Skip to content

Instantly share code, notes, and snippets.

@fqx
Created November 29, 2022 10:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fqx/05e37db80ea7de115f475a06af7f16ec to your computer and use it in GitHub Desktop.
Save fqx/05e37db80ea7de115f475a06af7f16ec to your computer and use it in GitHub Desktop.
给m3u加上频道信息和台标
#!/usr/bin/python3
import requests, re
tgtfile = 'ptv.m3u'
url = 'https://raw.githubusercontent.com/Tzwcard/ChinaTelecom-GuangdongIPTV-RTP-List/master/GuangdongIPTV_rtp_hd.m3u'
api = 'http://epg.51zmt.top:8000/upload/'
rtp = re.compile(r'rtp://')
repl = 'http://192.168.000.000:0000/rtp/'
proxies = { }
def build_m3u(url):
r = requests.get(url, proxies=proxies, timeout=1)
m3u = re.sub(rtp, repl, r.text)
# with open(tempfile, 'w') as f:
# f.write(m3u)
return m3u
def get_epg(m3u):
file = {'myfile': m3u}
r = requests.post(api, files=file, timeout=5)
url = re.search('http.*m3u', r.text)[0]
r = requests.get(url, timeout=5)
with open(tgtfile, 'w') as f:
f.write(r.text)
if __name__ == '__main__':
m3u = build_m3u(url)
get_epg(m3u)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment