Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dev update #477

Merged
merged 9 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@
- 接口源:

```bash
https://ghproxy.net/raw.githubusercontent.com/Guovin/TV/gd/output/result.m3u
https://ghproxy.net/raw.githubusercontent.com/Guovin/TV/gd/output/result.m3u
```

- 数据源:

```bash
https://ghproxy.net/raw.githubusercontent.com/Guovin/TV/gd/source.json
https://ghproxy.net/raw.githubusercontent.com/Guovin/TV/gd/source.json
```

## 配置
Expand Down
4 changes: 2 additions & 2 deletions README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@
- Interface source:

```bash
https://ghproxy.net/raw.githubusercontent.com/Guovin/TV/gd/output/result.m3u
https://ghproxy.net/raw.githubusercontent.com/Guovin/TV/gd/output/result.m3u
```

- Data source:

```bash
https://ghproxy.net/raw.githubusercontent.com/Guovin/TV/gd/source.json
https://ghproxy.net/raw.githubusercontent.com/Guovin/TV/gd/source.json
```

## Config
Expand Down
12 changes: 6 additions & 6 deletions config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ online_search_page_num = 3
urls_limit = 30
open_keep_all = False
open_sort = True
sort_timeout = 5
sort_timeout = 10
open_ffmpeg = True
open_filter_resolution = True
min_resolution = 1920x1080
Expand All @@ -20,26 +20,26 @@ ipv_type = 全部
ipv_type_prefer = 自动
ipv4_num = 15
ipv6_num = 15
domain_blacklist = epg.pw,skype.serv00.net,iptv.yjxfz.com,live-hls-web-ajb.getaj.net,live.goodiptv.club,hc73k3dhwo5gfkt.wcetv.com
domain_blacklist = epg.pw,skype.serv00.net,iptv.yjxfz.com,live-hls-web-ajb.getaj.net,live.goodiptv.club,hc73k3dhwo5gfkt.wcetv.com,stream1.freetv.fun
open_m3u_result = True
url_keywords_blacklist =
open_subscribe = True
subscribe_urls = http://175.178.251.183:6689/live.txt,http://102.134.54.106:3099/live/全国酒店源mini.txt,https://ghproxy.net/https://raw.githubusercontent.com/kimwang1978/collect-tv-txt/main/merged_output.txt,https://m3u.ibert.me/txt/fmml_dv6.txt,https://m3u.ibert.me/txt/o_cn.txt,https://m3u.ibert.me/txt/j_iptv.txt,https://github.moeyy.xyz/https://raw.githubusercontent.com/PizazzGY/TVBox/main/live.txt,https://ghproxy.net/https://raw.githubusercontent.com/xzw832/cmys/main/S_CCTV.txt,https://ghproxy.net/https://raw.githubusercontent.com/xzw832/cmys/main/S_weishi.txt
subscribe_urls = http://175.178.251.183:6689/live.txt,http://102.134.54.106:3099/live/全国酒店源mini.txt,https://ghproxy.net/https://raw.githubusercontent.com/kimwang1978/collect-tv-txt/main/merged_output.txt,https://m3u.ibert.me/txt/fmml_dv6.txt,https://m3u.ibert.me/txt/o_cn.txt,https://m3u.ibert.me/txt/j_iptv.txt,https://github.moeyy.xyz/https://raw.githubusercontent.com/PizazzGY/TVBox/main/live.txt,https://ghproxy.net/https://raw.githubusercontent.com/xzw832/cmys/main/S_CCTV.txt,https://ghproxy.net/https://raw.githubusercontent.com/xzw832/cmys/main/S_weishi.txt,http://itv.22m.top/ITVBox/tv/tvonline.txt
open_multicast = True
open_multicast_tonkiang = True
open_multicast_fofa = True
multicast_region_list = 全部
multicast_page_num = 3
multicast_page_num = 1
open_proxy = False
open_driver = True
open_hotel = True
open_hotel_tonkiang = False
open_hotel_fofa = True
hotel_region_list = 全部
hotel_page_num = 3
hotel_page_num = 1
open_update_time = True
request_timeout = 10
origin_type_prefer = hotel,multicast,subscribe,online_search
origin_type_prefer = subscribe,hotel,multicast,online_search
hotel_num = 10
multicast_num = 10
subscribe_num = 10
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ def pbar_update(self, name=""):
def get_urls_len(self, filter=False):
data = copy.deepcopy(self.channel_data)
if filter:
process_nested_dict(data, seen=set(), flag="$cache:")
process_nested_dict(data, seen=set(), flag=r"cache:(.*)")
processed_urls = set(
url_info[0]
for channel_obj in data.values()
Expand Down
4 changes: 2 additions & 2 deletions tkinter_ui/prefer.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def init_ui(self, root=None):
for item in config.get(
"Settings",
"origin_type_prefer",
fallback="hotel,multicast,subscribe,online_search",
fallback="subscribe,hotel,multicast,online_search",
).split(",")
]
config_options = [
Expand Down Expand Up @@ -161,7 +161,7 @@ def update_select(self, key):
for item in config.get(
"Settings",
"origin_type_prefer",
fallback="hotel,multicast,subscribe,online_search",
fallback="subscribe,hotel,multicast,online_search",
).split(",")
]
origin_type_prefer_list[self.combo_box_value] = self.origin_type_prefer_obj[
Expand Down
Binary file removed updates/fofa/fofa_hotel_region_result.pkl
Binary file not shown.
Binary file modified updates/fofa/fofa_multicast_region_result.pkl
Binary file not shown.
48 changes: 31 additions & 17 deletions updates/fofa/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import re
from utils.retry import retry_func
from utils.channel import format_channel_name
from utils.tools import merge_objects, get_pbar_remaining
from utils.tools import merge_objects, get_pbar_remaining, add_url_info
from updates.proxy import get_proxy, get_proxy_next
from requests_custom.utils import get_source_requests, close_session
from collections import defaultdict
Expand All @@ -32,11 +32,16 @@ def get_fofa_urls_from_region_list():
urls = []
region_url = getattr(fofa_map, "region_url")
if "all" in region_list or "ALL" in region_list or "全部" in region_list:
urls = [url for url_list in region_url.values() for url in url_list if url]
urls = [
(url, region)
for region, url_list in region_url.items()
for url in url_list
if url
]
else:
for region in region_list:
if region in region_url:
urls.append(region_url[region])
urls.extend([(url, region) for url in region_url[region] if url])
return urls


Expand All @@ -56,14 +61,16 @@ def update_fofa_region_result_tmp(result, multicast=False):


def get_fofa_region_result_tmp(multicast: False):
with open(
resource_path(
f"updates/fofa/fofa_{'multicast' if multicast else 'hotel'}_region_result.pkl"
),
"rb",
) as file:
result = pickle.load(file)
return result
try:
with open(
resource_path(
f"updates/fofa/fofa_{'multicast' if multicast else 'hotel'}_region_result.pkl"
),
"rb",
) as file:
return pickle.load(file)
except:
return {}


async def get_channels_by_fofa(urls=None, multicast=False, callback=None):
Expand All @@ -89,15 +96,15 @@ async def get_channels_by_fofa(urls=None, multicast=False, callback=None):
open_driver = config.getboolean("Settings", "open_driver", fallback=True)
open_sort = config.getboolean("Settings", "open_sort", fallback=True)
if open_proxy:
test_url = fofa_urls[0][0] if multicast else fofa_urls[0]
test_url = fofa_urls[0][0]
proxy = await get_proxy(test_url, best=True, with_test=True)
cancel_event = threading.Event()

def process_fofa_channels(fofa_info):
nonlocal proxy, fofa_urls_len, open_driver, open_sort, cancel_event
if cancel_event.is_set():
return {}
fofa_url = fofa_info[0] if multicast else fofa_info
fofa_url = fofa_info[0]
results = defaultdict(lambda: defaultdict(list))
driver = None
try:
Expand Down Expand Up @@ -130,7 +137,9 @@ def process_fofa_channels(fofa_info):
else:
with ThreadPoolExecutor(max_workers=100) as executor:
futures = [
executor.submit(process_fofa_json_url, url, open_sort)
executor.submit(
process_fofa_json_url, url, fofa_info[1], open_sort
)
for url in urls
]
for future in futures:
Expand Down Expand Up @@ -183,7 +192,7 @@ def process_fofa_channels(fofa_info):
return fofa_results


def process_fofa_json_url(url, open_sort):
def process_fofa_json_url(url, region, open_sort):
"""
Process the FOFA json url
"""
Expand All @@ -205,9 +214,14 @@ def process_fofa_json_url(url, open_sort):
item_url = item.get("url").strip()
if item_name and item_url:
total_url = (
f"{url}{item_url}$cache:{url}"
add_url_info(
f"{url}{item_url}",
f"{region}酒店源|cache:{url}",
)
if open_sort
else f"{url}{item_url}"
else add_url_info(
f"{url}{item_url}", f"{region}酒店源"
)
)
if item_name not in channels:
channels[item_name] = [(total_url, None, None)]
Expand Down
23 changes: 9 additions & 14 deletions updates/hotel/request.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from asyncio import create_task, gather
from utils.speed import get_speed
from utils.channel import (
get_results_from_multicast_soup,
get_results_from_multicast_soup_requests,
Expand Down Expand Up @@ -43,8 +41,7 @@ async def get_channels_by_hotel(callback=None):
if region.strip()
]
if "all" in region_list or "ALL" in region_list or "全部" in region_list:
fofa_region_name_list = list(getattr(fofa_map, "region_url").keys())
region_list = fofa_region_name_list
region_list = list(getattr(fofa_map, "region_url").keys())
if open_proxy:
proxy = await get_proxy(pageUrl, best=True, with_test=True)
start_time = time()
Expand Down Expand Up @@ -85,7 +82,7 @@ def process_region_by_hotel(region):
page_soup = get_soup_requests(pageUrl, data=post_form, proxy=proxy)
if not page_soup:
print(f"{name}:Request fail.")
return {"region": region, "type": type, "data": info_list}
return info_list
else:
a_tags = page_soup.find_all("a", href=True)
for a_tag in a_tags:
Expand Down Expand Up @@ -115,7 +112,7 @@ def process_region_by_hotel(region):
driver.execute_script("arguments[0].click();", page_link)
else:
request_url = (
f"{pageUrl}?net={name}&page={page}&code={code}"
f"{pageUrl}?isp={name}&page={page}&code={code}"
)
page_soup = retry_func(
lambda: get_soup_requests(request_url, proxy=proxy),
Expand Down Expand Up @@ -156,7 +153,7 @@ def process_region_by_hotel(region):
f"正在获取Tonkiang酒店源, 剩余{region_list_len - pbar.n}个地区待查询, 预计剩余时间: {get_pbar_remaining(n=pbar.n, total=pbar.total, start_time=start_time)}",
int((pbar.n / region_list_len) * 100),
)
return {"region": region, "type": type, "data": info_list}
return info_list

region_list_len = len(region_list)
pbar = tqdm_asyncio(total=region_list_len, desc="Tonkiang hotel search")
Expand All @@ -172,22 +169,20 @@ def process_region_by_hotel(region):
for future in as_completed(futures):
region = futures[future]
result = future.result()
data = result.get("data")

if data:
for item in data:
if result:
for item in result:
url = item.get("url")
date = item.get("date")
if url:
search_region_result[region].append((url, date, None))
urls = [
f"http://{url}/ZHGXTV/Public/json/live_interface.txt"
for result in search_region_result.values()
{region: region, url: f"http://{url}/ZHGXTV/Public/json/live_interface.txt"}
for region, result in search_region_result.items()
for url, _, _ in result
]
open_sort = config.getboolean("Settings", "open_sort", fallback=True)
channels = await get_channels_by_subscribe_urls(
urls, hotel=True, retry=False, error_print=False, with_cache=open_sort
urls, hotel=True, retry=False, error_print=False
)
if not open_driver:
close_session()
Expand Down
2 changes: 1 addition & 1 deletion updates/multicast/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def process_channel_by_multicast(region, type):
driver.execute_script("arguments[0].click();", page_link)
else:
request_url = (
f"{pageUrl}?net={name}&page={page}&code={code}"
f"{pageUrl}?isp={name}&page={page}&code={code}"
)
page_soup = retry_func(
lambda: get_soup_requests(request_url, proxy=proxy),
Expand Down
21 changes: 16 additions & 5 deletions updates/subscribe/request.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
from requests import Session, exceptions
from utils.retry import retry_func
from utils.channel import get_name_url, format_channel_name
from utils.tools import merge_objects, get_pbar_remaining, format_url_with_cache
from utils.tools import (
merge_objects,
get_pbar_remaining,
format_url_with_cache,
add_url_info,
)
from concurrent.futures import ThreadPoolExecutor
from collections import defaultdict

Expand All @@ -17,7 +22,6 @@ async def get_channels_by_subscribe_urls(
hotel=False,
retry=True,
error_print=True,
with_cache=False,
callback=None,
):
"""
Expand All @@ -44,9 +48,9 @@ async def get_channels_by_subscribe_urls(
session = Session()

def process_subscribe_channels(subscribe_info):
if multicast and isinstance(subscribe_info, dict):
if (multicast or hotel) and isinstance(subscribe_info, dict):
region = subscribe_info.get("region")
type = subscribe_info.get("type")
type = subscribe_info.get("type", "")
subscribe_url = subscribe_info.get("url")
else:
subscribe_url = subscribe_info
Expand All @@ -72,8 +76,15 @@ def process_subscribe_channels(subscribe_info):
name = item["name"]
url = item["url"]
if name and url:
if not multicast:
info = (
f"{region}酒店源"
if hotel
else "组播源" if "/rtp/" in url else "订阅源"
)
url = add_url_info(url, info)
url = format_url_with_cache(
url, cache=subscribe_url if with_cache else None
url, cache=subscribe_url if (multicast or hotel) else None
)
value = url if multicast else (url, None, None)
name = format_channel_name(name)
Expand Down
Loading
Loading