处理404 emoji

This commit is contained in:
STDquantum 2023-12-22 19:22:30 +08:00
parent 3a7049d08f
commit 206dbc88f8
2 changed files with 10 additions and 10 deletions

View File

@ -336,11 +336,7 @@ class ChildThread(QThread):
displayname = escape_js_and_html(displayname)
if self.output_type == Output.HTML:
emoji_path = get_emoji(str_content, thumb=True, output_path=origin_docx_path + '/emoji')
if emoji_path == "":
# todo 改为网络404图片
emoji_path = "./emoji/404.png"
else:
emoji_path = './emoji/' + os.path.basename(emoji_path)
emoji_path = './emoji/' + os.path.basename(emoji_path)
if self.is_5_min(timestamp):
doc.write(
f'''{{ type:0, text: '{str_time}',is_send:0,avatar_path:'',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''

View File

@ -13,7 +13,7 @@ import traceback
import xml.etree.ElementTree as ET
import sqlite3
import threading
from PyQt5.QtGui import QPixmap
import requests
from app.log import log, logger
@ -144,8 +144,6 @@ class Emotion:
@log
def download(url, output_dir, name, thumb=False):
if not url:
return ':/icons/icons/404.png'
resp = requests.get(url)
byte = resp.content
image_format = get_image_format(byte[:8])
@ -221,10 +219,16 @@ def get_emoji(xml_string, thumb=True, output_path=root_path) -> str:
return output_path
else:
print("!!!未知表情包数据,信息:", xml_string, emoji_info, url)
return ""
output_path = os.path.join(output_path, '404.png')
if not os.path.exists(output_path):
QPixmap(':/icons/icons/404.png').save(output_path)
return output_path
except:
logger.error(traceback.format_exc())
return ""
output_path = os.path.join(output_path, "404.png")
if not os.path.exists(output_path):
QPixmap(':/icons/icons/404.png').save(output_path)
return output_path
if __name__ == '__main__':