Update mdict.py

This commit is contained in:
恍兮惚兮 2024-05-21 02:44:59 +08:00
parent e75a3fcb60
commit 28cbcd8f45

View File

@ -2516,8 +2516,8 @@ class mdict(cishubase):
base64_content = base64.b64encode(file_content).decode('utf-8') base64_content = base64.b64encode(file_content).decode('utf-8')
import uuid import uuid
uid=str(uuid.uuid4()) uid=str(uuid.uuid4())
with open(uid+'.mp3','wb') as ff: # with open(uid+'.mp3','wb') as ff:
ff.write(file_content) # ff.write(file_content)
audio=f'<audio controls id="{uid}" style="display: none"><source src="data:{self.get_mime_type_from_magic(file_content)};base64,{base64_content}"></audio>' audio=f'<audio controls id="{uid}" style="display: none"><source src="data:{self.get_mime_type_from_magic(file_content)};base64,{base64_content}"></audio>'
html_content = audio+html_content.replace(url, f"javascript:document.getElementById('{uid}').play()") html_content = audio+html_content.replace(url, f"javascript:document.getElementById('{uid}').play()")
file_content=None file_content=None