Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Release 1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
MIKUScallion authored and MIKUScallion committed Jun 6, 2017
0 parents commit daa0147
Show file tree
Hide file tree
Showing 19 changed files with 1,797 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_tmp
lib
*.pyc
Binary file added 68479879-77DB-40FB-BD44-481312F4F9E8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 8534075D-9951-4504-B075-99172EE0570A.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added 902131C7-E337-4063-82F7-8B84909459A4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added E2838444-EDB0-4D05-A744-14970516F96D.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions MANIFEST
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# file GENERATED by distutils, do NOT edit
index.py
main.py
setup.py
utils/__init__.py
utils/cookie_util.py
utils/extract_util.py
utils/page_util.py
vendor/lxml/ElementInclude.py
vendor/lxml/__init__.py
vendor/lxml/_elementpath.py
vendor/lxml/builder.py
vendor/lxml/cssselect.py
vendor/lxml/doctestcompare.py
vendor/lxml/pyclasslookup.py
vendor/lxml/sax.py
vendor/lxml/usedoctest.py
43 changes: 43 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Onigiri 饭团日语词典

饭团日语词典 是 Alfred 3 的一个 Workflow,用于快速查询日语单词( 日 -> 中 ),查询结果除基本信息外,还包含读音与例句等。

## 用法

### 完全版

在 Alfred 中输入关键词 **onigiri** 或快捷键 **Cmd + O**,空格后加上查询内容,例如:

```
onigiri mama
```

运行结果为:

![](./readme_01.png)

### 简版

在 Alfred 中输入关键词 **onigiri_lite** 或 快捷键 **Alt + l**,空格后加上查询内容,例如:

```
onigiri_lite mama
```

运行结果为:

![](./readme_02.png)

### 其他

在选择项目上按下 Enter、Ctrl、Alt、Cmd、Cmd + L 与 CMD + L 等,来获得帮助或使用更多功能,尝试一下吧!

希望,这个小工具能够帮助到和我一样喜欢日语的您,(///▽///)

### 免责声明

* 词典数据来源于 [沪江小D]('http://dict.hjenglish.com/jp/jc'),仅用于个人学习交流使用
* 在使用过程中,程序会将用户的查询结果缓存起来(本地缓存 + 服务器缓存),但不会上传查词结果之外任何用户数据
* Dependent on [lxml](http://lxml.de). The lxml library is shipped under a **[BSD license](https://github.com/lxml/lxml/blob/master/doc/licenses/BSD.txt)**. libxml2 and libxslt2 itself are shipped under the **[MIT license](http://www.opensource.org/licenses/mit-license.html)**. There should therefore be no obstacle to using lxml in your codebase.
* <div>Icons made by <a href="http://www.freepik.com" title="Freepik">Freepik</a> from <a href="http://www.flaticon.com" title="Flaticon">www.flaticon.com</a> is licensed by <a href="http://creativecommons.org/licenses/by/3.0/" title="Creative Commons BY 3.0" target="_blank">CC 3.0 BY</a></div>
* Current version 1.1
Binary file added assets/mushroom.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/onigiri.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/popsicle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/scallion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
79 changes: 79 additions & 0 deletions converter_util.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import json
import hashlib

payload = {}

def converte (data):
for word in data['2']:
c_word = {
'title': _first(word['0']),
'subtitle': ''.join(word['5']) + '\t' + '%s %d-%d %s' % (_first(word['1']),
word['3'], word['2'], _first(word['4'])),
'audio': _first(word['6']),
'type': {}
}
c_word['uid'] = _hash_json(c_word)
payload[c_word['uid']] = c_word
for btype in word['9']:
for explain in btype['1']:
c_type = {
'title': _first(btype['0']),
'subtitle': _first(explain['0']),
'example': {}
}
c_type['uid'] = _hash_json(c_type)
c_word['type'][c_type['uid']] = c_type
for g_exp in explain['1']:
for exp in g_exp:
c_exp = {
'audio': ''
}
for index in range(0, len(exp)):
if index == 0:
c_exp['title'] = exp[index]
if index == 1:
c_exp['subtitle'] = exp[index]
c_exp['uid'] = _hash_json(c_exp)
c_type['example'][c_exp['uid']] = c_exp
for exp in explain['2']:
c_exp = {
'audio': ''
}
for index in range(0, len(exp)):
if index == 0:
c_exp['title'] = exp[index]
if index == 1:
c_exp['subtitle'] = exp[index]
if index == 2:
c_exp['audio'] = exp[index]
c_exp['uid'] = _hash_json(c_exp)
c_type['example'][c_exp['uid']] = c_exp

if not payload.keys():
raise Exception

return payload

def _stringify_json (json_data, decode = False):
tmp = json.dumps(json_data)
if decode:
tmp = tmp.decode('unicode-escape')
return tmp

def _hash_json (json_data):
tmp = _stringify_json(json_data)
return hashlib.md5(tmp).hexdigest()

def _first (list):
if len(list) > 0:
return list[0]
return ''

def _big_type_get_title (big_type):
_print_json(big_type)

def _print_json (json_data):
print _stringify_json(json_data, True)
Binary file added icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 15 additions & 0 deletions index.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/python
# -*- coding: UTF-8 -*-

import sys
import main

if len(sys.argv) > 1:
query = sys.argv[1]
else:
query = ''

if query:
print main.get(query)
else:
main.clean()
Loading

0 comments on commit daa0147

Please sign in to comment.