mirror of
https://github.com/alantang1977/JunTV.git
synced 2024-12-05 00:33: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 工作流可读写权限
|
1. Fork 此项目,开启 Action 工作流可读写权限
|
||||||
2. 修改 demo.txt 文件,后续更新根据此文件内容进行更新
|
2. 修改 demo.txt 模板文件,后续更新根据此文件内容进行更新
|
||||||
3. 修改 main.py(可选):
|
3. 修改 main.py(可选):
|
||||||
|
|
||||||
- importantList:关注频道名称列表
|
- source_file:模板文件,默认值:demo.txt
|
||||||
- importantPageNum:关注频道获取分页数量,默认值:5
|
- final_file:生成文件,默认值:result.txt
|
||||||
- defaultPageNum:常规频道获取分页数量,默认值:3
|
- important_list:关注频道名称列表
|
||||||
- urlsLimit:接口数量,默认值:15
|
- important_page_num:关注频道获取分页数量,默认值:5
|
||||||
|
- default_page_num:常规频道获取分页数量,默认值:3
|
||||||
|
- urls_limit:接口数量,默认值:15
|
||||||
- filter_invalid_url:是否过滤无效接口,默认开启
|
- 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:
|
class GetSource:
|
||||||
source_file = "demo.txt"
|
source_file = "demo.txt"
|
||||||
finalFile = "result.txt"
|
final_file = "result.txt"
|
||||||
importantList = [
|
important_list = [
|
||||||
"珠江",
|
"珠江",
|
||||||
"开平综合",
|
"开平综合",
|
||||||
"开平生活",
|
"开平生活",
|
||||||
|
@ -31,9 +31,9 @@ class GetSource:
|
||||||
"湖南卫视",
|
"湖南卫视",
|
||||||
"翡翠台",
|
"翡翠台",
|
||||||
]
|
]
|
||||||
importantPageNum = 5
|
important_page_num = 5
|
||||||
defaultPageNum = 3
|
default_page_num = 3
|
||||||
urlsLimit = 15
|
urls_limit = 15
|
||||||
filter_invalid_url = True
|
filter_invalid_url = True
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -119,12 +119,12 @@ class GetSource:
|
||||||
return infoList_new
|
return infoList_new
|
||||||
|
|
||||||
def removeFile(self):
|
def removeFile(self):
|
||||||
if os.path.exists(self.finalFile):
|
if os.path.exists(self.final_file):
|
||||||
os.remove(self.finalFile)
|
os.remove(self.final_file)
|
||||||
|
|
||||||
def outputTxt(self, cate, channelUrls):
|
def outputTxt(self, cate, channelUrls):
|
||||||
# Update the final file.
|
# Update the final file.
|
||||||
with open(self.finalFile, "a") as f:
|
with open(self.final_file, "a") as f:
|
||||||
f.write(cate + ",#genre#\n")
|
f.write(cate + ",#genre#\n")
|
||||||
for name, urls in channelUrls.items():
|
for name, urls in channelUrls.items():
|
||||||
for url in urls:
|
for url in urls:
|
||||||
|
@ -137,8 +137,10 @@ class GetSource:
|
||||||
for cate, channelObj in channelItems.items():
|
for cate, channelObj in channelItems.items():
|
||||||
channelUrls = {}
|
channelUrls = {}
|
||||||
for name in channelObj.keys():
|
for name in channelObj.keys():
|
||||||
isImportant = name in self.importantList
|
isImportant = name in self.important_list
|
||||||
pageNum = self.importantPageNum if isImportant else self.defaultPageNum
|
pageNum = (
|
||||||
|
self.important_page_num if isImportant else self.default_page_num
|
||||||
|
)
|
||||||
infoList = []
|
infoList = []
|
||||||
for page in range(1, pageNum):
|
for page in range(1, pageNum):
|
||||||
try:
|
try:
|
||||||
|
@ -211,7 +213,7 @@ class GetSource:
|
||||||
reverse=True,
|
reverse=True,
|
||||||
) # Sort by resolution
|
) # Sort by resolution
|
||||||
urls = list(dict.fromkeys(url for url, _, _ in infoList))
|
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:
|
except Exception as e:
|
||||||
print(f"Error on sorting: {e}")
|
print(f"Error on sorting: {e}")
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in a new issue