Skip to content

Commit

Permalink
Merge pull request #256 from Guovin/dev
Browse files Browse the repository at this point in the history
Release:v1.3.6
  • Loading branch information
Guovin authored Aug 22, 2024
2 parents 3dd3be2 + b36a886 commit 9272b97
Show file tree
Hide file tree
Showing 15 changed files with 232 additions and 76 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
dist
build
build
result_new.log
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# 更新日志(Changelog)

## v1.3.6

### 2024/8/22

- 新增酒店源更新,支持 Tonkiang、FOFA 两种工作模式(Added hotel source updates, supporting Tonkiang and FOFA working modes)
- 重构 UI 界面软件,新增帮助-关于、获取频道名称编辑、酒店源相关配置、软件图标(Refactored UI interface software, added Help-About, channel name editing, hotel source related configuration, and software icon)
- 移除关注频道相关配置(Removed configuration related to followed channels)
- 修复 Docker 定时任务未执行问题(Fixed issue with Docker scheduled tasks not executing)
- 修复使用历史结果时频道数据异常问题(Fixed issue with channel data anomalies when using historical results)
- 优化 UI 界面软件运行生成配置目录,方便查看与修改(Optimized UI interface software to generate configuration directory for easier viewing and modification)

## v1.3.5

### 2024/8/14
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ Fork 本项目并开启工作流更新

## 赞赏

![image](./docs/images/appreciate.jpg)
![image](./static/images/appreciate.jpg)
2 changes: 1 addition & 1 deletion README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,4 @@ If you don't want to bother, and my configuration just meets your needs, you can

## Appreciate

![image](./docs/images/appreciate.jpg)
![image](./static/images/appreciate.jpg)
2 changes: 1 addition & 1 deletion config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ multicast_region_list = 广东
multicast_page_num = 5
open_proxy = False
open_driver = False
open_hotel = False
open_hotel = True
open_hotel_tonkiang = True
open_hotel_fofa = True
hotel_region_list = 广东
Expand Down
51 changes: 35 additions & 16 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import asyncio
from utils.config import config
from utils.config import config, copy_config
from utils.channel import (
get_channel_items,
append_data_to_info_data,
Expand Down Expand Up @@ -34,7 +34,23 @@ def show_result():
user_final_file = config.get("Settings", "final_file")
with open(user_final_file, "r", encoding="utf-8") as file:
content = file.read()
return render_template_string("<pre>{{ content }}</pre>", content=content)
return render_template_string(
"<head><link rel='icon' href='{{ url_for('static', filename='images/favicon.ico') }}' type='image/x-icon'></head><pre>{{ content }}</pre>",
content=content,
)


@app.route("/log")
def show_log():
user_log_file = "output/" + (
"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:
content = file.read()
return render_template_string(
"<head><link rel='icon' href='{{ url_for('static', filename='images/favicon.ico') }}' type='image/x-icon'></head><pre>{{ content }}</pre>",
content=content,
)


class UpdateSource:
Expand Down Expand Up @@ -94,6 +110,8 @@ def sort_pbar_update(self):
async def main(self):
try:
self.channel_items = get_channel_items()
if self.run_ui:
copy_config()
channel_names = [
name
for channel_obj in self.channel_items.values()
Expand Down Expand Up @@ -171,8 +189,6 @@ async def main(self):
)
update_file(user_log_file, "output/result_new.log")
print(f"Update completed! Please check the {user_final_file} file!")
if not os.environ.get("GITHUB_ACTIONS"):
print(f"You can access the result at {get_ip_address()}")
if self.run_ui:
self.update_progress(
f"更新完成, 请检查{user_final_file}文件, 可访问以下链接:",
Expand All @@ -191,16 +207,14 @@ def default_callback(self, *args, **kwargs):
self.run_ui = True if callback else False
if config.getboolean("Settings", "open_update"):
await self.main()
if self.run_ui:
if not config.getboolean("Settings", "open_update"):
print(f"You can access the result at {get_ip_address()}")
self.update_progress(
f"服务启动成功, 可访问以下链接:",
100,
True,
url=f"{get_ip_address()}",
)
app.run(host="0.0.0.0", port=8000)
if self.run_ui and config.getboolean("Settings", "open_update") == False:
self.update_progress(
f"服务启动成功, 可访问以下链接:",
100,
True,
url=f"{get_ip_address()}",
)
run_app()

def stop(self):
for task in self.tasks:
Expand All @@ -218,8 +232,13 @@ def scheduled_task():
loop.run_until_complete(update_source.start())


def run_app():
if not os.environ.get("GITHUB_ACTIONS"):
print(f"You can access the result at {get_ip_address()}")
app.run(host="0.0.0.0", port=8000)


if __name__ == "__main__":
if len(sys.argv) == 1 or (len(sys.argv) > 1 and sys.argv[1] == "scheduled_task"):
scheduled_task()
if not os.environ.get("GITHUB_ACTIONS"):
app.run(host="0.0.0.0", port=8000)
run_app()
File renamed without changes
Binary file added static/images/favicon.ico
Binary file not shown.
87 changes: 87 additions & 0 deletions tkinter_ui/about.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import tkinter as tk
from PIL import Image, ImageTk
import webbrowser
from utils.config import resource_path


class AboutUI:
def init_ui(self, root=None, version=None):
about_window = tk.Toplevel(root)
about_window.title("关于")
about_window_width = 430
about_window_height = 430

version_frame = tk.Frame(about_window)
version_frame.pack(side=tk.TOP, fill=tk.X)

version_label = tk.Label(version_frame, text=f"版本: {version}")
version_label.pack()

author_row = tk.Frame(about_window)
author_row.pack()
author_row_column1 = tk.Frame(author_row)
author_row_column1.pack(side=tk.LEFT, fill=tk.Y)
author_row_column2 = tk.Frame(author_row)
author_row_column2.pack(side=tk.RIGHT, fill=tk.Y)
author_label = tk.Label(author_row_column1, text="作者:")
author_label.pack()
author_name = tk.Label(
author_row_column2, text="Govin", fg="blue", cursor="hand2"
)
author_name.pack()
author_name.bind(
"<Button-1>",
lambda e: webbrowser.open_new_tab("https://github.com/Guovin"),
)

project_row = tk.Frame(about_window)
project_row.pack()
project_row_column1 = tk.Frame(project_row)
project_row_column1.pack(side=tk.LEFT, fill=tk.Y)
project_row_column2 = tk.Frame(project_row)
project_row_column2.pack(side=tk.RIGHT, fill=tk.Y)
project_label = tk.Label(project_row_column1, text="项目地址:")
project_label.pack()
project_link = tk.Label(
project_row_column2,
text="https://github.com/Guovin/TV",
fg="blue",
cursor="hand2",
)
project_link.pack()
project_link.bind(
"<Button-1>",
lambda e: webbrowser.open_new_tab("https://github.com/Guovin/TV"),
)

disclaimer_label = tk.Label(
version_frame,
text="本软件仅供学习交流用途,数据均来源于互联网,禁止商业行为,一切法律责任与作者无关。",
wraplength=265,
)
disclaimer_label.pack()

image = Image.open(resource_path("static/images/appreciate.jpg"))
resized_image = image.resize((250, 250))
photo = ImageTk.PhotoImage(resized_image)
image_label = tk.Label(about_window, image=photo)
image_label.image = photo
image_label.pack()

appreciate_label = tk.Label(about_window, text="您的赞助是我更新的动力")
appreciate_label.pack()

confirm_button = tk.ttk.Button(
about_window, text="确定", command=about_window.destroy
)
confirm_button.pack(side=tk.RIGHT, padx=5)

main_width = root.winfo_width()
main_height = root.winfo_height()
main_x = root.winfo_x()
main_y = root.winfo_y()
pos_x = main_x + (main_width // 2) - (about_window_width // 2)
pos_y = main_y + (main_height // 2) - (about_window_height // 2)
about_window.geometry(
f"{about_window_width}x{about_window_height}+{pos_x}+{pos_y}"
)
10 changes: 8 additions & 2 deletions tkinter_ui/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from tkinter import scrolledtext
from tkinter import filedialog
import os
from utils.channel import get_channel_items


class DefaultUI:
Expand Down Expand Up @@ -67,7 +68,7 @@ def init_ui(self, root):
frame_default_source_file_select = tk.Frame(root)
frame_default_source_file_select.pack(fill=tk.X)

self.source_file_button = tk.Button(
self.source_file_button = tk.ttk.Button(
frame_default_source_file_select,
text="选择文件",
command=self.select_source_file,
Expand Down Expand Up @@ -106,7 +107,7 @@ def init_ui(self, root):
frame_default_final_file_select = tk.Frame(root)
frame_default_final_file_select.pack(fill=tk.X)

self.final_file_button = tk.Button(
self.final_file_button = tk.ttk.Button(
frame_default_final_file_select,
text="选择文件",
command=self.select_final_file,
Expand Down Expand Up @@ -305,6 +306,11 @@ def select_source_file(self):
self.source_file_entry.delete(0, tk.END)
self.source_file_entry.insert(0, filepath)
config.set("Settings", "source_file", filepath)
get_channel_items(change_source_path=True)
self.source_channels_text.delete(1.0, tk.END)
self.source_channels_text.insert(
tk.END, config.get("Settings", "source_channels")
)

def update_source_channels(self, event):
config.set(
Expand Down
74 changes: 33 additions & 41 deletions tkinter_ui/tkinter_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
sys.path.append(os.path.dirname(sys.path[0]))
import tkinter as tk
from tkinter import messagebox
from tkinter import ttk
from utils.config import config, resource_path, save_config
from main import UpdateSource
import asyncio
import threading
import webbrowser
from about import AboutUI
from default import DefaultUI
from multicast import MulticastUI
from hotel import HotelUI
Expand All @@ -25,6 +25,7 @@ def __init__(self, root):
self.root = root
self.root.title(info.get("name", ""))
self.version = info.get("version", "")
self.about_ui = AboutUI()
self.default_ui = DefaultUI()
self.multicast_ui = MulticastUI()
self.hotel_ui = HotelUI()
Expand Down Expand Up @@ -129,14 +130,23 @@ def update_progress(self, title, progress, finished=False, url=None):

def init_UI(self):

notebook = ttk.Notebook(self.root)
notebook.pack(expand=True, fill="both", padx=10, pady=0)
menu_bar = tk.Menu(self.root)
help_menu = tk.Menu(menu_bar, tearoff=0)
help_menu.add_command(
label="关于",
command=lambda: self.about_ui.init_ui(root=self.root, version=self.version),
)
menu_bar.add_cascade(label="帮助", menu=help_menu)
self.root.config(menu=menu_bar)

notebook = tk.ttk.Notebook(self.root)
notebook.pack(fill="both", padx=10, pady=5)

frame_default = ttk.Frame(notebook, width=500, height=500)
frame_multicast = ttk.Frame(notebook, width=500, height=500)
frame_hotel = ttk.Frame(notebook, width=500, height=500)
frame_subscribe = ttk.Frame(notebook, width=500, height=500)
frame_online_search = ttk.Frame(notebook, width=500, height=500)
frame_default = tk.ttk.Frame(notebook)
frame_multicast = tk.ttk.Frame(notebook)
frame_hotel = tk.ttk.Frame(notebook)
frame_subscribe = tk.ttk.Frame(notebook)
frame_online_search = tk.ttk.Frame(notebook)

notebook.add(frame_default, text="通用设置")
notebook.add(frame_multicast, text="组播源")
Expand All @@ -157,45 +167,20 @@ def init_UI(self):
root_operate_column2 = tk.Frame(root_operate)
root_operate_column2.pack(side=tk.RIGHT, fill=tk.Y)

self.save_button = tk.Button(
self.save_button = tk.ttk.Button(
root_operate_column1, text="保存设置", command=self.save_config
)
self.save_button.pack(side=tk.LEFT, padx=4, pady=8)

self.run_button = tk.Button(
self.run_button = tk.ttk.Button(
root_operate_column2, text="开始更新", command=self.on_run_update
)
self.run_button.pack(side=tk.LEFT, padx=4, pady=8)

version_frame = tk.Frame(self.root)
version_frame.pack(side=tk.BOTTOM, fill=tk.X)

self.version_label = tk.Label(
version_frame, text=self.version, fg="gray", anchor="se"
)
self.version_label.pack(side=tk.RIGHT, padx=5, pady=5)

self.author_label = tk.Label(
version_frame,
text="by Govin",
fg="gray",
anchor="se",
)
self.author_label.pack(side=tk.LEFT, padx=5, pady=5)

self.project_link = tk.Label(
version_frame, text="访问项目主页", fg="blue", cursor="hand2"
)
self.project_link.pack(side=tk.LEFT, padx=5, pady=5)
self.project_link.bind(
"<Button-1>",
lambda e: webbrowser.open_new_tab("https://github.com/Guovin/TV"),
)

root_progress = tk.Frame(self.root)
root_progress.pack(fill=tk.X)

self.progress_bar = ttk.Progressbar(
self.progress_bar = tk.ttk.Progressbar(
root_progress, length=300, mode="determinate"
)
self.progress_bar.pack_forget()
Expand All @@ -211,15 +196,22 @@ def init_UI(self):
self.view_result_link.pack_forget()


if __name__ == "__main__":
root = tk.Tk()
tkinter_ui = TkinterUI(root)
tkinter_ui.init_UI()
def get_root_location(root):
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
width = 550
height = 750
x = (screen_width / 2) - (width / 2)
y = (screen_height / 2) - (height / 2)
root.geometry("%dx%d+%d+%d" % (width, height, x, y))
return (width, height, x, y)


if __name__ == "__main__":
root = tk.Tk()
tkinter_ui = TkinterUI(root)
tkinter_ui.init_UI()
screen_width = root.winfo_screenwidth()
screen_height = root.winfo_screenheight()
root.geometry("%dx%d+%d+%d" % get_root_location(root))
root.iconbitmap(resource_path("static/images/favicon.ico"))
root.mainloop()
Loading

0 comments on commit 9272b97

Please sign in to comment.