diff --git a/README.md b/README.md index 319d924313..be24cbf113 100644 --- a/README.md +++ b/README.md @@ -142,55 +142,55 @@ https://cdn.jsdelivr.net/gh/Guovin/iptv-api@gd/source.json ## 配置 -| 配置项 | 描述 | 默认值 | -|:-----------------------|:------------------------------------------------------------------------------------------|:----------------------------------------| -| open_driver | 开启浏览器运行,若更新无数据可开启此模式,较消耗性能 | False | -| open_empty_category | 开启无结果频道分类,自动归类至底部 | False | -| open_filter_resolution | 开启分辨率过滤,低于最小分辨率(min_resolution)的接口将会被过滤 | True | -| open_filter_speed | 开启速率过滤,低于最小速率(min_speed)的接口将会被过滤 | True | -| open_hotel | 开启酒店源功能,关闭后所有酒店源工作模式都将关闭 | True | -| open_hotel_foodie | 开启 Foodie 酒店源工作模式 | True | -| open_hotel_fofa | 开启 FOFA、ZoomEye 酒店源工作模式 | True | -| open_keep_all | 开启保留所有检索结果,会保留非模板频道名称的结果,推荐手动维护时开启 | False | -| open_m3u_result | 开启转换生成 m3u 文件类型结果链接,支持显示频道图标 | True | -| open_multicast | 开启组播源功能,关闭后所有组播源工作模式都将关闭 | True | -| open_multicast_foodie | 开启 Foodie 组播源工作模式 | True | -| open_multicast_fofa | 开启 FOFA 组播源工作模式 | True | -| open_online_search | 开启关键字搜索源功能 | False | -| open_proxy | 开启代理,自动获取免费可用代理,若更新无数据可开启此模式 | False | -| open_request | 开启查询请求,数据来源于网络(仅针对酒店源与组播源) | False | -| open_service | 开启页面服务,用于控制是否启动结果页面服务;如果使用青龙等平台部署,有专门设定的定时任务,需要更新完成后停止运行,可以关闭该功能 | True | -| open_sort | 开启排序功能(响应速度、日期、分辨率) | True | -| open_subscribe | 开启订阅源功能 | False | -| open_update | 开启更新,用于控制是否更新接口,若关闭则所有工作模式(获取接口和测速)均停止 | True | -| open_update_time | 开启显示更新时间 | True | -| open_url_info | 开启显示接口说明信息,用于控制是否显示分辨率、接口协议类型等信息,为$符号后的内容,播放软件使用该信息对接口进行描述 | True | -| open_use_cache | 开启使用本地缓存数据,适用于查询请求失败场景(仅针对酒店源与组播源) | True | -| open_use_old_result | 开启使用历史更新结果(包含模板与结果文件的接口),合并至本次更新中 | True | -| app_port | 页面服务端口,用于控制页面服务的端口号 | 8000 | -| final_file | 生成结果文件路径 | output/result.txt | -| hotel_num | 结果中偏好的酒店源接口数量 | 4 | -| hotel_page_num | 酒店地区获取分页数量 | 1 | -| hotel_region_list | 酒店源地区列表,"全部"表示所有地区 | 全部 | -| ipv4_num | 结果中偏好的 IPv4 接口数量 | 5 | -| ipv6_num | 结果中偏好的 IPv6 接口数量 | 5 | -| ipv6_support | 强制认为当前网络支持IPv6,跳过检测 | False | -| ipv_type | 生成结果中接口的协议类型,可选值:ipv4、ipv6、全部、all | 全部 | -| ipv_type_prefer | 接口协议类型偏好,优先将该类型的接口排在结果前面,可选值:IPv4、IPv6、自动、auto | 自动 | -| min_resolution | 接口最小分辨率,需要开启 open_filter_resolution 才能生效 | 1920x1080 | -| min_speed | 接口最小速率(单位M/s),需要开启 open_filter_speed 才能生效 | 0.2 | -| multicast_num | 结果中偏好的组播源接口数量 | 3 | -| multicast_page_num | 组播地区获取分页数量 | 1 | -| multicast_region_list | 组播源地区列表,"全部"表示所有地区 | 全部 | -| online_search_num | 结果中偏好的关键字搜索接口数量 | 0 | -| online_search_page_num | 关键字搜索频道获取分页数量 | 1 | -| origin_type_prefer | 结果偏好的接口来源,结果优先按该顺序进行排序,hotel:酒店源,multicast:组播源,subscribe:订阅源,online_search:关键字搜索 | hotel,multicast,subscribe,online_search | -| recent_days | 获取最近时间范围内更新的接口(单位天),适当减小可避免出现匹配问题 | 30 | -| request_timeout | 查询请求超时时长,单位秒(s),用于控制查询接口文本链接的超时时长以及重试时长,调整此值能优化更新时间 | 10 | -| sort_timeout | 单个接口测速超时时长,单位秒(s);数值越大测速所属时间越长,能提高获取接口数量,但质量会有所下降;数值越小测速所需时间越短,能获取低延时的接口,质量较好;调整此值能优化更新时间 | 10 | -| source_file | 模板文件路径 | config/demo.txt | -| subscribe_num | 结果中偏好的订阅源接口数量 | 3 | -| urls_limit | 单个频道接口数量 | 10 | +| 配置项 | 描述 | 默认值 | +|:-----------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------| +| open_driver | 开启浏览器运行,若更新无数据可开启此模式,较消耗性能 | False | +| open_empty_category | 开启无结果频道分类,自动归类至底部 | False | +| open_filter_resolution | 开启分辨率过滤,低于最小分辨率(min_resolution)的接口将会被过滤 | True | +| open_filter_speed | 开启速率过滤,低于最小速率(min_speed)的接口将会被过滤 | True | +| open_hotel | 开启酒店源功能,关闭后所有酒店源工作模式都将关闭 | True | +| open_hotel_foodie | 开启 Foodie 酒店源工作模式 | True | +| open_hotel_fofa | 开启 FOFA、ZoomEye 酒店源工作模式 | True | +| open_keep_all | 开启保留所有检索结果,会保留非模板频道名称的结果,推荐手动维护时开启 | False | +| open_m3u_result | 开启转换生成 m3u 文件类型结果链接,支持显示频道图标 | True | +| open_multicast | 开启组播源功能,关闭后所有组播源工作模式都将关闭 | True | +| open_multicast_foodie | 开启 Foodie 组播源工作模式 | True | +| open_multicast_fofa | 开启 FOFA 组播源工作模式 | True | +| open_online_search | 开启关键字搜索源功能 | False | +| open_proxy | 开启代理,自动获取免费可用代理,若更新无数据可开启此模式 | False | +| open_request | 开启查询请求,数据来源于网络(仅针对酒店源与组播源) | False | +| open_service | 开启页面服务,用于控制是否启动结果页面服务;如果使用青龙等平台部署,有专门设定的定时任务,需要更新完成后停止运行,可以关闭该功能 | True | +| open_sort | 开启排序功能(响应速度、日期、分辨率) | True | +| open_subscribe | 开启订阅源功能 | False | +| open_update | 开启更新,用于控制是否更新接口,若关闭则所有工作模式(获取接口和测速)均停止 | True | +| open_update_time | 开启显示更新时间 | True | +| open_url_info | 开启显示接口说明信息,用于控制是否显示分辨率、接口协议类型等信息,为$符号后的内容,播放软件使用该信息对接口进行描述 | True | +| open_use_cache | 开启使用本地缓存数据,适用于查询请求失败场景(仅针对酒店源与组播源) | True | +| open_use_old_result | 开启使用历史更新结果(包含模板与结果文件的接口),合并至本次更新中 | True | +| app_port | 页面服务端口,用于控制页面服务的端口号 | 8000 | +| final_file | 生成结果文件路径 | output/result.txt | +| hotel_num | 结果中偏好的酒店源接口数量 | 10 | +| hotel_page_num | 酒店地区获取分页数量 | 1 | +| hotel_region_list | 酒店源地区列表,"全部"表示所有地区 | 全部 | +| ipv4_num | 结果中偏好的 IPv4 接口数量 | 5 | +| ipv6_num | 结果中偏好的 IPv6 接口数量 | 5 | +| ipv6_support | 强制认为当前网络支持IPv6,跳过检测 | False | +| ipv_type | 生成结果中接口的协议类型,可选值:ipv4、ipv6、全部、all | 全部 | +| ipv_type_prefer | 接口协议类型偏好,优先将该类型的接口排在结果前面,可选值:IPv4、IPv6、自动、auto | 自动 | +| min_resolution | 接口最小分辨率,需要开启 open_filter_resolution 才能生效 | 1920x1080 | +| min_speed | 接口最小速率(单位M/s),需要开启 open_filter_speed 才能生效 | 0.2 | +| multicast_num | 结果中偏好的组播源接口数量 | 10 | +| multicast_page_num | 组播地区获取分页数量 | 1 | +| multicast_region_list | 组播源地区列表,"全部"表示所有地区 | 全部 | +| online_search_num | 结果中偏好的关键字搜索接口数量 | 0 | +| online_search_page_num | 关键字搜索频道获取分页数量 | 1 | +| origin_type_prefer | 结果偏好的接口来源,结果优先按该顺序进行排序,逗号分隔,例如:hotel,multicast,subscribe,online_search;hotel:酒店源,multicast:组播源,subscribe:订阅源,online_search:关键字搜索;不填写则表示不指定来源,按照接口速率排序 | | +| recent_days | 获取最近时间范围内更新的接口(单位天),适当减小可避免出现匹配问题 | 30 | +| request_timeout | 查询请求超时时长,单位秒(s),用于控制查询接口文本链接的超时时长以及重试时长,调整此值能优化更新时间 | 10 | +| sort_timeout | 单个接口测速超时时长,单位秒(s);数值越大测速所属时间越长,能提高获取接口数量,但质量会有所下降;数值越小测速所需时间越短,能获取低延时的接口,质量较好;调整此值能优化更新时间 | 10 | +| source_file | 模板文件路径 | config/demo.txt | +| subscribe_num | 结果中偏好的订阅源接口数量 | 10 | +| urls_limit | 单个频道接口数量 | 10 | ## 快速上手 diff --git a/README_en.md b/README_en.md index d48585addd..a02611f995 100644 --- a/README_en.md +++ b/README_en.md @@ -142,55 +142,55 @@ https://cdn.jsdelivr.net/gh/Guovin/iptv-api@gd/source.json ## Config -| Configuration Item | Description | Default Value | -|:-----------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------| -| open_driver | Enable browser execution, If there are no updates, this mode can be enabled, which consumes more performance | False | -| open_empty_category | Enable the No Results Channel Category, which will automatically categorize channels without results to the bottom | False | -| open_filter_resolution | Enable resolution filtering, interfaces with resolution lower than the minimum resolution (min_resolution) will be filtered | True | -| open_filter_speed | Enable speed filtering, interfaces with speed lower than the minimum speed (min_speed) will be filtered | True | -| open_hotel | Enable the hotel source function, after closing it all hotel source working modes will be disabled | True | -| open_hotel_foodie | Enable Foodie hotel source work mode | True | -| open_hotel_fofa | Enable FOFA、ZoomEye hotel source work mode | True | -| open_keep_all | Enable retain all search results, retain results with non-template channel names, recommended to be turned on when manually maintaining | False | -| open_m3u_result | Enable the conversion to generate m3u file type result links, supporting the display of channel icons | True | -| open_multicast | Enable the multicast source function, after disabling it all multicast sources will stop working | True | -| open_multicast_foodie | Enable Foodie multicast source work mode | True | -| open_multicast_fofa | Enable FOFA multicast source work mode | True | -| open_online_search | Enable keyword search source feature | False | -| open_proxy | Enable proxy, automatically obtains free available proxies, If there are no updates, this mode can be enabled | False | -| open_request | Enable query request, the data is obtained from the network (only for hotel sources and multicast sources) | False | -| open_service | Enable page service, used to control whether to start the result page service; if deployed on platforms like Qinglong with dedicated scheduled tasks, the function can be turned off after updates are completed and the task is stopped | True | -| open_sort | Enable the sorting function (response speed, date, resolution) | True | -| open_subscribe | Enable subscription source feature | True | -| open_update | Enable updates, if disabled then only the result page service is run | True | -| open_update_time | Enable show update time | True | -| open_url_info | Enable display of API description information, used to control whether to show resolution, API protocol type, etc., the content after the $ symbol, playback software uses this information to describe the API | True | -| open_use_cache | Enable the use of local cache data, applicable to the query request failure scenario (only for hotel sources and multicast sources) | True | -| open_use_old_result | Enable the use of historical update results (including the interface for template and result files) and merge them into the current update | True | -| app_port | Page service port, used to control the port number of the page service | 8000 | -| final_file | Generated result file path | output/result.txt | -| hotel_num | The number of preferred hotel source interfaces in the results | 4 | -| hotel_page_num | Number of pages to retrieve for hotel regions | 1 | -| hotel_region_list | List of hotel source regions, 'all' indicates all regions | all | -| ipv4_num | The preferred number of IPv4 interfaces in the result | 5 | -| ipv6_num | The preferred number of IPv6 interfaces in the result | 5 | -| ipv6_support | It is forced to consider that the current network supports IPv6 and skip the check | False | -| ipv_type | The protocol type of interface in the generated result, optional values: ipv4, ipv6, all | all | -| ipv_type_prefer | Interface protocol type preference, prioritize interfaces of this type in the results, optional values: IPv4, IPv6, auto | auto | -| min_resolution | Minimum interface resolution, requires enabling open_filter_resolution to take effect | 1920x1080 | -| min_speed | Minimum interface speed (M/s), requires enabling open_filter_speed to take effect | 0.2 | -| multicast_num | The number of preferred multicast source interfaces in the results | 3 | -| multicast_page_num | Number of pages to retrieve for multicast regions | 1 | -| multicast_region_list | Multicast source region list, 'all' indicates all regions | all | -| online_search_num | The number of preferred keyword search interfaces in the results | 0 | -| online_search_page_num | Page retrieval quantity for keyword search channels | 1 | -| origin_type_prefer | Result preference for the source of the interface, results are prioritized in this order: hotel: hotel source, multicast: multicast source, subscribe: subscription source, online_search: keyword search | hotel, multicast, subscribe, online_search | -| recent_days | Retrieve interfaces updated within a recent time range (in days), reducing appropriately can avoid matching issues | 30 | -| request_timeout | Query request timeout duration, in seconds (s), used to control the timeout and retry duration for querying interface text links. Adjusting this value can optimize update time. | 10 | -| sort_timeout | The timeout duration for speed testing of a single interface, in seconds (s). A larger value means a longer testing period, which can increase the number of interfaces obtained but may decrease their quality. A smaller value means a shorter testing time, which can obtain low-latency interfaces with better quality. Adjusting this value can optimize the update time. | 10 | -| source_file | Template file path | config/demo.txt | -| subscribe_num | The number of preferred subscribe source interfaces in the results | 3 | -| urls_limit | Number of interfaces per channel | 10 | +| Configuration Item | Description | Default Value | +|:-----------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------| +| open_driver | Enable browser execution, If there are no updates, this mode can be enabled, which consumes more performance | False | +| open_empty_category | Enable the No Results Channel Category, which will automatically categorize channels without results to the bottom | False | +| open_filter_resolution | Enable resolution filtering, interfaces with resolution lower than the minimum resolution (min_resolution) will be filtered | True | +| open_filter_speed | Enable speed filtering, interfaces with speed lower than the minimum speed (min_speed) will be filtered | True | +| open_hotel | Enable the hotel source function, after closing it all hotel source working modes will be disabled | True | +| open_hotel_foodie | Enable Foodie hotel source work mode | True | +| open_hotel_fofa | Enable FOFA、ZoomEye hotel source work mode | True | +| open_keep_all | Enable retain all search results, retain results with non-template channel names, recommended to be turned on when manually maintaining | False | +| open_m3u_result | Enable the conversion to generate m3u file type result links, supporting the display of channel icons | True | +| open_multicast | Enable the multicast source function, after disabling it all multicast sources will stop working | True | +| open_multicast_foodie | Enable Foodie multicast source work mode | True | +| open_multicast_fofa | Enable FOFA multicast source work mode | True | +| open_online_search | Enable keyword search source feature | False | +| open_proxy | Enable proxy, automatically obtains free available proxies, If there are no updates, this mode can be enabled | False | +| open_request | Enable query request, the data is obtained from the network (only for hotel sources and multicast sources) | False | +| open_service | Enable page service, used to control whether to start the result page service; if deployed on platforms like Qinglong with dedicated scheduled tasks, the function can be turned off after updates are completed and the task is stopped | True | +| open_sort | Enable the sorting function (response speed, date, resolution) | True | +| open_subscribe | Enable subscription source feature | True | +| open_update | Enable updates, if disabled then only the result page service is run | True | +| open_update_time | Enable show update time | True | +| open_url_info | Enable display of API description information, used to control whether to show resolution, API protocol type, etc., the content after the $ symbol, playback software uses this information to describe the API | True | +| open_use_cache | Enable the use of local cache data, applicable to the query request failure scenario (only for hotel sources and multicast sources) | True | +| open_use_old_result | Enable the use of historical update results (including the interface for template and result files) and merge them into the current update | True | +| app_port | Page service port, used to control the port number of the page service | 8000 | +| final_file | Generated result file path | output/result.txt | +| hotel_num | The number of preferred hotel source interfaces in the results | 10 | +| hotel_page_num | Number of pages to retrieve for hotel regions | 1 | +| hotel_region_list | List of hotel source regions, 'all' indicates all regions | all | +| ipv4_num | The preferred number of IPv4 interfaces in the result | 5 | +| ipv6_num | The preferred number of IPv6 interfaces in the result | 5 | +| ipv6_support | It is forced to consider that the current network supports IPv6 and skip the check | False | +| ipv_type | The protocol type of interface in the generated result, optional values: ipv4, ipv6, all | all | +| ipv_type_prefer | Interface protocol type preference, prioritize interfaces of this type in the results, optional values: IPv4, IPv6, auto | auto | +| min_resolution | Minimum interface resolution, requires enabling open_filter_resolution to take effect | 1920x1080 | +| min_speed | Minimum interface speed (M/s), requires enabling open_filter_speed to take effect | 0.2 | +| multicast_num | The number of preferred multicast source interfaces in the results | 10 | +| multicast_page_num | Number of pages to retrieve for multicast regions | 1 | +| multicast_region_list | Multicast source region list, 'all' indicates all regions | all | +| online_search_num | The number of preferred keyword search interfaces in the results | 0 | +| online_search_page_num | Page retrieval quantity for keyword search channels | 1 | +| origin_type_prefer | Preferred interface source of the result, the result is sorted according to this order, separated by commas, for example: hotel, multicast, subscribe, online_search; hotel: hotel source, multicast: multicast source, subscribe: subscription source, online_search: keyword search; If not filled in, it means that the source is not specified, and it is sorted according to the interface rate | | +| recent_days | Retrieve interfaces updated within a recent time range (in days), reducing appropriately can avoid matching issues | 30 | +| request_timeout | Query request timeout duration, in seconds (s), used to control the timeout and retry duration for querying interface text links. Adjusting this value can optimize update time. | 10 | +| sort_timeout | The timeout duration for speed testing of a single interface, in seconds (s). A larger value means a longer testing period, which can increase the number of interfaces obtained but may decrease their quality. A smaller value means a shorter testing time, which can obtain low-latency interfaces with better quality. Adjusting this value can optimize the update time. | 10 | +| source_file | Template file path | config/demo.txt | +| subscribe_num | The number of preferred subscribe source interfaces in the results | 10 | +| urls_limit | Number of interfaces per channel | 10 | ## Quick Start diff --git a/config/config.ini b/config/config.ini index 57a7989b4a..567f3fe25f 100644 --- a/config/config.ini +++ b/config/config.ini @@ -50,7 +50,7 @@ app_port = 8000 # 生成结果文件路径; 默认值: output/result.txt | Generate result file path; Default value: output/result.txt final_file = output/result.txt # 结果中偏好的酒店源接口数量 | Preferred number of hotel source interfaces in the result -hotel_num = 4 +hotel_num = 10 # 酒店地区获取分页数量 | Number of hotel region acquisition pages hotel_page_num = 1 # 酒店源地区列表,"全部"表示所有地区 | Hotel source region list, "all" means all regions @@ -70,7 +70,7 @@ min_resolution = 1920x1080 # 接口最小速率(单位M/s),需要开启 open_filter_speed 才能生效 | Minimum rate of the interface (unit M/s), need to enable open_filter_speed to take effect min_speed = 0.2 # 结果中偏好的组播源接口数量 | Preferred number of multicast source interfaces in the result -multicast_num = 3 +multicast_num = 10 # 组播地区获取分页数量 | Number of multicast region acquisition pages multicast_page_num = 1 # 组播源地区列表,"全部"表示所有地区 | Multicast source region list, "all" means all regions @@ -79,8 +79,8 @@ multicast_region_list = 全部 online_search_num = 0 # 关键字搜索频道获取分页数量 | Number of keyword search channel acquisition pages online_search_page_num = 1 -# 结果偏好的接口来源,结果优先按该顺序进行排序,hotel:酒店源,multicast:组播源,subscribe:订阅源,online_search:关键字搜索 | Preferred interface source of the result, the result is sorted in this order, hotel: hotel source, multicast: multicast source, subscribe: subscription source, online_search: keyword search -origin_type_prefer = hotel,multicast,subscribe,online_search +# 结果偏好的接口来源,结果优先按该顺序进行排序,逗号分隔,例如:hotel,multicast,subscribe,online_search;hotel:酒店源,multicast:组播源,subscribe:订阅源,online_search:关键字搜索;不填写则表示不指定来源,按照接口速率排序 | Preferred interface source of the result, the result is sorted according to this order, separated by commas, for example: hotel, multicast, subscribe, online_search; hotel: hotel source, multicast: multicast source, subscribe: subscription source, online_search: keyword search; If not filled in, it means that the source is not specified, and it is sorted according to the interface rate +origin_type_prefer = # 获取最近时间范围内更新的接口(单位天),适当减小可避免出现匹配问题 | Get the interface updated within the recent time range (unit day), appropriately reducing can avoid matching problems recent_days = 30 # 查询请求超时时长,单位秒(s),用于控制查询接口文本链接的超时时长以及重试时长,调整此值能优化更新时间 | Query request timeout duration, unit seconds (s), used to control the timeout duration and retry duration of querying the interface text link, adjusting this value can optimize the update time @@ -90,6 +90,6 @@ sort_timeout = 10 # 模板文件路径, 默认值: config/demo.txt | Template file path, Default value: config/demo.txt source_file = config/demo.txt # 结果中偏好的订阅源接口数量 | Preferred number of subscription source interfaces in the result -subscribe_num = 3 +subscribe_num = 10 # 单个频道接口数量 | Number of interfaces per channel urls_limit = 10 \ No newline at end of file diff --git a/config/subscribe.txt b/config/subscribe.txt index 755b6da565..055212cbab 100644 --- a/config/subscribe.txt +++ b/config/subscribe.txt @@ -1,18 +1,18 @@ # 这是订阅源列表,每行一个订阅地址 # This is a list of subscription sources, with one subscription address per line https://iptv.b2og.com/txt/fmml_ipv6.txt -https://cdn.jsdelivr.net/gh/suxuang/myIPTV@main/ipv6.m3u +https://ghgo.xyz/raw.githubusercontent.com/suxuang/myIPTV/main/ipv6.m3u https://live.zbds.top/tv/iptv6.txt https://live.zbds.top/tv/iptv4.txt https://live.fanmingming.com/tv/m3u/ipv6.m3u -https://cdn.jsdelivr.net/gh/joevess/IPTV@main/home.m3u8 +https://ghgo.xyz/raw.githubusercontent.com/joevess/IPTV/main/home.m3u8 https://aktv.top/live.txt http://175.178.251.183:6689/live.txt -https://cdn.jsdelivr.net/gh/kimwang1978/collect-tv-txt@main/merged_output.txt +https://ghgo.xyz/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://cdn.jsdelivr.net/gh/xzw832/cmys@main/S_CCTV.txt -https://cdn.jsdelivr.net/gh/xzw832/cmys@main/S_weishi.txt -https://cdn.jsdelivr.net/gh/asdjkl6/tv@tv/.m3u/整套直播源/测试/整套直播源/l.txt -https://cdn.jsdelivr.net/gh/asdjkl6/tv@tv/.m3u/整套直播源/测试/整套直播源/kk.txt +https://ghgo.xyz/raw.githubusercontent.com/xzw832/cmys/main/S_CCTV.txt +https://ghgo.xyz/raw.githubusercontent.com/xzw832/cmys/main/S_weishi.txt +https://ghgo.xyz/raw.githubusercontent.com/asdjkl6/tv/tv/.m3u/整套直播源/测试/整套直播源/l.txt +https://ghgo.xyz/raw.githubusercontent.com/asdjkl6/tv/tv/.m3u/整套直播源/测试/整套直播源/kk.txt diff --git a/docs/config.md b/docs/config.md index 56faa46b28..e732873745 100644 --- a/docs/config.md +++ b/docs/config.md @@ -1,49 +1,49 @@ -| 配置项 | 描述 | 默认值 | -|:-----------------------|:------------------------------------------------------------------------------------------|:----------------------------------------| -| open_driver | 开启浏览器运行,若更新无数据可开启此模式,较消耗性能 | False | -| open_empty_category | 开启无结果频道分类,自动归类至底部 | False | -| open_filter_resolution | 开启分辨率过滤,低于最小分辨率(min_resolution)的接口将会被过滤 | True | -| open_filter_speed | 开启速率过滤,低于最小速率(min_speed)的接口将会被过滤 | True | -| open_hotel | 开启酒店源功能,关闭后所有酒店源工作模式都将关闭 | True | -| open_hotel_foodie | 开启 Foodie 酒店源工作模式 | True | -| open_hotel_fofa | 开启 FOFA、ZoomEye 酒店源工作模式 | True | -| open_keep_all | 开启保留所有检索结果,会保留非模板频道名称的结果,推荐手动维护时开启 | False | -| open_m3u_result | 开启转换生成 m3u 文件类型结果链接,支持显示频道图标 | True | -| open_multicast | 开启组播源功能,关闭后所有组播源工作模式都将关闭 | True | -| open_multicast_foodie | 开启 Foodie 组播源工作模式 | True | -| open_multicast_fofa | 开启 FOFA 组播源工作模式 | True | -| open_online_search | 开启关键字搜索源功能 | False | -| open_proxy | 开启代理,自动获取免费可用代理,若更新无数据可开启此模式 | False | -| open_request | 开启查询请求,数据来源于网络(仅针对酒店源与组播源) | False | -| open_service | 开启页面服务,用于控制是否启动结果页面服务;如果使用青龙等平台部署,有专门设定的定时任务,需要更新完成后停止运行,可以关闭该功能 | True | -| open_sort | 开启排序功能(响应速度、日期、分辨率) | True | -| open_subscribe | 开启订阅源功能 | False | -| open_update | 开启更新,用于控制是否更新接口,若关闭则所有工作模式(获取接口和测速)均停止 | True | -| open_update_time | 开启显示更新时间 | True | -| open_url_info | 开启显示接口说明信息,用于控制是否显示分辨率、接口协议类型等信息,为$符号后的内容,播放软件使用该信息对接口进行描述 | True | -| open_use_cache | 开启使用本地缓存数据,适用于查询请求失败场景(仅针对酒店源与组播源) | True | -| open_use_old_result | 开启使用历史更新结果(包含模板与结果文件的接口),合并至本次更新中 | True | -| app_port | 页面服务端口,用于控制页面服务的端口号 | 8000 | -| final_file | 生成结果文件路径 | output/result.txt | -| hotel_num | 结果中偏好的酒店源接口数量 | 4 | -| hotel_page_num | 酒店地区获取分页数量 | 1 | -| hotel_region_list | 酒店源地区列表,"全部"表示所有地区 | 全部 | -| ipv4_num | 结果中偏好的 IPv4 接口数量 | 5 | -| ipv6_num | 结果中偏好的 IPv6 接口数量 | 5 | -| ipv6_support | 强制认为当前网络支持IPv6,跳过检测 | False | -| ipv_type | 生成结果中接口的协议类型,可选值:ipv4、ipv6、全部、all | 全部 | -| ipv_type_prefer | 接口协议类型偏好,优先将该类型的接口排在结果前面,可选值:IPv4、IPv6、自动、auto | 自动 | -| min_resolution | 接口最小分辨率,需要开启 open_filter_resolution 才能生效 | 1920x1080 | -| min_speed | 接口最小速率(单位M/s),需要开启 open_filter_speed 才能生效 | 0.2 | -| multicast_num | 结果中偏好的组播源接口数量 | 3 | -| multicast_page_num | 组播地区获取分页数量 | 1 | -| multicast_region_list | 组播源地区列表,"全部"表示所有地区 | 全部 | -| online_search_num | 结果中偏好的关键字搜索接口数量 | 0 | -| online_search_page_num | 关键字搜索频道获取分页数量 | 1 | -| origin_type_prefer | 结果偏好的接口来源,结果优先按该顺序进行排序,hotel:酒店源,multicast:组播源,subscribe:订阅源,online_search:关键字搜索 | hotel,multicast,subscribe,online_search | -| recent_days | 获取最近时间范围内更新的接口(单位天),适当减小可避免出现匹配问题 | 30 | -| request_timeout | 查询请求超时时长,单位秒(s),用于控制查询接口文本链接的超时时长以及重试时长,调整此值能优化更新时间 | 10 | -| sort_timeout | 单个接口测速超时时长,单位秒(s);数值越大测速所属时间越长,能提高获取接口数量,但质量会有所下降;数值越小测速所需时间越短,能获取低延时的接口,质量较好;调整此值能优化更新时间 | 10 | -| source_file | 模板文件路径 | config/demo.txt | -| subscribe_num | 结果中偏好的订阅源接口数量 | 3 | -| urls_limit | 单个频道接口数量 | 10 | \ No newline at end of file +| 配置项 | 描述 | 默认值 | +|:-----------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------| +| open_driver | 开启浏览器运行,若更新无数据可开启此模式,较消耗性能 | False | +| open_empty_category | 开启无结果频道分类,自动归类至底部 | False | +| open_filter_resolution | 开启分辨率过滤,低于最小分辨率(min_resolution)的接口将会被过滤 | True | +| open_filter_speed | 开启速率过滤,低于最小速率(min_speed)的接口将会被过滤 | True | +| open_hotel | 开启酒店源功能,关闭后所有酒店源工作模式都将关闭 | True | +| open_hotel_foodie | 开启 Foodie 酒店源工作模式 | True | +| open_hotel_fofa | 开启 FOFA、ZoomEye 酒店源工作模式 | True | +| open_keep_all | 开启保留所有检索结果,会保留非模板频道名称的结果,推荐手动维护时开启 | False | +| open_m3u_result | 开启转换生成 m3u 文件类型结果链接,支持显示频道图标 | True | +| open_multicast | 开启组播源功能,关闭后所有组播源工作模式都将关闭 | True | +| open_multicast_foodie | 开启 Foodie 组播源工作模式 | True | +| open_multicast_fofa | 开启 FOFA 组播源工作模式 | True | +| open_online_search | 开启关键字搜索源功能 | False | +| open_proxy | 开启代理,自动获取免费可用代理,若更新无数据可开启此模式 | False | +| open_request | 开启查询请求,数据来源于网络(仅针对酒店源与组播源) | False | +| open_service | 开启页面服务,用于控制是否启动结果页面服务;如果使用青龙等平台部署,有专门设定的定时任务,需要更新完成后停止运行,可以关闭该功能 | True | +| open_sort | 开启排序功能(响应速度、日期、分辨率) | True | +| open_subscribe | 开启订阅源功能 | False | +| open_update | 开启更新,用于控制是否更新接口,若关闭则所有工作模式(获取接口和测速)均停止 | True | +| open_update_time | 开启显示更新时间 | True | +| open_url_info | 开启显示接口说明信息,用于控制是否显示分辨率、接口协议类型等信息,为$符号后的内容,播放软件使用该信息对接口进行描述 | True | +| open_use_cache | 开启使用本地缓存数据,适用于查询请求失败场景(仅针对酒店源与组播源) | True | +| open_use_old_result | 开启使用历史更新结果(包含模板与结果文件的接口),合并至本次更新中 | True | +| app_port | 页面服务端口,用于控制页面服务的端口号 | 8000 | +| final_file | 生成结果文件路径 | output/result.txt | +| hotel_num | 结果中偏好的酒店源接口数量 | 10 | +| hotel_page_num | 酒店地区获取分页数量 | 1 | +| hotel_region_list | 酒店源地区列表,"全部"表示所有地区 | 全部 | +| ipv4_num | 结果中偏好的 IPv4 接口数量 | 5 | +| ipv6_num | 结果中偏好的 IPv6 接口数量 | 5 | +| ipv6_support | 强制认为当前网络支持IPv6,跳过检测 | False | +| ipv_type | 生成结果中接口的协议类型,可选值:ipv4、ipv6、全部、all | 全部 | +| ipv_type_prefer | 接口协议类型偏好,优先将该类型的接口排在结果前面,可选值:IPv4、IPv6、自动、auto | 自动 | +| min_resolution | 接口最小分辨率,需要开启 open_filter_resolution 才能生效 | 1920x1080 | +| min_speed | 接口最小速率(单位M/s),需要开启 open_filter_speed 才能生效 | 0.2 | +| multicast_num | 结果中偏好的组播源接口数量 | 10 | +| multicast_page_num | 组播地区获取分页数量 | 1 | +| multicast_region_list | 组播源地区列表,"全部"表示所有地区 | 全部 | +| online_search_num | 结果中偏好的关键字搜索接口数量 | 0 | +| online_search_page_num | 关键字搜索频道获取分页数量 | 1 | +| origin_type_prefer | 结果偏好的接口来源,结果优先按该顺序进行排序,逗号分隔,例如:hotel,multicast,subscribe,online_search;hotel:酒店源,multicast:组播源,subscribe:订阅源,online_search:关键字搜索;不填写则表示不指定来源,按照接口速率排序 | | +| recent_days | 获取最近时间范围内更新的接口(单位天),适当减小可避免出现匹配问题 | 30 | +| request_timeout | 查询请求超时时长,单位秒(s),用于控制查询接口文本链接的超时时长以及重试时长,调整此值能优化更新时间 | 10 | +| sort_timeout | 单个接口测速超时时长,单位秒(s);数值越大测速所属时间越长,能提高获取接口数量,但质量会有所下降;数值越小测速所需时间越短,能获取低延时的接口,质量较好;调整此值能优化更新时间 | 10 | +| source_file | 模板文件路径 | config/demo.txt | +| subscribe_num | 结果中偏好的订阅源接口数量 | 10 | +| urls_limit | 单个频道接口数量 | 10 | \ No newline at end of file diff --git a/docs/config_en.md b/docs/config_en.md index d7aeef6538..406b6c63d4 100644 --- a/docs/config_en.md +++ b/docs/config_en.md @@ -1,49 +1,49 @@ -| Configuration Item | Description | Default Value | -|:-----------------------|:-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:-------------------------------------------| -| open_driver | Enable browser execution, If there are no updates, this mode can be enabled, which consumes more performance | False | -| open_empty_category | Enable the No Results Channel Category, which will automatically categorize channels without results to the bottom | False | -| open_filter_resolution | Enable resolution filtering, interfaces with resolution lower than the minimum resolution (min_resolution) will be filtered | True | -| open_filter_speed | Enable speed filtering, interfaces with speed lower than the minimum speed (min_speed) will be filtered | True | -| open_hotel | Enable the hotel source function, after closing it all hotel source working modes will be disabled | True | -| open_hotel_foodie | Enable Foodie hotel source work mode | True | -| open_hotel_fofa | Enable FOFA、ZoomEye hotel source work mode | True | -| open_keep_all | Enable retain all search results, retain results with non-template channel names, recommended to be turned on when manually maintaining | False | -| open_m3u_result | Enable the conversion to generate m3u file type result links, supporting the display of channel icons | True | -| open_multicast | Enable the multicast source function, after disabling it all multicast sources will stop working | True | -| open_multicast_foodie | Enable Foodie multicast source work mode | True | -| open_multicast_fofa | Enable FOFA multicast source work mode | True | -| open_online_search | Enable keyword search source feature | False | -| open_proxy | Enable proxy, automatically obtains free available proxies, If there are no updates, this mode can be enabled | False | -| open_request | Enable query request, the data is obtained from the network (only for hotel sources and multicast sources) | False | -| open_service | Enable page service, used to control whether to start the result page service; if deployed on platforms like Qinglong with dedicated scheduled tasks, the function can be turned off after updates are completed and the task is stopped | True | -| open_sort | Enable the sorting function (response speed, date, resolution) | True | -| open_subscribe | Enable subscription source feature | True | -| open_update | Enable updates, if disabled then only the result page service is run | True | -| open_update_time | Enable show update time | True | -| open_url_info | Enable display of API description information, used to control whether to show resolution, API protocol type, etc., the content after the $ symbol, playback software uses this information to describe the API | True | -| open_use_cache | Enable the use of local cache data, applicable to the query request failure scenario (only for hotel sources and multicast sources) | True | -| open_use_old_result | Enable the use of historical update results (including the interface for template and result files) and merge them into the current update | True | -| app_port | Page service port, used to control the port number of the page service | 8000 | -| final_file | Generated result file path | output/result.txt | -| hotel_num | The number of preferred hotel source interfaces in the results | 4 | -| hotel_page_num | Number of pages to retrieve for hotel regions | 1 | -| hotel_region_list | List of hotel source regions, 'all' indicates all regions | all | -| ipv4_num | The preferred number of IPv4 interfaces in the result | 5 | -| ipv6_num | The preferred number of IPv6 interfaces in the result | 5 | -| ipv6_support | It is forced to consider that the current network supports IPv6 and skip the check | False | -| ipv_type | The protocol type of interface in the generated result, optional values: ipv4, ipv6, all | all | -| ipv_type_prefer | Interface protocol type preference, prioritize interfaces of this type in the results, optional values: IPv4, IPv6, auto | auto | -| min_resolution | Minimum interface resolution, requires enabling open_filter_resolution to take effect | 1920x1080 | -| min_speed | Minimum interface speed (M/s), requires enabling open_filter_speed to take effect | 0.2 | -| multicast_num | The number of preferred multicast source interfaces in the results | 3 | -| multicast_page_num | Number of pages to retrieve for multicast regions | 1 | -| multicast_region_list | Multicast source region list, 'all' indicates all regions | all | -| online_search_num | The number of preferred keyword search interfaces in the results | 0 | -| online_search_page_num | Page retrieval quantity for keyword search channels | 1 | -| origin_type_prefer | Result preference for the source of the interface, results are prioritized in this order: hotel: hotel source, multicast: multicast source, subscribe: subscription source, online_search: keyword search | hotel, multicast, subscribe, online_search | -| recent_days | Retrieve interfaces updated within a recent time range (in days), reducing appropriately can avoid matching issues | 30 | -| request_timeout | Query request timeout duration, in seconds (s), used to control the timeout and retry duration for querying interface text links. Adjusting this value can optimize update time. | 10 | -| sort_timeout | The timeout duration for speed testing of a single interface, in seconds (s). A larger value means a longer testing period, which can increase the number of interfaces obtained but may decrease their quality. A smaller value means a shorter testing time, which can obtain low-latency interfaces with better quality. Adjusting this value can optimize the update time. | 10 | -| source_file | Template file path | config/demo.txt | -| subscribe_num | The number of preferred subscribe source interfaces in the results | 3 | -| urls_limit | Number of interfaces per channel | 10 | \ No newline at end of file +| Configuration Item | Description | Default Value | +|:-----------------------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------| +| open_driver | Enable browser execution, If there are no updates, this mode can be enabled, which consumes more performance | False | +| open_empty_category | Enable the No Results Channel Category, which will automatically categorize channels without results to the bottom | False | +| open_filter_resolution | Enable resolution filtering, interfaces with resolution lower than the minimum resolution (min_resolution) will be filtered | True | +| open_filter_speed | Enable speed filtering, interfaces with speed lower than the minimum speed (min_speed) will be filtered | True | +| open_hotel | Enable the hotel source function, after closing it all hotel source working modes will be disabled | True | +| open_hotel_foodie | Enable Foodie hotel source work mode | True | +| open_hotel_fofa | Enable FOFA、ZoomEye hotel source work mode | True | +| open_keep_all | Enable retain all search results, retain results with non-template channel names, recommended to be turned on when manually maintaining | False | +| open_m3u_result | Enable the conversion to generate m3u file type result links, supporting the display of channel icons | True | +| open_multicast | Enable the multicast source function, after disabling it all multicast sources will stop working | True | +| open_multicast_foodie | Enable Foodie multicast source work mode | True | +| open_multicast_fofa | Enable FOFA multicast source work mode | True | +| open_online_search | Enable keyword search source feature | False | +| open_proxy | Enable proxy, automatically obtains free available proxies, If there are no updates, this mode can be enabled | False | +| open_request | Enable query request, the data is obtained from the network (only for hotel sources and multicast sources) | False | +| open_service | Enable page service, used to control whether to start the result page service; if deployed on platforms like Qinglong with dedicated scheduled tasks, the function can be turned off after updates are completed and the task is stopped | True | +| open_sort | Enable the sorting function (response speed, date, resolution) | True | +| open_subscribe | Enable subscription source feature | True | +| open_update | Enable updates, if disabled then only the result page service is run | True | +| open_update_time | Enable show update time | True | +| open_url_info | Enable display of API description information, used to control whether to show resolution, API protocol type, etc., the content after the $ symbol, playback software uses this information to describe the API | True | +| open_use_cache | Enable the use of local cache data, applicable to the query request failure scenario (only for hotel sources and multicast sources) | True | +| open_use_old_result | Enable the use of historical update results (including the interface for template and result files) and merge them into the current update | True | +| app_port | Page service port, used to control the port number of the page service | 8000 | +| final_file | Generated result file path | output/result.txt | +| hotel_num | The number of preferred hotel source interfaces in the results | 10 | +| hotel_page_num | Number of pages to retrieve for hotel regions | 1 | +| hotel_region_list | List of hotel source regions, 'all' indicates all regions | all | +| ipv4_num | The preferred number of IPv4 interfaces in the result | 5 | +| ipv6_num | The preferred number of IPv6 interfaces in the result | 5 | +| ipv6_support | It is forced to consider that the current network supports IPv6 and skip the check | False | +| ipv_type | The protocol type of interface in the generated result, optional values: ipv4, ipv6, all | all | +| ipv_type_prefer | Interface protocol type preference, prioritize interfaces of this type in the results, optional values: IPv4, IPv6, auto | auto | +| min_resolution | Minimum interface resolution, requires enabling open_filter_resolution to take effect | 1920x1080 | +| min_speed | Minimum interface speed (M/s), requires enabling open_filter_speed to take effect | 0.2 | +| multicast_num | The number of preferred multicast source interfaces in the results | 10 | +| multicast_page_num | Number of pages to retrieve for multicast regions | 1 | +| multicast_region_list | Multicast source region list, 'all' indicates all regions | all | +| online_search_num | The number of preferred keyword search interfaces in the results | 0 | +| online_search_page_num | Page retrieval quantity for keyword search channels | 1 | +| origin_type_prefer | Preferred interface source of the result, the result is sorted according to this order, separated by commas, for example: hotel, multicast, subscribe, online_search; hotel: hotel source, multicast: multicast source, subscribe: subscription source, online_search: keyword search; If not filled in, it means that the source is not specified, and it is sorted according to the interface rate | | +| recent_days | Retrieve interfaces updated within a recent time range (in days), reducing appropriately can avoid matching issues | 30 | +| request_timeout | Query request timeout duration, in seconds (s), used to control the timeout and retry duration for querying interface text links. Adjusting this value can optimize update time. | 10 | +| sort_timeout | The timeout duration for speed testing of a single interface, in seconds (s). A larger value means a longer testing period, which can increase the number of interfaces obtained but may decrease their quality. A smaller value means a shorter testing time, which can obtain low-latency interfaces with better quality. Adjusting this value can optimize the update time. | 10 | +| source_file | Template file path | config/demo.txt | +| subscribe_num | The number of preferred subscribe source interfaces in the results | 10 | +| urls_limit | Number of interfaces per channel | 10 | \ No newline at end of file diff --git a/tkinter_ui/prefer.py b/tkinter_ui/prefer.py index 5e1136cba9..3213528674 100644 --- a/tkinter_ui/prefer.py +++ b/tkinter_ui/prefer.py @@ -1,5 +1,6 @@ import tkinter as tk from tkinter import ttk + from utils.config import config @@ -8,10 +9,9 @@ def init_ui(self, root=None): """ Init prefer UI """ - origin_type_prefer = [item.lower() for item in config.origin_type_prefer] config_options = [ - {"label_text": f"结果来源优先{i+1}:", "combo_box_value": i} - for i in range(len(origin_type_prefer)) + {"label_text": f"结果来源优先{i + 1}:", "combo_box_value": value} + for i, value in enumerate(self.get_origin_type_prefer_index(config.origin_type_prefer)) ] self.origin_type_prefer_options = [] for config_option in config_options: @@ -48,6 +48,18 @@ def init_ui(self, root=None): input.entry.bind("", input.update_input) self.ipv_type_input.append(input) + def get_origin_type_prefer_index(self, origin_type_prefer): + index_list = [None, None, None, None] + origin_type_prefer_obj = { + "hotel": 0, + "multicast": 1, + "subscribe": 2, + "online_search": 3, + } + for i, item in enumerate(origin_type_prefer): + index_list[i] = origin_type_prefer_obj[item] + return index_list + def update_ipv_type_prefer(self, event): config.set( "Settings", @@ -87,7 +99,7 @@ def __init__(self, master, ipv_type): def update_input(self, event): config.set( "Settings", - f"{ self.ipv_type}_num", + f"{self.ipv_type}_num", self.entry.get(), ) @@ -123,33 +135,42 @@ def __init__(self, master, label_text, combo_box_value): combo_box_values_name = list(self.origin_type_prefer_obj.keys()) self.combo_box["values"] = combo_box_values_name self.combo_box.pack(side=tk.LEFT, padx=4, pady=8) - self.combo_box.current(combo_box_value) + origin_type_prefer = config.origin_type_prefer + if not origin_type_prefer or combo_box_value is None: + self.combo_box.current(None) + else: + self.combo_box.current(combo_box_value) self.entry_label = tk.Label(self.column2, text="数量:", width=12) self.entry_label.pack(side=tk.LEFT, padx=4, pady=8) self.entry = tk.Entry(self.column2) - self.entry.insert( - 0, - config.source_limits[self.origin_type_prefer_obj[self.combo_box.get()]], - ) + if origin_type_prefer and combo_box_value is not None: + self.entry.insert( + 0, + config.source_limits[self.origin_type_prefer_obj[self.combo_box.get()]], + ) self.entry.pack(side=tk.LEFT, padx=4, pady=8) def update_select(self, key): origin_type_prefer_list = [item.lower() for item in config.origin_type_prefer] - origin_type_prefer_list[self.combo_box_value] = self.origin_type_prefer_obj[ + select_value = self.origin_type_prefer_obj[ self.combo_box.get() ] + if self.combo_box_value < len(origin_type_prefer_list): + origin_type_prefer_list[self.combo_box_value] = select_value + else: + origin_type_prefer_list.append(select_value) config.set( "Settings", "origin_type_prefer", - (",").join(origin_type_prefer_list), + ",".join(origin_type_prefer_list), ) def update_input(self, event): config.set( "Settings", - f"{ self.origin_type_prefer_obj[self.combo_box.get()]}_num", + f"{self.origin_type_prefer_obj[self.combo_box.get()]}_num", self.entry.get(), ) diff --git a/utils/config.py b/utils/config.py index 3fa985d3d1..2c372a13df 100644 --- a/utils/config.py +++ b/utils/config.py @@ -116,7 +116,7 @@ def origin_type_prefer(self): for origin in self.config.get( "Settings", "origin_type_prefer", - fallback="hotel,multicast,subscribe,online_search", + fallback="", ).split(",") if origin.strip().lower() ] diff --git a/utils/speed.py b/utils/speed.py index aa3ca7e45a..5fd9b79e0d 100644 --- a/utils/speed.py +++ b/utils/speed.py @@ -2,7 +2,7 @@ import re import subprocess from time import time -from urllib.parse import quote +from urllib.parse import quote, urlparse import m3u8 from aiohttp import ClientSession, TCPConnector @@ -47,23 +47,38 @@ async def get_speed_m3u8(url: str, timeout: int = config.sort_timeout) -> dict[s try: url = quote(url, safe=':/?$&=@[]').partition('$')[0] async with ClientSession(connector=TCPConnector(ssl=False), trust_env=True) as session: - async with session.head(url, timeout=2) as response: - if response.headers.get('Content-Type') == 'application/vnd.apple.mpegurl': - m3u8_obj = m3u8.load(url, timeout=2) - speed_list = [] - start_time = time() - for segment in m3u8_obj.segments: - if time() - start_time > timeout: - break - ts_url = segment.absolute_uri - download_info = await get_speed_with_download(ts_url, timeout) - speed_list.append(download_info['speed']) - if info['delay'] is None and download_info['delay'] is not None: - info['delay'] = download_info['delay'] - info['speed'] = sum(speed_list) / len(speed_list) if speed_list else 0 + async with session.head(url, timeout=5) as response: + content_type = response.headers.get('Content-Type') + if content_type: + content_type = content_type.lower() + location = response.headers.get('Location') + if 'application/vnd.apple.mpegurl' in content_type: + url = location or url + m3u8_obj = m3u8.load(url, timeout=2) + playlists = m3u8_obj.data.get('playlists') + segments = m3u8_obj.segments + if not segments and playlists: + parsed_url = urlparse(url) + url = f"{parsed_url.scheme}://{parsed_url.netloc}{parsed_url.path.rsplit('/', 1)[0]}/{playlists[0].get('uri', '')}" + m3u8_obj = m3u8.load(url, timeout=2) + segments = m3u8_obj.segments + if not segments: + return info + ts_urls = [segment.absolute_uri for segment in segments] + speed_list = [] + start_time = time() + for ts_url in ts_urls: + if time() - start_time > timeout: + break + download_info = await get_speed_with_download(ts_url, timeout) + speed_list.append(download_info['speed']) + if info['delay'] is None and download_info['delay'] is not None: + info['delay'] = download_info['delay'] + info['speed'] = sum(speed_list) / len(speed_list) if speed_list else 0 + elif location: + info.update(await get_speed_m3u8(location, timeout)) elif response.headers.get('Content-Length'): - download_info = await get_speed_with_download(url, timeout) - info.update(download_info) + info.update(await get_speed_with_download(url, timeout)) else: return info except: diff --git a/utils/tools.py b/utils/tools.py index 54787f161b..bac93a110b 100644 --- a/utils/tools.py +++ b/utils/tools.py @@ -146,6 +146,9 @@ def get_total_urls(info_list, ipv_type_prefer, origin_type_prefer): """ Get the total urls from info list """ + origin_prefer_bool = bool(origin_type_prefer) + if not origin_prefer_bool: + origin_type_prefer = ["all"] categorized_urls = { origin: {"ipv4": [], "ipv6": []} for origin in origin_type_prefer } @@ -163,7 +166,7 @@ def get_total_urls(info_list, ipv_type_prefer, origin_type_prefer): if origin == "subscribe" and "/rtp/" in url: origin = "multicast" - if origin not in origin_type_prefer: + if origin_prefer_bool and (origin not in origin_type_prefer): continue if config.open_filter_resolution and resolution: @@ -184,6 +187,9 @@ def get_total_urls(info_list, ipv_type_prefer, origin_type_prefer): if resolution: url = add_url_info(url, resolution) + if not origin_prefer_bool: + origin = "all" + if url_is_ipv6: categorized_urls[origin]["ipv6"].append(url) else: @@ -205,7 +211,7 @@ def get_total_urls(info_list, ipv_type_prefer, origin_type_prefer): if not urls: break limit = min( - max(config.source_limits[origin] - ipv_num[ipv_type], 0), + max(config.source_limits.get(origin, urls_limit) - ipv_num[ipv_type], 0), max(config.ipv_limit[ipv_type] - ipv_num[ipv_type], 0), ) limit_urls = urls[:limit] @@ -222,9 +228,7 @@ def get_total_urls(info_list, ipv_type_prefer, origin_type_prefer): for ipv_type in ipv_type_total: if len(total_urls) >= urls_limit: break - extra_urls = categorized_urls[origin][ipv_type][ - : config.source_limits[origin] - ] + extra_urls = categorized_urls[origin][ipv_type][: config.source_limits.get(origin, urls_limit)] total_urls.extend(extra_urls) total_urls = list(dict.fromkeys(total_urls))[:urls_limit]