rename audio files for mdx default field

rename audio files for mdx default field
This commit is contained in:
yu7777 2019-10-07 15:37:49 +11:00
parent b3da589ac8
commit 4603f662a5

View File

@ -672,8 +672,8 @@ class MdxService(LocalService):
html = html.replace(each, u'_' + each.split('/')[-1])
# find sounds
p = re.compile(
r'<a[^>]+?href=\"(sound:_.*?\.(?:mp3|wav))\"[^>]*?>(.*?)</a>')
html = p.sub(u"[\\1]\\2", html)
r'<a[^>]+?href=\"sound:_(.*?\.(?:mp3|wav))\"[^>]*?>(.*?)</a>')
html = p.sub("[sound:mdx-"+self.title+"-"+u"\\1]\\2", html)
self.save_media_files(media_files_set)
for f in mcss:
cssfile = u'_{}'.format(os.path.basename(f.replace('\\', os.path.sep)))
@ -701,6 +701,8 @@ class MdxService(LocalService):
basename = os.path.basename(filepath_in_mdx.replace('\\', os.path.sep))
if savepath is None:
savepath = '_' + basename
if basename.lower().endswith(("mp3","wav")):
savepath = "mdx-" + self.title + "-" + basename
if os.path.exists(savepath):
return savepath
try:
@ -739,6 +741,7 @@ class MdxService(LocalService):
lst.extend(keys)
for each in lst:
self.save_default_file(each)
except AttributeError:
pass