fix:UnicodeDecodeError()

This commit is contained in:
guorong.zheng 2024-11-18 10:24:29 +08:00
parent 390bf91f68
commit 8a884aa34e
3 changed files with 9 additions and 3 deletions

@ -1,5 +1,6 @@
import asyncio import asyncio
from utils.config import config from utils.config import config
import utils.constants as constants
from utils.channel import ( from utils.channel import (
get_channel_items, get_channel_items,
append_total_data, append_total_data,
@ -56,8 +57,11 @@ def show_log():
user_log_file = "output/" + ( user_log_file = "output/" + (
"user_result.log" if os.path.exists("config/user_config.ini") else "result.log" "user_result.log" if os.path.exists("config/user_config.ini") else "result.log"
) )
with open(user_log_file, "r", encoding="utf-8") as file: if os.path.exists(user_log_file):
content = file.read() with open(user_log_file, "r", encoding="utf-8") as file:
content = file.read()
else:
content = constants.waiting_tip
return render_template_string( return render_template_string(
"<head><link rel='icon' href='{{ url_for('static', filename='images/favicon.ico') }}' type='image/x-icon'></head><pre>{{ content }}</pre>", "<head><link rel='icon' href='{{ url_for('static', filename='images/favicon.ico') }}' type='image/x-icon'></head><pre>{{ content }}</pre>",
content=content, content=content,

@ -94,3 +94,5 @@ ipv6_proxy = "http://www.ipv6proxy.net/go.php?u="
foodie_url = "http://www.foodieguide.com/iptvsearch/" foodie_url = "http://www.foodieguide.com/iptvsearch/"
foodie_hotel_url = "http://www.foodieguide.com/iptvsearch/hoteliptv.php" foodie_hotel_url = "http://www.foodieguide.com/iptvsearch/hoteliptv.php"
waiting_tip = "🔍️正在更新,请耐心等待更新完成..."

@ -392,7 +392,7 @@ def get_result_file_content(show_result=False):
with open(user_final_file, "r", encoding="utf-8") as file: with open(user_final_file, "r", encoding="utf-8") as file:
content = file.read() content = file.read()
else: else:
content = "🔍️正在更新,请耐心等待更新完成..." content = constants.waiting_tip
return render_template_string( return render_template_string(
"<head><link rel='icon' href='{{ url_for('static', filename='images/favicon.ico') }}' type='image/x-icon'></head><pre>{{ content }}</pre>", "<head><link rel='icon' href='{{ url_for('static', filename='images/favicon.ico') }}' type='image/x-icon'></head><pre>{{ content }}</pre>",
content=content, content=content,