LiveTVTest / run.py
Mythus's picture
Update run.py
ea12fc4 verified
raw
history blame
5.51 kB
from flask import Flask, jsonify, abort
from filmpertutti import filmpertutti
from streamingcommunity import streaming_community
from tantifilm import tantifilm
import json
import config
import logging
# Configure logging
logging.basicConfig(level=logging.DEBUG)
FILMPERTUTTI = config.FILMPERTUTTI
STREAMINGCOMMUNITY = config.STREAMINGCOMMUNITY
MYSTERIUS = config.MYSTERIUS
TUTTIFILM = config.TUTTIFILM
TF_DOMAIN = config.TF_DOMAIN
HOST = config.HOST
PORT = int(config.PORT)
HF = config.HF
if HF == "1":
HF = "🤗️"
#Cool code to set the hugging face if the service is hosted there.
else:
HF = ""
if MYSTERIUS == "1":
from cool import cool
app = Flask(__name__)
MANIFEST = {
"id": "org.stremio.mammamia",
"version": "1.0.0",
"catalogs": [
{"type": "tv", "id": "tv_channels", "name": "TV Channels"}
],
"resources": ["stream", "catalog","meta"],
"types": ["movie", "series", "tv","channel"],
"name": "Mamma Mia",
"description": "Addon providing HTTPS Stream for Italian Movies/Series",
"logo": "https://creazilla-store.fra1.digitaloceanspaces.com/emojis/49647/pizza-emoji-clipart-md.png"
}
STREAMS = {
"tv": {
"channel1": {"name": "Channel 1", "url": "https://d3749synfikwkv.cloudfront.net/v1/master/3722c60a815c199d9c0ef36c5b73da68a62b09d1/cc-74ylxpgd78bpb/Live.m3u8"},
"channel2": {"name": "Channel 2", "url": "http://mediapolis.rai.it/relinker/relinkerServlet.htm?cont=2606803&output=7&forceUserAgent=raiplayappletv"},
# Add more channels as required
}
}
def respond_with(data):
resp = jsonify(data)
resp.headers['Access-Control-Allow-Origin'] = '*'
resp.headers['Access-Control-Allow-Headers'] = '*'
return resp
@app.route('/manifest.json')
def addon_manifest():
return respond_with(MANIFEST)
@app.route('/')
def root():
return "Hello, this is a Stremio Addon providing HTTPS Stream for Italian Movies/Series, to install it add /manifest.json to the url and then add it into the Stremio search bar"
@app.route('/catalog/tv/tv_channels.json')
def catalog():
items = []
for id, channel in STREAMS["tv"].items():
items.append({
"id": id,
"name": channel["name"],
"type": "channel"
})
return respond_with({"metas": items})
return respond_with({"metas": channels})
@app.route('/stream/<type>/<id>.json')
def addon_stream(type, id):
logging.debug(f"App debug mode: {app.debug}")
logging.debug(f"Received request for type: {type}, id: {id}")
logging.debug(f"Received request for type: {type}, id: {id}")
if type not in MANIFEST['types']: # Change this to "channel"
abort(404)
streams = {'streams': []}
channel = STREAMS.get(type, {}).get(id)
if channel:
logging.debug(f"Found TV channel: {id}")
streams['streams'] = [{"title": channel["name"], "url": channel["url"]}]
else:
logging.debug(f"Handling movie or series: {id}")
if MYSTERIUS == "1":
results = cool(id)
if results:
for resolution, link in results.items():
streams['streams'].append({'title': f'{HF}Mysterious {resolution}', 'url': link})
if STREAMINGCOMMUNITY == "1":
url_streaming_community = streaming_community(id)
if url_streaming_community is not None:
streams['streams'].append({'title': f'{HF}StreamingCommunity 1080p', 'url': f'{url_streaming_community}?rendition=1080p'})
streams['streams'].append({'title': f'{HF}StreamingCommunity 720p', 'url': f'{url_streaming_community}?rendition=720p'})
if FILMPERTUTTI == "1":
url_filmpertutti = filmpertutti(id)
if url_filmpertutti is not None:
streams['streams'].append({'title': 'Filmpertutti', 'url': url_filmpertutti})
if TUTTIFILM == "1":
url_tuttifilm = tantifilm(id)
if url_tuttifilm:
if not isinstance(url_tuttifilm, str):
for title, url in url_tuttifilm.items():
streams['streams'].append({'title': f'{HF}Tantifilm {title}', 'url': url, 'behaviorHints': {'proxyHeaders': {"request": {"Referer": "https://d000d.com/"}}, 'notWebReady': True}})
else:
streams['streams'].append({'title': f'{HF}Tantifilm', 'url': url_tuttifilm, 'behaviorHints': {'proxyHeaders': {"request": {"Referer": "https://d000d.com/"}}, 'notWebReady': True}})
if not streams['streams']:
abort(404)
return respond_with(streams)
@app.route('/meta/<type>/<id>.json')
def meta(type, id):
if type != "channel": # Change this to "channel"
abort(404)
channel = STREAMS.get("tv", {}).get(id) # Change the type here to "tv"
if channel:
return respond_with({
"meta": {
"id": id,
"name": channel["name"],
"type": "channel",
"poster": channel.get("poster", ""), # Add this line if you have a poster for each channel
"background": channel.get("background", ""), # Add this line if you have a background for each channel
"logo": channel.get("logo", ""), # Add this line if you have a logo for each channel
# Add more fields as required
}
})
abort(404)
return respond_with({"meta": meta})
if __name__ == '__main__':
app.run(host=HOST, port=PORT)