mirror of
https://github.com/LC044/WeChatMsg
synced 2025-02-23 03:22:17 +08:00
处理404 emoji
This commit is contained in:
parent
3a7049d08f
commit
206dbc88f8
@ -336,11 +336,7 @@ class ChildThread(QThread):
|
|||||||
displayname = escape_js_and_html(displayname)
|
displayname = escape_js_and_html(displayname)
|
||||||
if self.output_type == Output.HTML:
|
if self.output_type == Output.HTML:
|
||||||
emoji_path = get_emoji(str_content, thumb=True, output_path=origin_docx_path + '/emoji')
|
emoji_path = get_emoji(str_content, thumb=True, output_path=origin_docx_path + '/emoji')
|
||||||
if emoji_path == "":
|
emoji_path = './emoji/' + os.path.basename(emoji_path)
|
||||||
# todo 改为网络404图片
|
|
||||||
emoji_path = "./emoji/404.png"
|
|
||||||
else:
|
|
||||||
emoji_path = './emoji/' + os.path.basename(emoji_path)
|
|
||||||
if self.is_5_min(timestamp):
|
if self.is_5_min(timestamp):
|
||||||
doc.write(
|
doc.write(
|
||||||
f'''{{ type:0, text: '{str_time}',is_send:0,avatar_path:'',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''
|
f'''{{ type:0, text: '{str_time}',is_send:0,avatar_path:'',timestamp:{timestamp},is_chatroom:{is_chatroom},displayname:'{displayname}'}},'''
|
||||||
|
@ -13,7 +13,7 @@ import traceback
|
|||||||
import xml.etree.ElementTree as ET
|
import xml.etree.ElementTree as ET
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import threading
|
import threading
|
||||||
|
from PyQt5.QtGui import QPixmap
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
from app.log import log, logger
|
from app.log import log, logger
|
||||||
@ -144,8 +144,6 @@ class Emotion:
|
|||||||
|
|
||||||
@log
|
@log
|
||||||
def download(url, output_dir, name, thumb=False):
|
def download(url, output_dir, name, thumb=False):
|
||||||
if not url:
|
|
||||||
return ':/icons/icons/404.png'
|
|
||||||
resp = requests.get(url)
|
resp = requests.get(url)
|
||||||
byte = resp.content
|
byte = resp.content
|
||||||
image_format = get_image_format(byte[:8])
|
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
|
return output_path
|
||||||
else:
|
else:
|
||||||
print("!!!未知表情包数据,信息:", xml_string, emoji_info, url)
|
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:
|
except:
|
||||||
logger.error(traceback.format_exc())
|
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__':
|
if __name__ == '__main__':
|
||||||
|
Loading…
Reference in New Issue
Block a user