fix #31
This commit is contained in:
parent
96432ca023
commit
b2754e080c
@ -2,27 +2,32 @@
|
|||||||
import re
|
import re
|
||||||
from ..base import *
|
from ..base import *
|
||||||
|
|
||||||
|
|
||||||
VOICE_PATTERN = r'<a href="sound://([\w/]+\w*\.mp3)"><img src="img/spkr_%s.png"></a>'
|
VOICE_PATTERN = r'<a href="sound://([\w/]+\w*\.mp3)"><img src="img/spkr_%s.png"></a>'
|
||||||
|
VOICE_PATTERN_WQ = r'<span class="%s"><a href="sound://([\w/]+\w*\.mp3)">(.*?)</span %s>'
|
||||||
MAPPINGS = [
|
MAPPINGS = [
|
||||||
['br', [re.compile(VOICE_PATTERN % r'r')]],
|
['br', [re.compile(VOICE_PATTERN % r'r'), re.compile(VOICE_PATTERN_WQ % (r'brevoice', r'brevoice'))]],
|
||||||
['us', [re.compile(VOICE_PATTERN % r'b')]]
|
['us', [re.compile(VOICE_PATTERN % r'b'), re.compile(VOICE_PATTERN_WQ % (r'amevoice', r'amevoice'))]]
|
||||||
]
|
]
|
||||||
LANG_TO_REGEXPS = {lang: regexps for lang, regexps in MAPPINGS}
|
LANG_TO_REGEXPS = {lang: regexps for lang, regexps in MAPPINGS}
|
||||||
|
DICT_PATH = u'' # u'E:\\BaiduYunDownload\\mdx\\L6mp3.mdx'
|
||||||
|
|
||||||
|
|
||||||
@register([u'本地词典-LDOCE6', u'MDX-LDOCE6'])
|
@register([u'本地词典-LDOCE6', u'MDX-LDOCE6'])
|
||||||
class Ldoce6(MdxService):
|
class Ldoce6(MdxService):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
from ...service import service_manager, service_pool
|
dict_path = DICT_PATH
|
||||||
dict_path = ''
|
# if DICT_PATH is a path, stop auto detect
|
||||||
for clazz in service_manager.mdx_services:
|
if not dict_path:
|
||||||
service = service_pool.get(clazz.__unique__)
|
from ...service import service_manager, service_pool
|
||||||
title = service.builder._title if service and service.support else u''
|
for clazz in service_manager.mdx_services:
|
||||||
service_pool.put(service)
|
service = service_pool.get(clazz.__unique__)
|
||||||
if title.startswith(u'LDOCE6'):
|
title = service.builder._title if service and service.support else u''
|
||||||
dict_path = service.dict_path
|
service_pool.put(service)
|
||||||
break
|
if title.startswith(u'LDOCE6'):
|
||||||
|
dict_path = service.dict_path
|
||||||
|
break
|
||||||
super(Ldoce6, self).__init__(dict_path)
|
super(Ldoce6, self).__init__(dict_path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
@ -4,26 +4,30 @@ from ..base import *
|
|||||||
|
|
||||||
|
|
||||||
VOICE_PATTERN = r'<a href="sound://([\w/]+\w*\.mp3)"><img src="img/spkr_%s.png"></a>'
|
VOICE_PATTERN = r'<a href="sound://([\w/]+\w*\.mp3)"><img src="img/spkr_%s.png"></a>'
|
||||||
|
VOICE_PATTERN_WQ = r'<span class="%s"><a href="sound://([\w/]+\w*\.mp3)">(.*?)</span %s>'
|
||||||
MAPPINGS = [
|
MAPPINGS = [
|
||||||
['br', [re.compile(VOICE_PATTERN % r'r')]],
|
['br', [re.compile(VOICE_PATTERN % r'r'), re.compile(VOICE_PATTERN_WQ % (r'brevoice', r'brevoice'))]],
|
||||||
['us', [re.compile(VOICE_PATTERN % r'b')]]
|
['us', [re.compile(VOICE_PATTERN % r'b'), re.compile(VOICE_PATTERN_WQ % (r'amevoice', r'amevoice'))]]
|
||||||
]
|
]
|
||||||
LANG_TO_REGEXPS = {lang: regexps for lang, regexps in MAPPINGS}
|
LANG_TO_REGEXPS = {lang: regexps for lang, regexps in MAPPINGS}
|
||||||
|
DICT_PATH = u'' # u'E:\\BaiduYunDownload\\mdx\\L6mp3.mdx'
|
||||||
|
|
||||||
|
|
||||||
@register([u'本地词典-LDOCE6', u'MDX-LDOCE6'])
|
@register([u'本地词典-LDOCE6', u'MDX-LDOCE6'])
|
||||||
class Ldoce6(MdxService):
|
class Ldoce6(MdxService):
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
from ...service import service_manager, service_pool
|
dict_path = DICT_PATH
|
||||||
dict_path = ''
|
# if DICT_PATH is a path, stop auto detect
|
||||||
for clazz in service_manager.mdx_services:
|
if not dict_path:
|
||||||
service = service_pool.get(clazz.__unique__)
|
from ...service import service_manager, service_pool
|
||||||
title = service.builder._title if service and service.support else u''
|
for clazz in service_manager.mdx_services:
|
||||||
service_pool.put(service)
|
service = service_pool.get(clazz.__unique__)
|
||||||
if title.startswith(u'LDOCE6'):
|
title = service.builder._title if service and service.support else u''
|
||||||
dict_path = service.dict_path
|
service_pool.put(service)
|
||||||
break
|
if title.startswith(u'LDOCE6'):
|
||||||
|
dict_path = service.dict_path
|
||||||
|
break
|
||||||
super(Ldoce6, self).__init__(dict_path)
|
super(Ldoce6, self).__init__(dict_path)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user