Spaces:
Paused
Paused
Upload 4 files
Browse files- convert.py +19 -0
- info.py +119 -0
- run.py +196 -0
- streamingcommunity.py +182 -0
convert.py
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
from tmdbv3api import TMDb, Movie, TV
|
| 3 |
+
from loadenv import load_env
|
| 4 |
+
import config
|
| 5 |
+
MYSTERIUS = config.MYSTERIUS
|
| 6 |
+
if MYSTERIUS == "1":
|
| 7 |
+
TMDB_KEY,_= load_env()
|
| 8 |
+
else:
|
| 9 |
+
TMDB_KEY= load_env()
|
| 10 |
+
def get_TMDb_id_from_IMDb_id(imdb_id):
|
| 11 |
+
response = requests.get(f'https://api.themoviedb.org/3/find/{imdb_id}',
|
| 12 |
+
params={'external_source': 'imdb_id', 'api_key': f'{TMDB_KEY}'})
|
| 13 |
+
tmbda = response.json()
|
| 14 |
+
if tmbda['movie_results']:
|
| 15 |
+
return tmbda['movie_results'][0]['id']
|
| 16 |
+
elif tmbda['tv_results']:
|
| 17 |
+
return tmbda['tv_results'][0]['id']
|
| 18 |
+
else:
|
| 19 |
+
return None
|
info.py
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from loadenv import load_env
|
| 2 |
+
from tmdbv3api import TMDb, Movie, TV
|
| 3 |
+
from convert_date import convert_US_date, convert_IT_date
|
| 4 |
+
import requests
|
| 5 |
+
import config
|
| 6 |
+
SC_FAST_SEARCH = config.SC_FAST_SEARCH
|
| 7 |
+
TF_FAST_SEARCH = config.TF_FAST_SEARCH
|
| 8 |
+
MYSTERIUS = config.MYSTERIUS
|
| 9 |
+
if MYSTERIUS == "1":
|
| 10 |
+
TMDB_KEY,_= load_env()
|
| 11 |
+
else:
|
| 12 |
+
TMDB_KEY= load_env()
|
| 13 |
+
|
| 14 |
+
def get_info_tmdb(tmbda,ismovie,type):
|
| 15 |
+
tmdb = TMDb()
|
| 16 |
+
tmdb.api_key = f'{TMDB_KEY}'
|
| 17 |
+
tmdb.language = 'it'
|
| 18 |
+
if ismovie == 0:
|
| 19 |
+
tv = TV()
|
| 20 |
+
show= tv.details(tmbda)
|
| 21 |
+
showname = show.name
|
| 22 |
+
if type == "Filmpertutti":
|
| 23 |
+
date= show.first_air_date
|
| 24 |
+
print("Real date",date)
|
| 25 |
+
return showname,date
|
| 26 |
+
elif type == "StreamingCommunity":
|
| 27 |
+
if SC_FAST_SEARCH == "0":
|
| 28 |
+
n_season = show.number_of_seasons
|
| 29 |
+
full_date = show.first_air_date
|
| 30 |
+
date = full_date.split("-")[0]
|
| 31 |
+
print(date)
|
| 32 |
+
return showname,date
|
| 33 |
+
else:
|
| 34 |
+
return showname
|
| 35 |
+
elif type == "Tuttifilm":
|
| 36 |
+
if TF_FAST_SEARCH == "0":
|
| 37 |
+
date = show.first_air_date
|
| 38 |
+
date = date.split("-")[0]
|
| 39 |
+
print("Real date",date)
|
| 40 |
+
return showname,date
|
| 41 |
+
else:
|
| 42 |
+
return showname
|
| 43 |
+
elif type == "Cool":
|
| 44 |
+
return showname
|
| 45 |
+
|
| 46 |
+
elif ismovie == 1:
|
| 47 |
+
movie = Movie()
|
| 48 |
+
show= movie.details(tmbda)
|
| 49 |
+
showname= show.title
|
| 50 |
+
#Get all release dates
|
| 51 |
+
if type == "Filmpertutti":
|
| 52 |
+
date = show.release_dates
|
| 53 |
+
#GET US RELEASE DATE because filmpertutti somewhy uses US release date
|
| 54 |
+
date = convert_US_date(date)
|
| 55 |
+
return showname,date
|
| 56 |
+
elif type == "StreamingCommunity":
|
| 57 |
+
return showname
|
| 58 |
+
elif type == "Tuttifilm":
|
| 59 |
+
if TF_FAST_SEARCH == "0":
|
| 60 |
+
date = show.release_date
|
| 61 |
+
date = date.split("-")[0]
|
| 62 |
+
print("Real date",date)
|
| 63 |
+
return showname,date
|
| 64 |
+
else:
|
| 65 |
+
return showname
|
| 66 |
+
elif type == "Cool":
|
| 67 |
+
return showname
|
| 68 |
+
|
| 69 |
+
|
| 70 |
+
def get_info_imdb(imdb_id, ismovie, type):
|
| 71 |
+
|
| 72 |
+
resp = requests.get(f'https://api.themoviedb.org/3/find/{imdb_id}?api_key={TMDB_KEY}&language=it&external_source=imdb_id')
|
| 73 |
+
data = resp.json()
|
| 74 |
+
if ismovie == 0:
|
| 75 |
+
showname = data['tv_results'][0]['name']
|
| 76 |
+
if type == "Filmpertutti":
|
| 77 |
+
date= data['tv_results'][0]['first_air_date']
|
| 78 |
+
print("Real date",date)
|
| 79 |
+
return showname, date
|
| 80 |
+
elif type == "StreamingCommunity":
|
| 81 |
+
return showname
|
| 82 |
+
elif type == "Tuttifilm":
|
| 83 |
+
date = data['tv_results'][0]['first_air_date']
|
| 84 |
+
date = date.split("-")[0]
|
| 85 |
+
return showname,date
|
| 86 |
+
elif type == "Cool":
|
| 87 |
+
return showname
|
| 88 |
+
|
| 89 |
+
elif ismovie == 1:
|
| 90 |
+
showname= data['movie_results'][0]['title']
|
| 91 |
+
if type == "Filmpertutti":
|
| 92 |
+
return
|
| 93 |
+
elif type == "StreamingCommunity":
|
| 94 |
+
return showname
|
| 95 |
+
elif type == "Tuttifilm":
|
| 96 |
+
date = data['movie_results'][0]['release_date']
|
| 97 |
+
date = date.split("-")[0]
|
| 98 |
+
print("Real date",date)
|
| 99 |
+
return showname,date
|
| 100 |
+
elif type == "Cool":
|
| 101 |
+
return showname
|
| 102 |
+
|
| 103 |
+
|
| 104 |
+
|
| 105 |
+
|
| 106 |
+
|
| 107 |
+
|
| 108 |
+
def is_movie(imdb_id):
|
| 109 |
+
if "tmdb:" in imdb_id:
|
| 110 |
+
imdb_id = imdb_id.replace("tmdb:","")
|
| 111 |
+
if ":" in imdb_id:
|
| 112 |
+
season = imdb_id.split(":")[1]
|
| 113 |
+
episode = imdb_id.split(":")[-1]
|
| 114 |
+
ismovie = 0
|
| 115 |
+
imdb_id = imdb_id.split(":")[0]
|
| 116 |
+
return ismovie,imdb_id,season,episode
|
| 117 |
+
else:
|
| 118 |
+
ismovie = 1
|
| 119 |
+
return ismovie,imdb_id
|
run.py
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from flask import Flask, jsonify, abort
|
| 2 |
+
from filmpertutti import filmpertutti
|
| 3 |
+
from streamingcommunity import streaming_community
|
| 4 |
+
from tantifilm import tantifilm
|
| 5 |
+
import json
|
| 6 |
+
import config
|
| 7 |
+
import logging
|
| 8 |
+
|
| 9 |
+
# Configure logging
|
| 10 |
+
|
| 11 |
+
FILMPERTUTTI = config.FILMPERTUTTI
|
| 12 |
+
STREAMINGCOMMUNITY = config.STREAMINGCOMMUNITY
|
| 13 |
+
MYSTERIUS = config.MYSTERIUS
|
| 14 |
+
TUTTIFILM = config.TUTTIFILM
|
| 15 |
+
HOST = config.HOST
|
| 16 |
+
PORT = int(config.PORT)
|
| 17 |
+
if MYSTERIUS == "1":
|
| 18 |
+
from cool import cool
|
| 19 |
+
|
| 20 |
+
app = Flask(__name__)
|
| 21 |
+
|
| 22 |
+
MANIFEST = {
|
| 23 |
+
"id": "org.stremio.mammamia",
|
| 24 |
+
"version": "1.0.0",
|
| 25 |
+
"catalogs": [
|
| 26 |
+
{"type": "tv", "id": "tv_channels", "name": "TV Channels"}
|
| 27 |
+
],
|
| 28 |
+
"resources": ["stream", "catalog","meta"],
|
| 29 |
+
"types": ["movie", "series", "tv"],
|
| 30 |
+
"name": "Mamma Mia",
|
| 31 |
+
"description": "Addon providing HTTPS Stream for Italian Movies/Series",
|
| 32 |
+
"logo": "https://creazilla-store.fra1.digitaloceanspaces.com/emojis/49647/pizza-emoji-clipart-md.png"
|
| 33 |
+
}
|
| 34 |
+
|
| 35 |
+
STREAMS = {
|
| 36 |
+
"tv": {
|
| 37 |
+
"skysport24": [
|
| 38 |
+
{
|
| 39 |
+
"title": "Sky Sport 24",
|
| 40 |
+
"poster": "https://www.tanti.bond/public/upload/channel/sky-sport-24.webp",
|
| 41 |
+
"url": "https://07-24.mizhls.ru/fls/cdn/calcioXskysport24/playlist.m3u8",
|
| 42 |
+
"behaviorHints": {
|
| 43 |
+
"notWebReady": True,
|
| 44 |
+
"proxyHeaders": {
|
| 45 |
+
"request": {
|
| 46 |
+
"Referer": "https://claplivehdplay.ru/",
|
| 47 |
+
"Origin": "https://claplivehdplay.ru",
|
| 48 |
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
|
| 49 |
+
}
|
| 50 |
+
}
|
| 51 |
+
}
|
| 52 |
+
}
|
| 53 |
+
],
|
| 54 |
+
"Skyuno": [
|
| 55 |
+
{
|
| 56 |
+
"title": "Sky Uno",
|
| 57 |
+
"url": "https://07-24.mizhls.ru/fls/cdn/calcioXskyuno/playlist.m3u8",
|
| 58 |
+
"behaviorHints": {
|
| 59 |
+
"notWebReady": True,
|
| 60 |
+
"proxyHeaders": {
|
| 61 |
+
"request": {
|
| 62 |
+
"Referer": "https://claplivehdplay.ru/",
|
| 63 |
+
"Origin": "https://claplivehdplay.ru",
|
| 64 |
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
|
| 65 |
+
}
|
| 66 |
+
}
|
| 67 |
+
}
|
| 68 |
+
}
|
| 69 |
+
],
|
| 70 |
+
"skyserie": [
|
| 71 |
+
{
|
| 72 |
+
"title": "Sky Serie",
|
| 73 |
+
"url": "https://07-24.mizhls.ru/fls/cdn/calcioXskyserie/playlist.m3u8",
|
| 74 |
+
"behaviorHints": {
|
| 75 |
+
"notWebReady": True,
|
| 76 |
+
"proxyHeaders": {
|
| 77 |
+
"request": {
|
| 78 |
+
"Referer": "https://claplivehdplay.ru/",
|
| 79 |
+
"Origin": "https://claplivehdplay.ru",
|
| 80 |
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
|
| 81 |
+
}
|
| 82 |
+
}
|
| 83 |
+
}
|
| 84 |
+
}
|
| 85 |
+
],
|
| 86 |
+
"Sky Nature": [
|
| 87 |
+
{
|
| 88 |
+
"title": "Sky Nature",
|
| 89 |
+
"url": "https://07-24.mizhls.ru/fls/cdn/calcioXskynature/playlist.m3u8",
|
| 90 |
+
"behaviorHints": {
|
| 91 |
+
"notWebReady": True,
|
| 92 |
+
"proxyHeaders": {
|
| 93 |
+
"request": {
|
| 94 |
+
"Referer": "https://claplivehdplay.ru/",
|
| 95 |
+
"Origin": "https://claplivehdplay.ru",
|
| 96 |
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
|
| 97 |
+
}
|
| 98 |
+
}
|
| 99 |
+
}
|
| 100 |
+
}
|
| 101 |
+
],
|
| 102 |
+
"skyinvestigation": [
|
| 103 |
+
{
|
| 104 |
+
"title": "skyinvestigation",
|
| 105 |
+
"url": "https://07-24.mizhls.ru/fls/cdn/calcioXskyinvestigation/playlist.m3u8",
|
| 106 |
+
"behaviorHints": {
|
| 107 |
+
"notWebReady": True,
|
| 108 |
+
"proxyHeaders": {
|
| 109 |
+
"request": {
|
| 110 |
+
"Referer": "https://claplivehdplay.ru/",
|
| 111 |
+
"Origin": "https://claplivehdplay.ru",
|
| 112 |
+
"User-Agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
|
| 113 |
+
}
|
| 114 |
+
}
|
| 115 |
+
}
|
| 116 |
+
}
|
| 117 |
+
]
|
| 118 |
+
}
|
| 119 |
+
}
|
| 120 |
+
|
| 121 |
+
def respond_with(data):
|
| 122 |
+
resp = jsonify(data)
|
| 123 |
+
resp.headers['Access-Control-Allow-Origin'] = '*'
|
| 124 |
+
resp.headers['Access-Control-Allow-Headers'] = '*'
|
| 125 |
+
return resp
|
| 126 |
+
|
| 127 |
+
@app.route('/manifest.json')
|
| 128 |
+
def addon_manifest():
|
| 129 |
+
return respond_with(MANIFEST)
|
| 130 |
+
|
| 131 |
+
@app.route('/')
|
| 132 |
+
def root():
|
| 133 |
+
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"
|
| 134 |
+
|
| 135 |
+
@app.route('/catalog/<type>/<id>.json')
|
| 136 |
+
def addon_catalog(type, id):
|
| 137 |
+
if type not in MANIFEST['types']:
|
| 138 |
+
abort(404)
|
| 139 |
+
catalog = {'metas': []}
|
| 140 |
+
if type in STREAMS:
|
| 141 |
+
for stream_id in STREAMS[type]:
|
| 142 |
+
for item in STREAMS[type][stream_id]:
|
| 143 |
+
meta_item = {
|
| 144 |
+
"id": stream_id,
|
| 145 |
+
"type": type,
|
| 146 |
+
"name": item['title'],
|
| 147 |
+
"poster": item.get('poster', "https://via.placeholder.com/150")
|
| 148 |
+
}
|
| 149 |
+
catalog['metas'].append(meta_item)
|
| 150 |
+
return respond_with(catalog)
|
| 151 |
+
|
| 152 |
+
@app.route('/stream/<type>/<id>.json')
|
| 153 |
+
def addon_stream(type, id):
|
| 154 |
+
if type not in MANIFEST['types']:
|
| 155 |
+
abort(404)
|
| 156 |
+
streams = {'streams': []}
|
| 157 |
+
|
| 158 |
+
if type in STREAMS and id in STREAMS[type]:
|
| 159 |
+
logging.debug(f"Found TV channel: {id}")
|
| 160 |
+
streams['streams'] = STREAMS[type][id]
|
| 161 |
+
else:
|
| 162 |
+
logging.debug(f"Handling movie or series: {id}")
|
| 163 |
+
if MYSTERIUS == "1":
|
| 164 |
+
results = cool(id)
|
| 165 |
+
if results:
|
| 166 |
+
for resolution, link in results.items():
|
| 167 |
+
streams['streams'].append({'title': f'🤗️ Mysterious {resolution}', 'url': link})
|
| 168 |
+
if STREAMINGCOMMUNITY == "1":
|
| 169 |
+
url_streaming_community = streaming_community(id)
|
| 170 |
+
print(url_streaming_community)
|
| 171 |
+
if url_streaming_community is not None:
|
| 172 |
+
streams['streams'].append({'title': '🤗️ StreamingCommunity 1080p', 'url': f'{url_streaming_community}?rendition=1080p'})
|
| 173 |
+
streams['streams'].append({'title': '🤗️ StreamingCommunity 720p', 'url': f'{url_streaming_community}?rendition=720p'})
|
| 174 |
+
if FILMPERTUTTI == "1":
|
| 175 |
+
url_filmpertutti = filmpertutti(id)
|
| 176 |
+
if url_filmpertutti is not None:
|
| 177 |
+
streams['streams'].append({'title': 'Filmpertutti', 'url': url_filmpertutti})
|
| 178 |
+
if TUTTIFILM == "1":
|
| 179 |
+
url_tuttifilm = tantifilm(id)
|
| 180 |
+
streams['streams'].append({'title': '🤗️ Tantifilm', 'url': url_tuttifilm, 'behaviorHints': {'proxyHeaders': {"request": {"Referer": "https://d000d.com/"}}, 'notWebReady': True}})
|
| 181 |
+
|
| 182 |
+
if not streams['streams']:
|
| 183 |
+
abort(404)
|
| 184 |
+
|
| 185 |
+
return respond_with(streams)
|
| 186 |
+
|
| 187 |
+
@app.route('/meta/<type>/<id>.json')
|
| 188 |
+
def meta(type, id):
|
| 189 |
+
return respond_with({"meta": {
|
| 190 |
+
"id": id,
|
| 191 |
+
"type": type,
|
| 192 |
+
"name": "Whatever Channel"
|
| 193 |
+
}})
|
| 194 |
+
|
| 195 |
+
if __name__ == '__main__':
|
| 196 |
+
app.run(host=HOST, port=PORT)
|
streamingcommunity.py
ADDED
|
@@ -0,0 +1,182 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from tmdbv3api import TMDb, Movie, TV
|
| 2 |
+
import requests
|
| 3 |
+
import logging
|
| 4 |
+
from bs4 import BeautifulSoup,SoupStrainer
|
| 5 |
+
from datetime import datetime
|
| 6 |
+
import dateparser
|
| 7 |
+
from convert import get_TMDb_id_from_IMDb_id
|
| 8 |
+
from info import get_info_tmdb, is_movie, get_info_imdb
|
| 9 |
+
import config
|
| 10 |
+
import json
|
| 11 |
+
import re
|
| 12 |
+
#Get domain
|
| 13 |
+
SC_DOMAIN= config.SC_DOMAIN
|
| 14 |
+
SC_FAST_SEARCH = config.SC_FAST_SEARCH
|
| 15 |
+
|
| 16 |
+
headers = {
|
| 17 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.10; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3',
|
| 18 |
+
'Accept-Language': 'en-US,en;q=0.5'
|
| 19 |
+
}
|
| 20 |
+
|
| 21 |
+
#GET VERSION OF STREAMING COMMUNITY:
|
| 22 |
+
def get_version():
|
| 23 |
+
#Extract the version from the main page of the site
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
try:
|
| 27 |
+
base_url = f'https://streamingcommunity.{SC_DOMAIN}/richiedi-un-titolo'
|
| 28 |
+
response = requests.get(base_url, headers=headers)
|
| 29 |
+
#Soup the response
|
| 30 |
+
soup = BeautifulSoup(response.text, "lxml")
|
| 31 |
+
|
| 32 |
+
# Extract version
|
| 33 |
+
version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version']
|
| 34 |
+
return version
|
| 35 |
+
except:
|
| 36 |
+
print("Couldn't find the version")
|
| 37 |
+
version = "65e52dcf34d64173542cd2dc6b8bb75b"
|
| 38 |
+
return version
|
| 39 |
+
|
| 40 |
+
def search(query,date,ismovie):
|
| 41 |
+
#Do a request to get the ID of serie/move and it's slug in the URL
|
| 42 |
+
response = requests.get(query).json()
|
| 43 |
+
for item in response['data']:
|
| 44 |
+
tid = item['id']
|
| 45 |
+
slug = item['slug']
|
| 46 |
+
type = item['type']
|
| 47 |
+
if type == "tv":
|
| 48 |
+
type = 0
|
| 49 |
+
elif type == "movie":
|
| 50 |
+
type = 1
|
| 51 |
+
if type == ismovie:
|
| 52 |
+
#Added a Check to see if the result is what it is supposed to be
|
| 53 |
+
if SC_FAST_SEARCH == "0":
|
| 54 |
+
if ismovie == 0:
|
| 55 |
+
seasons_count = item['seasons_count']
|
| 56 |
+
#Do not ask me why but somewhy streaming community call the first air date the last air date
|
| 57 |
+
first_air_date = item['last_air_date']
|
| 58 |
+
if first_air_date:
|
| 59 |
+
first_air_year = first_air_date.split("-")[0]
|
| 60 |
+
if first_air_year == date:
|
| 61 |
+
return tid,slug
|
| 62 |
+
else:
|
| 63 |
+
response = requests.get ( f'https://streamingcommunity.boston/titles/{tid}-{slug}')
|
| 64 |
+
pattern = r'<div[^>]*class="features"[^>]*>.*?<span[^>]*>(.*?)<\/span>'
|
| 65 |
+
match = re.search(pattern, response.text)
|
| 66 |
+
print(match.group(1).split("-")[0])
|
| 67 |
+
first_air_year = match.group(1).split("-")[0]
|
| 68 |
+
date = int(date)
|
| 69 |
+
first_air_year = int(first_air_year)
|
| 70 |
+
if first_air_year == date:
|
| 71 |
+
return tid,slug
|
| 72 |
+
elif ismovie == 1:
|
| 73 |
+
return tid,slug
|
| 74 |
+
elif SC_FAST_SEARCH == "1":
|
| 75 |
+
return tid,slug
|
| 76 |
+
else:
|
| 77 |
+
print("Couldn't find anything")
|
| 78 |
+
|
| 79 |
+
|
| 80 |
+
def get_film(tid):
|
| 81 |
+
#Access the iframe
|
| 82 |
+
url = f'https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}'
|
| 83 |
+
response = requests.get(url, headers=headers)
|
| 84 |
+
iframe = BeautifulSoup(response.text, 'lxml')
|
| 85 |
+
#Get the link of iframe
|
| 86 |
+
iframe = iframe.find('iframe').get("src")
|
| 87 |
+
#Get the ID containted in the src of iframe
|
| 88 |
+
vixid = iframe.split("/embed/")[1].split("?")[0]
|
| 89 |
+
#Build the url with 1080p, to get the highest resolution
|
| 90 |
+
url = f'https://vixcloud.co/playlist/{vixid}'
|
| 91 |
+
return url
|
| 92 |
+
|
| 93 |
+
def get_season_episode_id(tid,slug,season,episode,version):
|
| 94 |
+
#Set some basic headers for the request
|
| 95 |
+
headers = {
|
| 96 |
+
'user-agent': "Mozilla/5.0 (Windows NT 10.10; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3",
|
| 97 |
+
'x-inertia': 'true',
|
| 98 |
+
#Version of streaming community
|
| 99 |
+
'x-inertia-version': version
|
| 100 |
+
}
|
| 101 |
+
#Get episode ID
|
| 102 |
+
response = requests.get(f'https://streamingcommunity.{SC_DOMAIN}/titles/{tid}-{slug}/stagione-{season}', headers=headers)
|
| 103 |
+
# Print the json got
|
| 104 |
+
json_response = response.json().get('props', {}).get('loadedSeason', {}).get('episodes', [])
|
| 105 |
+
for dict_episode in json_response:
|
| 106 |
+
if dict_episode['number'] == episode:
|
| 107 |
+
return dict_episode['id']
|
| 108 |
+
|
| 109 |
+
def get_episode_link(episode_id,tid):
|
| 110 |
+
#The parameters for the request
|
| 111 |
+
params = {
|
| 112 |
+
'episode_id': episode_id,
|
| 113 |
+
'next_episode': '1'
|
| 114 |
+
}
|
| 115 |
+
#Let's try to get the link from iframe source
|
| 116 |
+
# Make a request to get iframe source
|
| 117 |
+
response = requests.get(f"https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}", params=params)
|
| 118 |
+
|
| 119 |
+
# Parse response with BeautifulSoup to get iframe source
|
| 120 |
+
soup = BeautifulSoup(response.text, "lxml")
|
| 121 |
+
iframe = soup.find("iframe").get("src")
|
| 122 |
+
vixid = iframe.split("/embed/")[1].split("?")[0]
|
| 123 |
+
url = f"https://vixcloud.co/playlist/{vixid}"
|
| 124 |
+
return url
|
| 125 |
+
|
| 126 |
+
|
| 127 |
+
def streaming_community(imdb):
|
| 128 |
+
try:
|
| 129 |
+
general = is_movie(imdb)
|
| 130 |
+
ismovie = general[0]
|
| 131 |
+
imdb_id = general[1]
|
| 132 |
+
type = "StreamingCommunity"
|
| 133 |
+
if ismovie == 0 :
|
| 134 |
+
season = int(general[2])
|
| 135 |
+
episode = int(general[3])
|
| 136 |
+
#Check if fast search is enabled or disabled
|
| 137 |
+
if SC_FAST_SEARCH == "1":
|
| 138 |
+
if "tt" in imdb:
|
| 139 |
+
#Get showname
|
| 140 |
+
showname = get_info_imdb(imdb_id,ismovie,type)
|
| 141 |
+
date = None
|
| 142 |
+
else:
|
| 143 |
+
#I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled
|
| 144 |
+
date = None
|
| 145 |
+
#else just equals them
|
| 146 |
+
tmdba = imdb_id.replace("tmdb:","")
|
| 147 |
+
showname = get_info_tmdb(tmdba,ismovie,type)
|
| 148 |
+
elif SC_FAST_SEARCH == "0":
|
| 149 |
+
tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
|
| 150 |
+
showname,date = get_info_tmdb(tmdba,ismovie,type)
|
| 151 |
+
#HERE THE CASE IF IT IS A MOVIE
|
| 152 |
+
else:
|
| 153 |
+
if "tt" in imdb:
|
| 154 |
+
#Get showname
|
| 155 |
+
date = None
|
| 156 |
+
showname = get_info_imdb(imdb_id,ismovie,type)
|
| 157 |
+
else:
|
| 158 |
+
#I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled
|
| 159 |
+
#else just equals them
|
| 160 |
+
date = None
|
| 161 |
+
tmdba = imdb_id.replace("tmdb:","")
|
| 162 |
+
showname = get_info_tmdb(tmdba,ismovie,type)
|
| 163 |
+
|
| 164 |
+
showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
|
| 165 |
+
query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}'
|
| 166 |
+
tid,slug = search(query,date,ismovie)
|
| 167 |
+
if ismovie == 1:
|
| 168 |
+
#TID means temporaly ID
|
| 169 |
+
url = get_film(tid)
|
| 170 |
+
print(url)
|
| 171 |
+
return url
|
| 172 |
+
if ismovie == 0:
|
| 173 |
+
#Uid = URL ID
|
| 174 |
+
version = get_version()
|
| 175 |
+
episode_id = get_season_episode_id(tid,slug,season,episode,version)
|
| 176 |
+
url = get_episode_link(episode_id,tid)
|
| 177 |
+
print(url)
|
| 178 |
+
return url
|
| 179 |
+
except Exception as e:
|
| 180 |
+
print("Nope It failed")
|
| 181 |
+
|
| 182 |
+
streaming_community("tt0158552:3:2")
|