fix bing sound's field error.

This commit is contained in:
St.Huang 2018-07-12 00:06:19 +08:00
parent b3c36c4493
commit ec4327958a
2 changed files with 6 additions and 6 deletions

View File

@ -86,9 +86,9 @@ class Bing(WebService):
def _fld_mp3(self, fld):
audio_url = self._get_field('pronunciation')[fld]
if bing_download_mp3 and audio_url:
filename = u''.join(re.findall(r'\w*\.mp3', audio_url))
if filename and self.download(audio_url, filename):
return self.get_anki_label(u'bing_{0}_{1}'.format(fld, filename), 'audio')
filename = u'bing_' + u''.join(re.findall(r'\w*\.mp3', audio_url))
if filename and self.net_download(filename, audio_url):
return self.get_anki_label(filename, 'audio')
return ''
@export('AME_PRON', 3)

View File

@ -45,9 +45,9 @@ class BingXtk(WebService):
def _fld_mp3(self, fld):
audio_url = self._get_field('pronunciation')[fld]
if bing_download_mp3 and audio_url:
filename = u''.join(re.findall(r'\w*\.mp3', audio_url))
if filename and self.download(audio_url, filename):
return self.get_anki_label(u'bing_{0}_{1}'.format(fld, filename), 'audio')
filename = u'bing_' + u''.join(re.findall(r'\w*\.mp3', audio_url))
if filename and self.net_download(filename, audio_url):
return self.get_anki_label(filename, 'audio')
return ''
@export('AME_PRON', 3)