Switched to FastApi
This commit is contained in:
+2
-2
@@ -31,10 +31,10 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"General":{
|
"General":{
|
||||||
"load_env": "0",
|
"load_env": "1",
|
||||||
"HOST": "0.0.0.0",
|
"HOST": "0.0.0.0",
|
||||||
"PORT": "8080",
|
"PORT": "8080",
|
||||||
"HF": "1"
|
"HF": "0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,7 +5,7 @@ import config
|
|||||||
env_vars = load_env()
|
env_vars = load_env()
|
||||||
|
|
||||||
TMDB_KEY = env_vars.get('TMDB_KEY')
|
TMDB_KEY = env_vars.get('TMDB_KEY')
|
||||||
def get_TMDb_id_from_IMDb_id(imdb_id):
|
def get_TMDb_id_from_IMDb_id(imdb_id):
|
||||||
response = requests.get(f'https://api.themoviedb.org/3/find/{imdb_id}',
|
response = requests.get(f'https://api.themoviedb.org/3/find/{imdb_id}',
|
||||||
params={'external_source': 'imdb_id', 'api_key': f'{TMDB_KEY}'})
|
params={'external_source': 'imdb_id', 'api_key': f'{TMDB_KEY}'})
|
||||||
tmbda = response.json()
|
tmbda = response.json()
|
||||||
|
|||||||
+3
-1
@@ -2,5 +2,7 @@ bs4
|
|||||||
tmdbv3api
|
tmdbv3api
|
||||||
dateparser
|
dateparser
|
||||||
python-dotenv
|
python-dotenv
|
||||||
flask
|
fastapi
|
||||||
|
uvicorn
|
||||||
|
tzdata
|
||||||
lxml
|
lxml
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
from fastapi import FastAPI, HTTPException
|
||||||
|
from fastapi.responses import JSONResponse
|
||||||
from flask import Flask, jsonify, abort
|
from flask import Flask, jsonify, abort
|
||||||
from filmpertutti import filmpertutti
|
from filmpertutti import filmpertutti
|
||||||
from streamingcommunity import streaming_community
|
from streamingcommunity import streaming_community
|
||||||
@@ -10,6 +12,7 @@ import logging
|
|||||||
from okru import okru_get_url
|
from okru import okru_get_url
|
||||||
from animeworld import animeworld
|
from animeworld import animeworld
|
||||||
from dictionaries import okru,STREAM
|
from dictionaries import okru,STREAM
|
||||||
|
import httpx
|
||||||
# Configure logging
|
# Configure logging
|
||||||
FILMPERTUTTI = config.FILMPERTUTTI
|
FILMPERTUTTI = config.FILMPERTUTTI
|
||||||
STREAMINGCOMMUNITY = config.STREAMINGCOMMUNITY
|
STREAMINGCOMMUNITY = config.STREAMINGCOMMUNITY
|
||||||
@@ -30,8 +33,7 @@ else:
|
|||||||
if MYSTERIUS == "1":
|
if MYSTERIUS == "1":
|
||||||
from cool import cool
|
from cool import cool
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = FastAPI()
|
||||||
|
|
||||||
MANIFEST = {
|
MANIFEST = {
|
||||||
"id": "org.stremio.mammamia",
|
"id": "org.stremio.mammamia",
|
||||||
"version": "1.0.5",
|
"version": "1.0.5",
|
||||||
@@ -48,23 +50,23 @@ MANIFEST = {
|
|||||||
|
|
||||||
|
|
||||||
def respond_with(data):
|
def respond_with(data):
|
||||||
resp = jsonify(data)
|
resp = JSONResponse(data)
|
||||||
resp.headers['Access-Control-Allow-Origin'] = '*'
|
resp.headers['Access-Control-Allow-Origin'] = '*'
|
||||||
resp.headers['Access-Control-Allow-Headers'] = '*'
|
resp.headers['Access-Control-Allow-Headers'] = '*'
|
||||||
return resp
|
return resp
|
||||||
|
|
||||||
@app.route('/manifest.json')
|
@app.get('/manifest.json')
|
||||||
def addon_manifest():
|
def addon_manifest():
|
||||||
return respond_with(MANIFEST)
|
return respond_with(MANIFEST)
|
||||||
|
|
||||||
@app.route('/')
|
@app.get('/')
|
||||||
def root():
|
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"
|
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/<type>/<id>.json')
|
@app.get('/catalog/<type>/<id>.json')
|
||||||
def addon_catalog(type, id):
|
def addon_catalog(type, id):
|
||||||
if type != "tv":
|
if type != "tv":
|
||||||
abort(404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
catalogs = {"metas": []}
|
catalogs = {"metas": []}
|
||||||
for channel in STREAM["channels"]:
|
for channel in STREAM["channels"]:
|
||||||
@@ -78,10 +80,10 @@ def addon_catalog(type, id):
|
|||||||
|
|
||||||
return respond_with(catalogs)
|
return respond_with(catalogs)
|
||||||
|
|
||||||
@app.route('/meta/<type>/<id>.json')
|
@app.get('/meta/<type>/<id>.json')
|
||||||
def addon_meta(type, id):
|
def addon_meta(type, id):
|
||||||
if type != "tv":
|
if type != "tv":
|
||||||
abort(404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
for channel in STREAM["channels"]:
|
for channel in STREAM["channels"]:
|
||||||
if channel["id"] == id:
|
if channel["id"] == id:
|
||||||
@@ -106,10 +108,10 @@ def addon_meta(type, id):
|
|||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/stream/<type>/<id>.json')
|
@app.get('/stream/{type}/{id}.json')
|
||||||
def addon_stream(type, id):
|
def addon_stream(type, id):
|
||||||
if type not in MANIFEST['types']:
|
if type not in MANIFEST['types']:
|
||||||
abort(404)
|
raise HTTPException(status_code=404)
|
||||||
streams = {'streams': []}
|
streams = {'streams': []}
|
||||||
if type == "tv":
|
if type == "tv":
|
||||||
for channel in STREAM["channels"]:
|
for channel in STREAM["channels"]:
|
||||||
@@ -125,7 +127,7 @@ def addon_stream(type, id):
|
|||||||
'url': channel_url
|
'url': channel_url
|
||||||
})
|
})
|
||||||
if not streams['streams']:
|
if not streams['streams']:
|
||||||
abort(404)
|
raise HTTPException(status_code=404)
|
||||||
return respond_with(streams)
|
return respond_with(streams)
|
||||||
else:
|
else:
|
||||||
logging.debug(f"Handling movie or series: {id}")
|
logging.debug(f"Handling movie or series: {id}")
|
||||||
@@ -178,11 +180,11 @@ def addon_stream(type, id):
|
|||||||
if url_streamingwatch:
|
if url_streamingwatch:
|
||||||
streams['streams'].append({'title': f'{HF}StreamingWatch 720p', 'url': url_streamingwatch})
|
streams['streams'].append({'title': f'{HF}StreamingWatch 720p', 'url': url_streamingwatch})
|
||||||
if not streams['streams']:
|
if not streams['streams']:
|
||||||
abort(404)
|
raise HTTPException(status_code=404)
|
||||||
|
|
||||||
return respond_with(streams)
|
return respond_with(streams)
|
||||||
|
|
||||||
|
|
||||||
return respond_with({"meta": meta})
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
app.run(host=HOST, port=PORT)
|
import uvicorn
|
||||||
|
uvicorn.run("run:app", host=HOST, port=PORT, log_level="info")
|
||||||
@@ -187,7 +187,7 @@ def streaming_community(imdb):
|
|||||||
showname = get_info_tmdb(tmdba,ismovie,type)
|
showname = get_info_tmdb(tmdba,ismovie,type)
|
||||||
elif SC_FAST_SEARCH == "0":
|
elif SC_FAST_SEARCH == "0":
|
||||||
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
||||||
showname,date = get_info_tmdb(tmdba,ismovie,type)
|
showname,date = get_info_tmdb(tmdba,ismovie,type)
|
||||||
#HERE THE CASE IF IT IS A MOVIE
|
#HERE THE CASE IF IT IS A MOVIE
|
||||||
else:
|
else:
|
||||||
if "tt" in imdb:
|
if "tt" in imdb:
|
||||||
|
|||||||
Reference in New Issue
Block a user