bug fixes.

This commit is contained in:
St.Huang 2018-07-31 11:53:18 +08:00
parent 90cf0834d1
commit 2fc6de3af0
10 changed files with 15 additions and 21 deletions

View File

@ -36,8 +36,7 @@ class Baicizhan(WebService):
@export('PRON')
def fld_phonetic(self):
url = u'http://baicizhan.qiniucdn.com/word_audios/{}.mp3'.format(self.quote_word)
audio_name = 'bcz_%s.mp3' % self.word
audio_name = get_hex_name(self.unique.lower(), audio_name, 'mp3')
audio_name = get_hex_name(self.unique.lower(), url, 'mp3')
if self.bcz_download_mp3:
if os.path.exists(audio_name) or self.download(url, audio_name, 5):
with open(audio_name, 'rb') as f:

View File

@ -71,8 +71,7 @@ class Baidu_Chinese(WebService):
def fld_pron(self):
audio_url = self._get_field('audio_url')
if baidu_download_mp3 and audio_url:
filename = u'_baidu_chinese_{}_.mp3'.format(self.word)
filename = get_hex_name(self.unique.lower(), filename, 'mp3')
filename = get_hex_name(self.unique.lower(), audio_url, 'mp3')
try:
if os.path.exists(filename) or self.net_download(
filename,

View File

@ -60,8 +60,7 @@ class Frdic(WebService):
url = 'https://api.frdic.com/api/v2/speech/speakweb?langid=fr&txt=QYN{word}'.format(
word=urllib2.quote(base64.b64encode(self.word.encode('utf-8')))
)
filename = u'frdic_{word}.mp3'.format(word=self.word)
filename = get_hex_name(self.unique.lower(), filename, 'mp3')
filename = get_hex_name(self.unique.lower(), url, 'mp3')
if os.path.exists(filename) or self.net_download(filename, url):
return self.get_anki_label(filename, 'audio')
return ''

View File

@ -58,7 +58,7 @@ class ICIBA(WebService):
if not audio_url:
audio_url, t = seg['symbols'][0]['ph_tts_mp3'], 'tts'
if iciba_download_mp3 and audio_url:
filename = u'iciba_{0}_{1}.mp3'.format(self.word, t)
filename = get_hex_name(self.unique.lower(), audio_url, 'mp3')
if os.path.exists(filename) or self.download(audio_url, filename):
return self.get_anki_label(filename, 'audio')
return audio_url
@ -71,7 +71,7 @@ class ICIBA(WebService):
if not audio_url:
audio_url, t = seg['symbols'][0]['ph_tts_mp3'], 'tts'
if iciba_download_mp3 and audio_url:
filename = u'iciba_{0}_{1}.mp3'.format(self.word, t)
filename = get_hex_name(self.unique.lower(), audio_url, 'mp3')
if os.path.exists(filename) or self.download(audio_url, filename):
return self.get_anki_label(filename, 'audio')
return audio_url

View File

@ -71,14 +71,14 @@ class OxfordLearning(WebService):
def get_sound_bre(self):
url = self._get_single_dict('s_bre')
filename = u'oxford_{}_uk.mp3'.format(self.word)
filename = get_hex_name(self.unique.lower(), url, 'mp3')
if url and self.download(url, filename):
return self.get_anki_label(filename, 'audio')
return ''
def get_sound_ame(self):
url = self._get_single_dict('s_ame')
filename = u'oxford_{}_us.mp3'.format(self.word)
filename = get_hex_name(self.unique.lower(), url, 'mp3')
if url and self.download(url, filename):
return self.get_anki_label(filename, 'audio')
return ''

View File

@ -36,8 +36,7 @@ class Baicizhan(WebService):
@export('PRON')
def fld_phonetic(self):
url = u'http://baicizhan.qiniucdn.com/word_audios/{}.mp3'.format(self.quote_word)
audio_name = 'bcz_%s.mp3' % self.word
audio_name = get_hex_name(self.unique.lower(), audio_name, 'mp3')
audio_name = get_hex_name(self.unique.lower(), url, 'mp3')
if self.bcz_download_mp3:
if os.path.exists(audio_name) or self.download(url, audio_name, 5):
with open(audio_name, 'rb') as f:

View File

@ -71,8 +71,7 @@ class Baidu_Chinese(WebService):
def fld_pron(self):
audio_url = self._get_field('audio_url')
if baidu_download_mp3 and audio_url:
filename = u'_baidu_chinese_{}_.mp3'.format(self.word)
filename = get_hex_name(self.unique.lower(), filename, 'mp3')
filename = get_hex_name(self.unique.lower(), audio_url, 'mp3')
try:
if os.path.exists(filename) or self.net_download(
filename,

View File

@ -60,8 +60,7 @@ class Frdic(WebService):
url = 'https://api.frdic.com/api/v2/speech/speakweb?langid=fr&txt=QYN{word}'.format(
word=urllib2.quote(base64.b64encode(self.word.encode('utf-8')))
)
filename = u'frdic_{word}.mp3'.format(word=self.word)
filename = get_hex_name(self.unique.lower(), filename, 'mp3')
filename = get_hex_name(self.unique.lower(), url, 'mp3')
if os.path.exists(filename) or self.net_download(filename, url):
return self.get_anki_label(filename, 'audio')
return ''

View File

@ -58,7 +58,7 @@ class ICIBA(WebService):
if not audio_url:
audio_url, t = seg['symbols'][0]['ph_tts_mp3'], 'tts'
if iciba_download_mp3 and audio_url:
filename = u'iciba_{0}_{1}.mp3'.format(self.word, t)
filename = get_hex_name(self.unique.lower(), audio_url, 'mp3')
if os.path.exists(filename) or self.download(audio_url, filename):
return self.get_anki_label(filename, 'audio')
return audio_url
@ -71,7 +71,7 @@ class ICIBA(WebService):
if not audio_url:
audio_url, t = seg['symbols'][0]['ph_tts_mp3'], 'tts'
if iciba_download_mp3 and audio_url:
filename = u'iciba_{0}_{1}.mp3'.format(self.word, t)
filename = get_hex_name(self.unique.lower(), audio_url, 'mp3')
if os.path.exists(filename) or self.download(audio_url, filename):
return self.get_anki_label(filename, 'audio')
return audio_url

View File

@ -2,7 +2,7 @@
#from warnings import filterwarnings
from bs4 import Tag
from ..base import WebService, export, register, with_styles, parse_html
from ..base import *
#filterwarnings('ignore')
@ -77,14 +77,14 @@ class OxfordLearning(WebService):
def get_sound_bre(self):
url = self._get_single_dict('s_bre')
filename = u'oxford_{}_uk.mp3'.format(self.word)
filename = get_hex_name(self.unique.lower(), url, 'mp3')
if url and self.download(url, filename):
return self.get_anki_label(filename, 'audio')
return ''
def get_sound_ame(self):
url = self._get_single_dict('s_ame')
filename = u'oxford_{}_us.mp3'.format(self.word)
filename = get_hex_name(self.unique.lower(), url, 'mp3')
if url and self.download(url, filename):
return self.get_anki_label(filename, 'audio')
return ''