Spaces:
Runtime error
Runtime error
File size: 1,520 Bytes
9f1bb61 49e879f c1eadc1 49e879f c1eadc1 49e879f 0577f16 9f1bb61 c1eadc1 49e879f c1eadc1 49e879f c1eadc1 49e879f | 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 33 34 35 36 37 38 39 40 41 42 43 44 | from flask import Flask, Response, request
import requests
import re
# Fai molta attenzione a questa riga qui sotto:
app = Flask(name)
CHANNELS = {
"Sky Serie": "https://tv247us.vip/watch/sky-serie/",
"Sky Uno": "https://tv247us.vip/watch/sky-uno-italy/",
"Sky Sport Uno": "https://tv247us.vip/watch/sky-sport-uno-italia/",
"Sky Sport Arena": "https://tv247us.vip/watch/sky-sport-arena-italia/"
}
def get_dynamic_m3u8(page_url):
headers = {'User-Agent': 'Mozilla/5.0', 'Referer': 'https://tv247us.vip/'}
try:
r = requests.get(page_url, headers=headers, timeout=10)
match = re.search(r'(https?://[^\s\'"<>]+?\.m3u8[^\s\'"<>]*?)', r.text)
return match.group(1).replace('\\/', '/') if match else None
except: return None
@app.route('/')
def home():
return "Proxy Attivo! Usa /playlist.m3u"
@app.route('/playlist.m3u')
def playlist():
host = request.host_url.rstrip('/')
m3u = "#EXTM3U\n"
for name in CHANNELS:
m3u += f'#EXTINF:-1, {name}\n{host}/live?id={name}\n'
return Response(m3u, content_type='text/plain')
@app.route('/live')
def live():
channel_id = request.args.get('id')
target = get_dynamic_m3u8(CHANNELS.get(channel_id))
if not target: return "Link non trovato", 404
r = requests.get(target, headers={'Referer': 'https://tv247us.vip/'}, stream=True)
return Response(r.iter_content(chunk_size=1024*10), content_type='application/vnd.apple.mpegurl')
if name == 'main':
app.run(host='0.0.0.0', port=7860) |