diff --git a/main.py b/main.py index 5d076bc439d..17c52a8cdbc 100644 --- a/main.py +++ b/main.py @@ -30,7 +30,8 @@ format_interval, check_ipv6_support, resource_path, - get_urls_from_file + get_urls_from_file, + get_version_info ) @@ -212,6 +213,8 @@ def stop(self): if __name__ == "__main__": + info = get_version_info() + print(f"ℹ️ {info['name']} Version: {info['version']}") loop = asyncio.new_event_loop() asyncio.set_event_loop(loop) update_source = UpdateSource() diff --git a/tkinter_ui/tkinter_ui.py b/tkinter_ui/tkinter_ui.py index 540ddc9ce0a..17cb75a01d9 100644 --- a/tkinter_ui/tkinter_ui.py +++ b/tkinter_ui/tkinter_ui.py @@ -6,7 +6,7 @@ from tkinter import messagebox from PIL import Image, ImageTk from utils.config import config -from utils.tools import resource_path +from utils.tools import resource_path, get_version_info from main import UpdateSource import asyncio import threading @@ -19,14 +19,12 @@ from hotel import HotelUI from subscribe import SubscribeUI from online_search import OnlineSearchUI -import json from utils.speed import check_ffmpeg_installed_status class TkinterUI: def __init__(self, root): - with open(resource_path("version.json"), "r", encoding="utf-8") as f: - info = json.load(f) + info = get_version_info() self.root = root self.root.title(info.get("name", "")) self.version = info.get("version", "") diff --git a/utils/tools.py b/utils/tools.py index 451dd2c3269..20eaf9ebb4f 100644 --- a/utils/tools.py +++ b/utils/tools.py @@ -1,5 +1,6 @@ import datetime import ipaddress +import json import logging import os import re @@ -592,3 +593,11 @@ def get_datetime_now(): now = datetime.datetime.now() time_zone = pytz.timezone(config.time_zone) return now.astimezone(time_zone).strftime("%Y-%m-%d %H:%M:%S") + + +def get_version_info(): + """ + Get the version info + """ + with open(resource_path("version.json"), "r", encoding="utf-8") as f: + return json.load(f)