Skip to content

Commit

Permalink
Merge pull request #367 from Guovin/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Guovin authored Oct 9, 2024
2 parents e4e7476 + 8cf901b commit 38b1b0a
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 25 deletions.
4 changes: 3 additions & 1 deletion config/config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ urls_limit = 30
open_keep_all = False
open_sort = True
open_ffmpeg = True
open_filter_resolution = True
min_resolution = 1920x1080
response_time_weight = 0.5
resolution_weight = 0.5
recent_days = 30
Expand All @@ -17,7 +19,7 @@ domain_blacklist = epg.pw,skype.serv00.net
open_m3u_result = True
url_keywords_blacklist =
open_subscribe = True
subscribe_urls = 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
subscribe_urls = 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
open_multicast = True
open_multicast_tonkiang = True
open_multicast_fofa = True
Expand Down
9 changes: 6 additions & 3 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,9 @@ async def main(self):
print(f"Update completed! Please check the {user_final_file} file!")
if self.run_ui:
tip = (
"服务启动成功, 可访问以下链接:"
"服务启动成功, 可使用以下链接观看直播:"
if config.getboolean("Settings", "open_update") == False
else f"更新完成, 请检查{user_final_file}文件, 可访问以下链接:"
else f"更新完成, 请检查{user_final_file}文件, 可使用以下链接观看直播:"
)
self.update_progress(
tip,
Expand Down Expand Up @@ -251,7 +251,10 @@ def scheduled_task():

def run_app():
if not os.environ.get("GITHUB_ACTIONS"):
print(f"You can access the result at {get_ip_address()}")
ip_address = get_ip_address()
print(f"You can use this url to watch the live stream: {ip_address}")
print(f"Result detail: {ip_address}/result")
print(f"Log detail: {ip_address}/log")
app.run(host="0.0.0.0", port=8000)


Expand Down
Binary file modified 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.
21 changes: 12 additions & 9 deletions utils/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -772,15 +772,18 @@ def get_channel_data_cache_with_compare(data, new_data):
"""
Get channel data with cache compare new data
"""

def match_url(url, sort_urls):
url = url.split("$", 1)[0]
return url in sort_urls

for cate, obj in new_data.items():
for name, url_info in obj.items():
if url_info and cate in data and name in data[cate]:
new_urls = {new_url for new_url, _, _ in url_info}
data[cate][name] = [
info for info in data[cate][name] if match_url(info[0], new_urls)
]
new_urls = {
new_url.split("$", 1)[0]: new_resolution
for new_url, _, new_resolution in url_info
}
updated_data = []
for info in data[cate][name]:
url, date, resolution = info
base_url = url.split("$", 1)[0]
if base_url in new_urls:
resolution = new_urls[base_url]
updated_data.append((url, date, resolution))
data[cate][name] = updated_data
13 changes: 2 additions & 11 deletions utils/speed.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
import re
from utils.config import config
from utils.tools import is_ipv6
from utils.tools import is_ipv6, get_resolution_value
import subprocess

timeout = 15
Expand Down Expand Up @@ -188,15 +188,6 @@ async def sort_urls_by_speed_and_resolution(
)
)
valid_response = [res for res in response if res != float("inf")]

def extract_resolution(resolution_str):
numbers = re.findall(r"\d+x\d+", resolution_str)
if numbers:
width, height = map(int, numbers[0].split("x"))
return width * height
else:
return 0

default_response_time_weight = 0.5
default_resolution_weight = 0.5
response_time_weight = (
Expand All @@ -217,7 +208,7 @@ def extract_resolution(resolution_str):

def combined_key(item):
(_, _, resolution), response_time = item
resolution_value = extract_resolution(resolution) if resolution else 0
resolution_value = get_resolution_value(resolution) if resolution else 0
return (
-(response_time_weight * response_time)
+ resolution_weight * resolution_value
Expand Down
22 changes: 21 additions & 1 deletion utils/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,31 @@ def get_soup(source):
return soup


def get_resolution_value(resolution_str):
"""
Get resolution value from string
"""
numbers = re.findall(r"\d+x\d+", resolution_str)
if numbers:
width, height = map(int, numbers[0].split("x"))
return width * height
else:
return 0


def get_total_urls_from_info_list(infoList):
"""
Get the total urls from info list
"""
total_urls = [url for url, _, _ in infoList]
open_filter_resolution = config.getboolean("Settings", "open_filter_resolution")
min_resolution = get_resolution_value(config.get("Settings", "min_resolution"))
total_urls = []
for url, _, resolution in infoList:
if open_filter_resolution and resolution:
resolution_value = get_resolution_value(resolution)
if resolution_value < min_resolution:
continue
total_urls.append(url)
return list(dict.fromkeys(total_urls))[: config.getint("Settings", "urls_limit")]


Expand Down

0 comments on commit 38b1b0a

Please sign in to comment.