mirror of
https://github.com/LibraHp/GetQzonehistory.git
synced 2024-12-27 22:49:09 +00:00
优化代码,去除非法字符/Emoji表情
This commit is contained in:
parent
3f96e387c7
commit
3e331172c3
10
main.py
10
main.py
@ -24,6 +24,7 @@ user_message = list()
|
||||
leave_message = list()
|
||||
forward_message = list()
|
||||
|
||||
|
||||
# 信号处理函数
|
||||
def signal_handler(signal, frame):
|
||||
# 在手动结束程序时保存已有的数据
|
||||
@ -135,12 +136,13 @@ def save_data():
|
||||
# 可见说说中可能存在多张图片
|
||||
item_pic_links = str(item[2]).split(",")
|
||||
for item_pic_link in item_pic_links:
|
||||
if item_pic_link is not None and len(item_pic_link) > 0 and 'http' in item_pic_link:
|
||||
# 保存图片
|
||||
pic_name = re.sub(r'[\\/:*?"<>|]', '_', item_text) + '.jpg'
|
||||
# 如果图片链接为空或者不是http链接,则跳过
|
||||
if not item_pic_link or len(item_pic_link) == 0 or 'http' not in item_pic_link:
|
||||
continue
|
||||
# 去除非法字符 / Emoji表情
|
||||
pic_name = re.sub(r'\[em\].*?\[/em\]|[^\w\s]|[\\/:*?"<>|\r\n]+', '_', item_text).replace(" ", "") + '.jpg'
|
||||
# 去除文件名中的空格
|
||||
pic_name = pic_name.replace(' ', '')
|
||||
|
||||
# 限制文件名长度
|
||||
if len(pic_name) > 40:
|
||||
pic_name = pic_name[:40] + '.jpg'
|
||||
|
Loading…
Reference in New Issue
Block a user