MammaMia-Urlo commited on
Commit
e07bf28
·
verified ·
1 Parent(s): e57824f

Upload 9 files

Browse files
Files changed (9) hide show
  1. config.json +21 -0
  2. config.py +18 -0
  3. convert.py +15 -0
  4. convert_date.py +39 -0
  5. filmpertutti.py +120 -0
  6. info.py +42 -0
  7. loadenv.py +13 -0
  8. run.py +67 -0
  9. streamingcommunity.py +105 -0
config.json ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "Siti": {
3
+ "StreamingCommunity": {
4
+ "enabled": "1",
5
+ "domain": "boston"
6
+ },
7
+ "Filmpertutti": {
8
+ "enabled": "1",
9
+ "domain": "casino"
10
+ },
11
+ "Tuttifilm":{
12
+ "enabled": "1",
13
+ "domain": "bond",
14
+ "fast_search": "0"
15
+ }
16
+ },
17
+ "General":{
18
+ "load_env": "1"
19
+ }
20
+ }
21
+
config.py ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #LOAD THE CONFIG
2
+ import json
3
+
4
+ # Open the configuration file
5
+ with open('config.json') as f:
6
+ # Load JSON data from file
7
+ config = json.load(f)
8
+
9
+ # Accessing SC_DOMAIN
10
+ SITE = config["Siti"]
11
+ FT_DOMAIN = SITE["Filmpertutti"]['domain']
12
+ SC_DOMAIN = SITE["StreamingCommunity"]['domain']
13
+ TF_DOMAIN = SITE["Filmpertutti"]['enabled']
14
+ FILMPERTUTTI = SITE["Filmpertutti"]['enabled']
15
+ STREAMINGCOMMUNITY = SITE["StreamingCommunity"]['enabled']
16
+ #General
17
+ GENERAL = config['General']
18
+ dotenv = GENERAL["load_env"]
convert.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+ from tmdbv3api import TMDb, Movie, TV
3
+ from loadenv import load_env
4
+ TMDB_KEY= load_env()
5
+ def get_TMDb_id_from_IMDb_id(imdb_id):
6
+ response = requests.get(f'https://api.themoviedb.org/3/find/{imdb_id}',
7
+ params={'external_source': 'imdb_id', 'api_key': f'{TMDB_KEY}'})
8
+ tmbda = response.json()
9
+ if tmbda['movie_results']:
10
+ return tmbda['movie_results'][0]['id']
11
+ elif tmbda['tv_results']:
12
+ print(tmbda['tv_results'][0]['id'])
13
+ return tmbda['tv_results'][0]['id']
14
+ else:
15
+ return None
convert_date.py ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ def convert_US_date(date):
3
+ us_data = next((country_data for country_data in date['results'] if country_data["iso_3166_1"] == "US"), None)
4
+ if us_data:
5
+ us_release_dates_type_3 = [rd for rd in us_data['release_dates'] if rd['type'] == 3]
6
+ # Sort the list of release dates and get the latest
7
+ us_release_dates_type_3.sort(key = lambda x: x['release_date'], reverse=True)
8
+ if len(us_release_dates_type_3) > 0:
9
+ latest_release_date = us_release_dates_type_3[0]['release_date']
10
+ date = latest_release_date.split('T')[0]
11
+ print('Latest US theatrical release date:', date)
12
+ return date
13
+ else:
14
+ us_release_dates_type_4 = [rd for rd in us_data['release_dates'] if rd['type'] == 4]
15
+ us_release_dates_type_4.sort(key = lambda x: x['release_date'], reverse=True)
16
+ if len(us_release_dates_type_4) > 0:
17
+ latest_release_date = us_release_dates_type_4[0]['release_date']
18
+ date = latest_release_date.split('T')[0]
19
+ print('Latest US theatrical release date (type 4):', date)
20
+ return date
21
+ def convert_IT_date(date):
22
+ it_data = next((country_data for country_data in date['results'] if country_data["iso_3166_1"] == "IT"), None)
23
+ if it_data:
24
+ it_release_dates_type_3 = [rd for rd in it_data['release_dates'] if rd['type'] == 3]
25
+ # Sort the list of release dates and get the latest
26
+ it_release_dates_type_3.sort(key = lambda x: x['release_date'], reverse=True)
27
+ if len(it_release_dates_type_3) > 0:
28
+ latest_release_date = it_release_dates_type_3[0]['release_date']
29
+ date = latest_release_date.split('T')[0]
30
+ print('Latest IT theatrical release date:', date)
31
+ return date
32
+ else:
33
+ it_release_dates_type_4 = [rd for rd in it_data['release_dates'] if rd['type'] == 4]
34
+ it_release_dates_type_4.sort(key = lambda x: x['release_date'], reverse=True)
35
+ if len(it_release_dates_type_4) > 0:
36
+ latest_release_date = it_release_dates_type_4[0]['release_date']
37
+ date = latest_release_date.split('T')[0]
38
+ print('Latest IT theatrical release date (type 4):', date)
39
+ return date
filmpertutti.py ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ from tmdbv3api import TMDb, Movie, TV
3
+ import requests
4
+ from bs4 import BeautifulSoup,SoupStrainer
5
+ import string
6
+ import re
7
+ from datetime import datetime
8
+ import dateparser
9
+ from convert import get_TMDb_id_from_IMDb_id
10
+ from info import get_info, is_movie
11
+ from convert_date import convert_US_date
12
+ import logging
13
+ import config
14
+
15
+ FT_DOMAIN = config.FT_DOMAIN
16
+
17
+ #Some basic headers
18
+ headers = {
19
+ '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',
20
+ 'Accept-Language': 'en-US,en;q=0.5'
21
+ }
22
+ #Map months to check if date = date
23
+ month_mapping = {
24
+ 'Jan': 'Gennaio', 'Feb': 'Febbraio', 'Mar': 'Marzo', 'Apr': 'Aprile',
25
+ 'May': 'Maggio', 'Jun': 'Giugno', 'Jul': 'Luglio', 'Aug': 'Agosto',
26
+ 'Sep': 'Settembre', 'Oct': 'Ottobre', 'Nov': 'Novembre', 'Dec': 'Dicembre'
27
+ }
28
+
29
+ def search(query,date):
30
+ response = requests.get(query).json()
31
+ #Get link tid of every item and then open the link to see if the date = date
32
+ for json in response:
33
+ link = json['link']
34
+ tid = json['id']
35
+ series_response = requests.get(link, headers=headers)
36
+ series_soup = BeautifulSoup(series_response.text, 'lxml')
37
+ release_span = series_soup.find('span', class_='released')
38
+ if release_span:
39
+ if release_span.text != "Data di uscita: N/A":
40
+ date_string = release_span.text.split(': ')[-1] # Get the date part
41
+ for eng, ita in month_mapping.items():
42
+ date_string = re.sub(rf'\b{eng}\b', ita, date_string)
43
+
44
+ # Swap to YY-MM-DD formatting using dateparser
45
+ release_date = dateparser.parse(date_string, languages=['it']).strftime("%Y-%m-%d")
46
+ if release_date == date:
47
+ url = link
48
+ tid = tid
49
+ break
50
+ return url, tid
51
+
52
+ def get_episode_link(season,episode,tid,url):
53
+ #Get the link from where we have to obtain mixdrop link
54
+ tlink = f'{url}?show_video=true&post_id={tid}&season_id={season-1}&episode_id={episode-1}'
55
+ return tlink
56
+
57
+
58
+ def get_film(url):
59
+ #Get the link from where we have to obtain mixdrop link
60
+ tlink = url + "?show_video=true"
61
+ return tlink
62
+
63
+ def get_real_link(tlink):
64
+ #Some basic code to get the mixdrop link
65
+ page = requests.get(tlink, headers=headers)
66
+ soup = BeautifulSoup(page.content, features="lxml",parse_only=SoupStrainer('iframe'))
67
+ iframe_src = soup.find('iframe')['src']
68
+
69
+ iframe_page = requests.get(iframe_src, headers=headers)
70
+ iframe_soup = BeautifulSoup(iframe_page.content, features="lxml")
71
+
72
+ mega_button = iframe_soup.find('div', attrs={'class': 'megaButton', 'rel': 'nofollow'}, string='MIXDROP')
73
+ if mega_button:
74
+ real_link = mega_button.get('meta-link')
75
+ return real_link
76
+
77
+ def get_true_link(real_link):
78
+ response = requests.get(real_link, headers=headers)
79
+ [s1, s2] = re.search(r"\}\('(.+)',.+,'(.+)'\.split", response.text).group(1, 2)
80
+ schema = s1.split(";")[2][5:-1]
81
+ terms = s2.split("|")
82
+ charset = string.digits + string.ascii_letters
83
+ d = dict()
84
+ for i in range(len(terms)):
85
+ d[charset[i]] = terms[i] or charset[i]
86
+ s = 'https:'
87
+ for c in schema:
88
+ s += d[c] if c in d else c
89
+ return s
90
+
91
+ def filmpertutti(imdb):
92
+ general = is_movie(imdb)
93
+ ismovie = general[0]
94
+ imdb_id = general[1]
95
+ if ismovie == 0 :
96
+ season = int(general[2])
97
+ episode = int(general[3])
98
+ tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
99
+ type = "Filmpertutti"
100
+ showname,date = get_info(tmdba,ismovie,type)
101
+ showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
102
+ #Build the query
103
+ query = f'https://filmpertutti.{FT_DOMAIN}/wp-json/wp/v2/posts?search={showname}&page=1&_fields=link,id'
104
+ url,tid = search(query,date)
105
+ if ismovie == 0:
106
+ episode_link = get_episode_link(season,episode,tid,url)
107
+ #Let's get mixdrop link
108
+ real_link = get_real_link(episode_link)
109
+ #let's get delivery link, streaming link
110
+ streaming_link = get_true_link(real_link)
111
+ print(streaming_link)
112
+ return streaming_link
113
+ elif ismovie == 1:
114
+ film_link = get_film(url)
115
+ #Let's get mixdrop link
116
+ real_link = get_real_link(film_link)
117
+ #let's get delivery link, streaming link
118
+ streaming_link = get_true_link(real_link)
119
+ print(streaming_link)
120
+ return streaming_link
info.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ TMDB_KEY= load_env()
5
+
6
+ def get_info(tmbda,ismovie,type):
7
+ tmdb = TMDb()
8
+ tmdb.api_key = f'{TMDB_KEY}'
9
+ tmdb.language = 'it'
10
+ if ismovie == 0:
11
+ tv = TV()
12
+ show= tv.details(tmbda)
13
+ showname = show.name
14
+ if type == "Filmpertutti":
15
+ date= show.first_air_date
16
+ elif type == "StreamingCommunity":
17
+ date = show.last_air_date
18
+ print("Real date",date)
19
+ else:
20
+ movie = Movie()
21
+ show= movie.details(tmbda)
22
+ showname= show.title
23
+ #Get all release dates
24
+ date = show.release_dates
25
+ if type == "Filmpertutti":
26
+ #GET US RELEASE DATE because filmpertutti somewhy uses US release date
27
+ date = convert_US_date(date)
28
+ return showname,date
29
+
30
+
31
+ def is_movie(imdb_id):
32
+ if "tmdb:" in imdb_id:
33
+ imdb_id = imdb_id.replace("tmdb:","")
34
+ if ":" in imdb_id:
35
+ season = imdb_id.split(":")[1]
36
+ episode = imdb_id[-1]
37
+ ismovie = 0
38
+ imdb_id = imdb_id.split(":")[0]
39
+ return ismovie,imdb_id,season,episode
40
+ else:
41
+ ismovie = 1
42
+ return ismovie,imdb_id
loadenv.py ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import config
3
+
4
+ dotenv = config.dotenv
5
+ #You need to keep dotenv disabled on remote servers
6
+ if dotenv == "1":
7
+ from dotenv import load_dotenv
8
+ load_dotenv(".env")
9
+
10
+
11
+ def load_env():
12
+ TMDB_KEY = os.getenv('TMDB_KEY')
13
+ return TMDB_KEY
run.py ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from flask import Flask, jsonify, abort
2
+ from filmpertutti import filmpertutti
3
+ from streamingcommunity import streaming_community
4
+ import json
5
+ import config
6
+
7
+ FILMPERTUTTI = config.FILMPERTUTTI
8
+ STREAMINGCOMMUNITY = config.STREAMINGCOMMUNITY
9
+
10
+
11
+
12
+ app = Flask(__name__)
13
+
14
+ MANIFEST = {
15
+ "id": "org.stremio.mammamia",
16
+ "version": "1.0.0",
17
+ "catalogs": [],
18
+ "resources": ["stream"],
19
+ "types": ["movie", "series"],
20
+ "name": "Mamma Mia",
21
+ "description": "Addon providing HTTPS Stream for Italian Movies/Series",
22
+ "logo":"https://creazilla-store.fra1.digitaloceanspaces.com/emojis/49647/pizza-emoji-clipart-md.png"
23
+ }
24
+
25
+ def respond_with(data):
26
+ resp = jsonify(data)
27
+ resp.headers['Access-Control-Allow-Origin'] = '*'
28
+ resp.headers['Access-Control-Allow-Headers'] = '*'
29
+ return resp
30
+
31
+ @app.route('/manifest.json')
32
+ def addon_manifest():
33
+ return respond_with(MANIFEST)
34
+
35
+ @app.route('/')
36
+ def root():
37
+ 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"
38
+
39
+
40
+
41
+ @app.route('/stream/<type>/<id>.json')
42
+ def addon_stream(type, id):
43
+ if type not in MANIFEST['types']:
44
+ abort(404)
45
+ streams = {'streams': []}
46
+ if STREAMINGCOMMUNITY == "1":
47
+ url_streaming_community = streaming_community(id)
48
+ print(url_streaming_community)
49
+ if url_streaming_community is not None:
50
+ streams['streams'].append({'title': 'StreamingCommunity 1080p', 'url': f'{url_streaming_community}?rendition=1080p'})
51
+ streams['streams'].append({'title': 'StreamingCommunity 720p', 'url': f'{url_streaming_community}?rendition=720p'})
52
+
53
+ # If FILMPERTUTTI == 1, scrape that site
54
+ if FILMPERTUTTI == "1":
55
+ url_filmpertutti = filmpertutti(id)
56
+ if url_filmpertutti is not None:
57
+ streams['streams'].append({'title': 'Filmpertutti', 'url': url_filmpertutti})
58
+
59
+ # If no streams were added, abort with a 404 error
60
+ if not streams['streams']:
61
+ abort(404)
62
+
63
+ return respond_with(streams)
64
+
65
+
66
+ if __name__ == '__main__':
67
+ app.run(host='0.0.0.0', port=8080)
streamingcommunity.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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, is_movie
9
+ import config
10
+ #Get domain
11
+ SC_DOMAIN= config.SC_DOMAIN
12
+
13
+ headers = {
14
+ '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',
15
+ 'Accept-Language': 'en-US,en;q=0.5'
16
+ }
17
+
18
+ def search(query):
19
+ #Do a request to get the ID of serie/move and it's slug in the URL
20
+ response = requests.get(query).json()
21
+ for item in response['data']:
22
+ tid = item['id']
23
+ slug = item['slug']
24
+ return tid,slug
25
+
26
+
27
+ def get_film(tid):
28
+ #Access the iframe
29
+ url = f'https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}'
30
+ response = requests.get(url, headers=headers)
31
+ iframe = BeautifulSoup(response.text, 'lxml')
32
+ #Get the link of iframe
33
+ iframe = iframe.find('iframe').get("src")
34
+ #Get the ID containted in the src of iframe
35
+ vixid = iframe.split("/embed/")[1].split("?")[0]
36
+ #Build the url with 1080p, to get the highest resolution
37
+ url = f'https://vixcloud.co/playlist/{vixid}'
38
+ return url
39
+
40
+ def get_season_episode_id(tid,slug,season,episode):
41
+ #Set some basic headers for the request
42
+ headers = {
43
+ '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",
44
+ 'x-inertia': 'true',
45
+ #Version of streaming community
46
+ 'x-inertia-version': 'c1bdf1189cb68fca28151c8e909bd053'
47
+ }
48
+ #Get episode ID
49
+ response = requests.get(f'https://streamingcommunity.{SC_DOMAIN}/titles/{tid}-{slug}/stagione-{season}', headers=headers)
50
+ # Print the json got
51
+ json_response = response.json().get('props', {}).get('loadedSeason', {}).get('episodes', [])
52
+ for dict_episode in json_response:
53
+ if dict_episode['number'] == episode:
54
+ return dict_episode['id']
55
+
56
+ def get_episode_link(episode_id,tid):
57
+ #The parameters for the request
58
+ params = {
59
+ 'episode_id': episode_id,
60
+ 'next_episode': '1'
61
+ }
62
+ #Let's try to get the link from iframe source
63
+ # Make a request to get iframe source
64
+ response = requests.get(f"https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}", params=params)
65
+
66
+ # Parse response with BeautifulSoup to get iframe source
67
+ soup = BeautifulSoup(response.text, "lxml")
68
+ iframe = soup.find("iframe").get("src")
69
+ vixid = iframe.split("/embed/")[1].split("?")[0]
70
+ url = f"https://vixcloud.co/playlist/{vixid}"
71
+ return url
72
+
73
+
74
+ def streaming_community(imdb):
75
+ general = is_movie(imdb)
76
+ ismovie = general[0]
77
+ imdb_id = general[1]
78
+ if ismovie == 0 :
79
+ season = int(general[2])
80
+ episode = int(general[3])
81
+ if "tt" in imdb:
82
+ #If it is a imbd then conver it to tmbd
83
+ tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
84
+ showname = requests.get(f'https://v3.sg.media-imdb.com/suggestion/a/{imdb_id}.json')
85
+ showname = showname.json()
86
+ showname = showname['d'][-1]['l']
87
+ else:
88
+ #else just equals them
89
+ tmdba = imdb_id.replace("tmdb:","")
90
+ type = "StreamingCommunity"
91
+ showname = get_info(tmdba,ismovie,type)
92
+ showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
93
+ query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}'
94
+ tid,slug = search(query)
95
+ if ismovie == 1:
96
+ #TID means temporaly ID
97
+ url = get_film(tid)
98
+ print(url)
99
+ return url
100
+ if ismovie == 0:
101
+ #Uid = URL ID
102
+ episode_id = get_season_episode_id(tid,slug,season,episode)
103
+ url = get_episode_link(episode_id,tid)
104
+ print(url)
105
+ return url