commit
18c87bc413
3
.gitignore
vendored
3
.gitignore
vendored
@ -116,3 +116,6 @@ User*/
|
|||||||
release*.zip
|
release*.zip
|
||||||
README.txt
|
README.txt
|
||||||
.fastwq_*_ankihub.json
|
.fastwq_*_ankihub.json
|
||||||
|
|
||||||
|
# idea ide
|
||||||
|
/.idea
|
||||||
|
|||||||
@ -100,7 +100,9 @@ _arr = [
|
|||||||
['DEF', u'释义', u'Definition'],
|
['DEF', u'释义', u'Definition'],
|
||||||
['PHON', u'音标', u'Phonetic Symbols'],
|
['PHON', u'音标', u'Phonetic Symbols'],
|
||||||
['BRE_PHON', u'英式音标', u'Phonetic Symbols (UK)'],
|
['BRE_PHON', u'英式音标', u'Phonetic Symbols (UK)'],
|
||||||
|
['BRE_PHON_NO_PREFIX', u'英式音标无前缀', u'Phonetic Symbols (UK) no prefix'],
|
||||||
['AME_PHON', u'美式音标', u'Phonetic Symbols (US)'],
|
['AME_PHON', u'美式音标', u'Phonetic Symbols (US)'],
|
||||||
|
['AME_PHON_NO_PREFIX', u'美式音标无前缀', u'Phonetic Symbols (US) no prefix'],
|
||||||
['IMAGE', u'图片', u'Images'],
|
['IMAGE', u'图片', u'Images'],
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
#-*- coding:utf-8 -*-
|
# -*- coding:utf-8 -*-
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
@ -6,7 +6,6 @@ from bs4 import Tag
|
|||||||
from ..base import *
|
from ..base import *
|
||||||
from ...utils.misc import format_multi_query_word
|
from ...utils.misc import format_multi_query_word
|
||||||
|
|
||||||
|
|
||||||
longman_download_mp3 = True
|
longman_download_mp3 = True
|
||||||
longman_download_img = True
|
longman_download_img = True
|
||||||
|
|
||||||
@ -30,8 +29,8 @@ class Longman(WebService):
|
|||||||
assert isinstance(dic_link, Tag)
|
assert isinstance(dic_link, Tag)
|
||||||
|
|
||||||
# remove sound tag
|
# remove sound tag
|
||||||
am_s_tag = dic_link.find('span', title='Play American pronunciation of {}'.format(self.word))
|
am_s_tag = dic_link.find('span', {'class': 'speaker amefile fa fa-volume-up hideOnAmp'})
|
||||||
br_s_tag = dic_link.find('span', title='Play British pronunciation of {}'.format(self.word))
|
br_s_tag = dic_link.find('span', {'class': 'speaker brefile fa fa-volume-up hideOnAmp'})
|
||||||
if am_s_tag:
|
if am_s_tag:
|
||||||
word_info['am_mp3'] = am_s_tag.get('data-src-mp3', u'')
|
word_info['am_mp3'] = am_s_tag.get('data-src-mp3', u'')
|
||||||
am_s_tag.decompose()
|
am_s_tag.decompose()
|
||||||
@ -91,7 +90,7 @@ class Longman(WebService):
|
|||||||
word_info['pos'] = POS
|
word_info['pos'] = POS
|
||||||
word_info['inflections'] = Inflections
|
word_info['inflections'] = Inflections
|
||||||
head_finded = True
|
head_finded = True
|
||||||
#self.cache_this(word_info)
|
# self.cache_this(word_info)
|
||||||
if head_tag:
|
if head_tag:
|
||||||
head_tag.decompose()
|
head_tag.decompose()
|
||||||
|
|
||||||
@ -118,7 +117,7 @@ class Longman(WebService):
|
|||||||
@export('PHON')
|
@export('PHON')
|
||||||
def fld_phonetic(self):
|
def fld_phonetic(self):
|
||||||
return self._get_field('phonetic')
|
return self._get_field('phonetic')
|
||||||
|
|
||||||
def _fld_mp3(self, fld):
|
def _fld_mp3(self, fld):
|
||||||
audio_url = self._get_field(fld)
|
audio_url = self._get_field(fld)
|
||||||
if longman_download_mp3 and audio_url:
|
if longman_download_mp3 and audio_url:
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
#from warnings import filterwarnings
|
# from warnings import filterwarnings
|
||||||
|
|
||||||
from bs4 import Tag
|
from bs4 import Tag
|
||||||
from ..base import *
|
from ..base import *
|
||||||
@ -14,7 +14,7 @@ import sys
|
|||||||
|
|
||||||
@register([u'牛津学习词典', u'Oxford Learner'])
|
@register([u'牛津学习词典', u'Oxford Learner'])
|
||||||
class OxfordLearning(WebService):
|
class OxfordLearning(WebService):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(OxfordLearning, self).__init__()
|
super(OxfordLearning, self).__init__()
|
||||||
|
|
||||||
@ -42,9 +42,11 @@ class OxfordLearning(WebService):
|
|||||||
if web_word:
|
if web_word:
|
||||||
self.cache_this(
|
self.cache_this(
|
||||||
{
|
{
|
||||||
'phonetic': '{} {}'.format(web_word.wd_phon_bre, web_word.wd_phon_nam),
|
'phonetic': '{} {}'.format(web_word.wd_phon_bre, web_word.wd_phon_ame),
|
||||||
'phon_bre': '{}'.format(web_word.wd_phon_bre),
|
'phon_bre': '{}'.format(web_word.wd_phon_bre),
|
||||||
'phon_ame': '{}'.format(web_word.wd_phon_nam),
|
'phon_ame': '{}'.format(web_word.wd_phon_ame),
|
||||||
|
'phon_bre_no_prefix': '{}'.format(web_word.wd_phon_bre_no_prefix),
|
||||||
|
'phon_ame_no_prefix': '{}'.format(web_word.wd_phon_ame_no_prefix),
|
||||||
'pos': web_word.wd_pos,
|
'pos': web_word.wd_pos,
|
||||||
'img_full': web_word.wd_image_full_url,
|
'img_full': web_word.wd_image_full_url,
|
||||||
'img_thumb': web_word.wd_image_thumb_url,
|
'img_thumb': web_word.wd_image_thumb_url,
|
||||||
@ -81,6 +83,14 @@ class OxfordLearning(WebService):
|
|||||||
def fld_phonetic_uk(self):
|
def fld_phonetic_uk(self):
|
||||||
return self._get_single_dict('phon_bre')
|
return self._get_single_dict('phon_bre')
|
||||||
|
|
||||||
|
@export('BRE_PHON_NO_PREFIX')
|
||||||
|
def fld_phonetic_us_no_prefix(self):
|
||||||
|
return self._get_single_dict('phon_bre_no_prefix')
|
||||||
|
|
||||||
|
@export('AME_PHON_NO_PREFIX')
|
||||||
|
def fld_phonetic_uk_no_prefix(self):
|
||||||
|
return self._get_single_dict('phon_ame_no_prefix')
|
||||||
|
|
||||||
@export([u'词性', u'POS'])
|
@export([u'词性', u'POS'])
|
||||||
def fld_pos(self):
|
def fld_pos(self):
|
||||||
return self._get_single_dict('pos')
|
return self._get_single_dict('pos')
|
||||||
@ -211,24 +221,35 @@ class OxfordLearningDictWord:
|
|||||||
|
|
||||||
# endregion
|
# endregion
|
||||||
|
|
||||||
|
def _pull_bre_phon(self):
|
||||||
|
try:
|
||||||
|
_tag_phn = self.tag_phon_bre.find('span', self._cls_dic('phon')).get_text().replace('/', '').replace('BrE', '')
|
||||||
|
phon = '/{}/'.format(_tag_phn.text if isinstance(_tag_phn, Tag) else _tag_phn)
|
||||||
|
except:
|
||||||
|
phon = ''
|
||||||
|
return phon
|
||||||
|
|
||||||
|
@property
|
||||||
|
def wd_phon_bre_no_prefix(self):
|
||||||
|
"""
|
||||||
|
|
||||||
|
:return: phon
|
||||||
|
"""
|
||||||
|
return self._pull_bre_phon()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wd_phon_bre(self):
|
def wd_phon_bre(self):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:return: pre_fix, phon
|
:return: pre_fix, phon
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
_tag_phn = self.tag_phon_bre.find('span', self._cls_dic('phon')).contents[3]
|
|
||||||
phon = '/{}/'.format(_tag_phn.text if isinstance(_tag_phn, Tag) else _tag_phn)
|
|
||||||
except:
|
|
||||||
phon = ''
|
|
||||||
try:
|
try:
|
||||||
prefix = self.tag_phon_bre.find('span', self._cls_dic('prefix')).string
|
prefix = self.tag_phon_bre.find('span', self._cls_dic('prefix')).string
|
||||||
except:
|
except:
|
||||||
prefix = ''
|
prefix = ''
|
||||||
return "{} {}".format(
|
return "{} {}".format(
|
||||||
prefix,
|
prefix,
|
||||||
phon
|
self._pull_bre_phon()
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
@ -238,24 +259,35 @@ class OxfordLearningDictWord:
|
|||||||
except:
|
except:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
def _pull_ame_phon(self):
|
||||||
|
try:
|
||||||
|
_tag_phn = self.tag_phon_nam.find('span', self._cls_dic('phon')).get_text().replace('/', '').replace('NAmE', '')
|
||||||
|
phon = '/{}/'.format(_tag_phn.text if isinstance(_tag_phn, Tag) else _tag_phn)
|
||||||
|
except:
|
||||||
|
phon = ''
|
||||||
|
return phon
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def wd_phon_nam(self):
|
def wd_phon_ame_no_prefix(self):
|
||||||
|
"""
|
||||||
|
|
||||||
|
:return: phon
|
||||||
|
"""
|
||||||
|
return self._pull_ame_phon()
|
||||||
|
|
||||||
|
@property
|
||||||
|
def wd_phon_ame(self):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
:return: pre_fix, phon
|
:return: pre_fix, phon
|
||||||
"""
|
"""
|
||||||
try:
|
|
||||||
_tag_phn = self.tag_phon_nam.find('span', self._cls_dic('phon')).contents[3]
|
|
||||||
phon = '/{}/'.format(_tag_phn.text if isinstance(_tag_phn, Tag) else _tag_phn)
|
|
||||||
except:
|
|
||||||
phon = ''
|
|
||||||
try:
|
try:
|
||||||
prefix = self.tag_phon_nam.find('span', self._cls_dic('prefix')).string
|
prefix = self.tag_phon_nam.find('span', self._cls_dic('prefix')).string
|
||||||
except:
|
except:
|
||||||
prefix = ''
|
prefix = ''
|
||||||
return "{} {}".format(
|
return "{} {}".format(
|
||||||
prefix,
|
prefix,
|
||||||
phon
|
self._pull_ame_phon()
|
||||||
)
|
)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user