Skip to content

Commit

Permalink
feat:hotel mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Guovin committed Aug 21, 2024
1 parent b49eb4d commit 5ad8834
Show file tree
Hide file tree
Showing 7 changed files with 74 additions and 20 deletions.
7 changes: 3 additions & 4 deletions config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ open_proxy = False
open_driver = False

open_hotel = False
open_hotel_tonkiang = True
open_hotel_fofa = True
hotel_region_list = 广东
hotel_page_num = 5

open_fofa = False
fofa_region_list = all
hotel_page_num = 5
2 changes: 2 additions & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,7 @@
| multicast_region_list | 广东 | 组播源地区列表,[更多地区](../updates/multicast/multicast_map.json),all 表示所有地区 |
| multicast_page_num | 5 | 组播地区获取分页数量 |
| open_hotel | False | 开启酒店源功能 |
| open_hotel_tonkiang | True | 开启 Tonkiang 酒店源工作模式 |
| open_hotel_fofa | True | 开启 FOFA 酒店源工作模式 |
| hotel_region_list | 广东 | 酒店源地区列表,[更多地区](../updates/fofa/fofa_map.py),all 表示所有地区 |
| hotel_page_num | 5 | 酒店地区获取分页数量 |
8 changes: 7 additions & 1 deletion docs/config_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
| source_file | config/demo.txt | Template file name |
| final_file | output/result.txt | Generated file name |
| open_online_search | False | Enable online search source feature |
| page_num | 5 | Page retrieval quantity for favorite channels |
| page_num | 5 | Page retrieval quantity for channels |
| urls_limit | 10 | Number of interfaces per channel |
| open_keep_all | False | Retain all search results, retain results with non-template channel names, recommended to be turned on when manually maintaining |
| open_sort | True | Enable the sorting function (response speed, date, resolution) |
Expand All @@ -21,3 +21,9 @@
| subscribe_urls | https://m3u.ibert.me/txt/fmml_dv6.txt,<br>https://m3u.ibert.me/txt/o_cn.txt,<br>https://m3u.ibert.me/txt/j_iptv.txt | Subscription source list |
| open_multicast | True | Enable multicast source function |
| region_list | 广东 | Multicast source region list, [more regions](../updates/multicast/multicast_map.json, all means all regions) |
| multicast_page_num | 5 | Number of pages to retrieve for multicast regions |
| open_hotel | False | Enable hotel source feature |
| open_hotel_tonkiang | True | Enable Tonkiang hotel source work mode |
| open_hotel_fofa | True | Enable FOFA hotel source work mode |
| hotel_region_list | 广东 | List of hotel source regions, [more regions](../updates/fofa/fofa_map.py), 'all' indicates all regions |
| hotel_page_num | 5 | Number of pages to retrieve for hotel regions |
16 changes: 10 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ def __init__(self):
self.channel_items = get_channel_items()
self.subscribe_result = {}
self.multicast_result = {}
self.hotel_result = {}
self.fofa_result = {}
self.hotel_tonkiang_result = {}
self.hotel_fofa_result = {}
self.online_search_result = {}
self.channel_data = {}
self.pbar = None
Expand All @@ -58,8 +58,8 @@ async def visit_page(self, channel_names=None):
tasks_config = [
("open_subscribe", get_channels_by_subscribe_urls, "subscribe_result"),
("open_multicast", get_channels_by_multicast, "multicast_result"),
("open_hotel", get_channels_by_hotel, "hotel_result"),
("open_fofa", get_channels_by_fofa, "fofa_result"),
("open_hotel_tonkiang", get_channels_by_hotel, "hotel_tonkiang_result"),
("open_hotel_fofa", get_channels_by_fofa, "hotel_fofa_result"),
(
"open_online_search",
get_channels_by_online_search,
Expand All @@ -68,6 +68,10 @@ async def visit_page(self, channel_names=None):
]

for setting, task_func, result_attr in tasks_config:
if (
setting == "open_hotel_tonkiang" or setting == "open_hotel_fofa"
) and config.getboolean("Settings", "open_hotel") == False:
continue
if config.getboolean("Settings", setting):
task = asyncio.create_task(
task_func(channel_names, self.update_progress)
Expand Down Expand Up @@ -102,8 +106,8 @@ async def main(self):
self.channel_data,
self.subscribe_result,
self.multicast_result,
self.hotel_result,
self.fofa_result,
self.hotel_tonkiang_result,
self.hotel_fofa_result,
self.online_search_result,
)
if config.getboolean("Settings", "open_sort"):
Expand Down
43 changes: 43 additions & 0 deletions tkinter_ui/hotel.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,39 @@ def init_ui(self, root):
)
self.open_hotel_checkbutton.pack(side=tk.LEFT, padx=4, pady=8)

frame_hotel_mode = tk.Frame(root)
frame_hotel_mode.pack(fill=tk.X)

self.open_hotel_mode_label = tk.Label(
frame_hotel_mode, text="工作模式:", width=9
)
self.open_hotel_mode_label.pack(side=tk.LEFT, padx=4, pady=8)
self.open_hotel_tonkiang_var = tk.BooleanVar(
value=config.getboolean("Settings", "open_hotel_tonkiang")
)
self.open_hotel_tonkiang_checkbutton = ttk.Checkbutton(
frame_hotel_mode,
variable=self.open_hotel_tonkiang_var,
onvalue=True,
offvalue=False,
command=self.update_open_hotel_tonkiang,
text="Tonkiang",
)
self.open_hotel_tonkiang_checkbutton.pack(side=tk.LEFT, padx=4, pady=8)

self.open_hotel_fofa_var = tk.BooleanVar(
value=config.getboolean("Settings", "open_hotel_fofa")
)
self.open_hotel_fofa_checkbutton = ttk.Checkbutton(
frame_hotel_mode,
variable=self.open_hotel_fofa_var,
onvalue=True,
offvalue=False,
command=self.update_open_hotel_fofa,
text="FOFA",
)
self.open_hotel_fofa_checkbutton.pack(side=tk.LEFT, padx=4, pady=8)

frame_hotel_region_list = tk.Frame(root)
frame_hotel_region_list.pack(fill=tk.X)

Expand Down Expand Up @@ -66,6 +99,14 @@ def init_ui(self, root):
def update_open_hotel(self):
config.set("Settings", "open_hotel", str(self.open_hotel_var.get()))

def update_open_hotel_tonkiang(self):
config.set(
"Settings", "open_hotel_tonkiang", str(self.open_hotel_tonkiang_var.get())
)

def update_open_hotel_fofa(self):
config.set("Settings", "open_hotel_fofa", str(self.open_hotel_fofa_var.get()))

def update_region_list(self, event):
config.set(
"Settings",
Expand All @@ -79,6 +120,8 @@ def update_page_num(self, event):
def change_entry_state(self, state):
for entry in [
"open_hotel_checkbutton",
"open_hotel_tonkiang_checkbutton",
"open_hotel_fofa_checkbutton",
"region_list_combo",
"page_num_entry",
]:
Expand Down
2 changes: 1 addition & 1 deletion updates/fofa/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def get_fofa_urls_from_region_list():
"""
Get the FOFA url from region
"""
region_list = config.get("Settings", "fofa_region_list").split(",")
region_list = config.get("Settings", "hotel_region_list").split(",")
urls = []
region_url = getattr(fofa_map, "region_url")
if "all" in region_list:
Expand Down
16 changes: 8 additions & 8 deletions utils/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ def append_all_method_data(
data,
subscribe_result=None,
multicast_result=None,
hotel_result=None,
fofa_result=None,
hotel_tonkiang_result=None,
hotel_fofa_result=None,
online_search_result=None,
):
"""
Expand All @@ -488,8 +488,8 @@ def append_all_method_data(
for method, result in [
("subscribe", subscribe_result),
("multicast", multicast_result),
("hotel", hotel_result),
("fofa", fofa_result),
("hotel_tonkiang", hotel_tonkiang_result),
("hotel_fofa", hotel_fofa_result),
("online_search", online_search_result),
]:
if config.getboolean("Settings", f"open_{method}"):
Expand Down Expand Up @@ -527,8 +527,8 @@ def append_all_method_data_keep_all(
data,
subscribe_result=None,
multicast_result=None,
hotel_result=None,
fofa_result=None,
hotel_tonkiang_result=None,
hotel_fofa_result=None,
online_search_result=None,
):
"""
Expand All @@ -538,8 +538,8 @@ def append_all_method_data_keep_all(
for result_name, result in [
("subscribe", subscribe_result),
("multicast", multicast_result),
("hotel", hotel_result),
("fofa", fofa_result),
("hotel_tonkiang", hotel_tonkiang_result),
("hotel_fofa", hotel_fofa_result),
("online_search", online_search_result),
]:
if result and config.getboolean("Settings", f"open_{result_name}"):
Expand Down

0 comments on commit 5ad8834

Please sign in to comment.