forked from hl128k/tvbox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathautoUrl.py
32 lines (32 loc) · 1.74 KB
/
autoUrl.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import re
import datetime
import requests
import urllib3
p1 = re.compile(r"[(](.*?)[)]", re.S)
p2 = re.compile(r"^(https://ghproxy.com/https://raw.githubusercontent.com/tv-player/tvbox-line/main/tv/)", re.I)
urllib3.disable_warnings()
req = requests.get('https://raw.fastgit.org/tv-player/TvBox/main/README.md', verify=False)
nameList=[]
for url in re.findall(p1,req.text):
reflag=re.search(p2, url)
if reflag:
urlReq = requests.get(url, verify=False)
urlname=url.replace("https://ghproxy.com/https://raw.githubusercontent.com/tv-player/tvbox-line/main/tv/", "")
reqtext=urlReq.text
reqtext=reqtext.replace("'https://github.com", "'https://ghproxy.com/https://github.com").replace("'https://raw.githubusercontent", "'https://ghproxy.com/https://raw.githubusercontent").replace("'https://raw.iqiq.io/wsl201/box/main/", "'https://ghproxy.net/https://raw.githubusercontent.com/wsl201/box/main/tvbox/")
fp = open("./tv/"+urlname, "w+",encoding='utf-8')
fp.write(reqtext)
nameList.append(urlname)
now = datetime.datetime.now()
fp = open('README.md', "w+",encoding='utf-8')
fp.write("# TvBox 配置\n\n")
fp.write("所有数据均来自于网络,不保证可用性\n\n")
fp.write("原始数据来源:https://github.com/tv-player/TvBox\n\n")
fp.write("因电视对GitHub访问问题,所以将配置中的GitHub缓存镜像源\n\n")
fp.write("本次更新时间为:"+now.strftime("%Y-%m-%d %H:%M:%S")+"\n\n")
fp.write("## 配置\n\n")
fp.write("| 名称 | 地址 |\n")
fp.write("| ---- | ---- |\n")
for urlName in nameList:
fp.write("| "+urlName+" | [地址](https://ghproxy.net/https://raw.githubusercontent.com/hl128k/tvbox/main/tv/"+urlName+") |\n")
fp.close()