mirror of
https://github.com/alantang1977/JunTV.git
synced 2024-12-04 20:23:10 +02:00
feat:config and LICENSE
This commit is contained in:
parent
7ae50a4c0a
commit
7ddefd5bdd
3 changed files with 48 additions and 19 deletions
21
LICENSE
Normal file
21
LICENSE
Normal file
|
@ -0,0 +1,21 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) 2024-PRESENT Govin <https://github.com/guovin>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
22
README.md
22
README.md
|
@ -1,6 +1,6 @@
|
|||
# TVbox 电视直播源接口自动爬取更新
|
||||
# TVBox 电视直播源接口自动更新
|
||||
|
||||
根据基础配置直播源文件获取最新直播源接口链接
|
||||
根据基础模板直播源接口文件自动获取并更新最新直播源接口链接
|
||||
|
||||
## 特点
|
||||
|
||||
|
@ -12,13 +12,19 @@
|
|||
## 使用方法
|
||||
|
||||
1. Fork 此项目,开启 Action 工作流可读写权限
|
||||
2. 修改 demo.txt 文件,后续更新根据此文件内容进行更新
|
||||
2. 修改 demo.txt 模板文件,后续更新根据此文件内容进行更新
|
||||
3. 修改 main.py(可选):
|
||||
|
||||
- importantList:关注频道名称列表
|
||||
- importantPageNum:关注频道获取分页数量,默认值:5
|
||||
- defaultPageNum:常规频道获取分页数量,默认值:3
|
||||
- urlsLimit:接口数量,默认值:15
|
||||
- source_file:模板文件,默认值:demo.txt
|
||||
- final_file:生成文件,默认值:result.txt
|
||||
- important_list:关注频道名称列表
|
||||
- important_page_num:关注频道获取分页数量,默认值:5
|
||||
- default_page_num:常规频道获取分页数量,默认值:3
|
||||
- urls_limit:接口数量,默认值:15
|
||||
- filter_invalid_url:是否过滤无效接口,默认开启
|
||||
|
||||
4. result.txt 为更新后的直播源文件,source.json 为数据源文件
|
||||
4. result.txt 为更新后的直播源接口文件,source.json 为数据源文件
|
||||
|
||||
## License
|
||||
|
||||
[MIT](./LICENSE) License © 2024-PRESENT [Govin](https://github.com/guovin)
|
||||
|
|
24
main.py
24
main.py
|
@ -15,8 +15,8 @@ import re
|
|||
|
||||
class GetSource:
|
||||
source_file = "demo.txt"
|
||||
finalFile = "result.txt"
|
||||
importantList = [
|
||||
final_file = "result.txt"
|
||||
important_list = [
|
||||
"珠江",
|
||||
"开平综合",
|
||||
"开平生活",
|
||||
|
@ -31,9 +31,9 @@ class GetSource:
|
|||
"湖南卫视",
|
||||
"翡翠台",
|
||||
]
|
||||
importantPageNum = 5
|
||||
defaultPageNum = 3
|
||||
urlsLimit = 15
|
||||
important_page_num = 5
|
||||
default_page_num = 3
|
||||
urls_limit = 15
|
||||
filter_invalid_url = True
|
||||
|
||||
def __init__(self):
|
||||
|
@ -119,12 +119,12 @@ class GetSource:
|
|||
return infoList_new
|
||||
|
||||
def removeFile(self):
|
||||
if os.path.exists(self.finalFile):
|
||||
os.remove(self.finalFile)
|
||||
if os.path.exists(self.final_file):
|
||||
os.remove(self.final_file)
|
||||
|
||||
def outputTxt(self, cate, channelUrls):
|
||||
# Update the final file.
|
||||
with open(self.finalFile, "a") as f:
|
||||
with open(self.final_file, "a") as f:
|
||||
f.write(cate + ",#genre#\n")
|
||||
for name, urls in channelUrls.items():
|
||||
for url in urls:
|
||||
|
@ -137,8 +137,10 @@ class GetSource:
|
|||
for cate, channelObj in channelItems.items():
|
||||
channelUrls = {}
|
||||
for name in channelObj.keys():
|
||||
isImportant = name in self.importantList
|
||||
pageNum = self.importantPageNum if isImportant else self.defaultPageNum
|
||||
isImportant = name in self.important_list
|
||||
pageNum = (
|
||||
self.important_page_num if isImportant else self.default_page_num
|
||||
)
|
||||
infoList = []
|
||||
for page in range(1, pageNum):
|
||||
try:
|
||||
|
@ -211,7 +213,7 @@ class GetSource:
|
|||
reverse=True,
|
||||
) # Sort by resolution
|
||||
urls = list(dict.fromkeys(url for url, _, _ in infoList))
|
||||
channelUrls[name] = (urls or channelObj[name])[: self.urlsLimit]
|
||||
channelUrls[name] = (urls or channelObj[name])[: self.urls_limit]
|
||||
except Exception as e:
|
||||
print(f"Error on sorting: {e}")
|
||||
continue
|
||||
|
|
Loading…
Reference in a new issue