Mythus commited on
Commit
6cfa7c7
·
verified ·
1 Parent(s): 637ad83

Delete streamingcommunity.py

Browse files
Files changed (1) hide show
  1. streamingcommunity.py +0 -157
streamingcommunity.py DELETED
@@ -1,157 +0,0 @@
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
- #Get domain
12
- SC_DOMAIN= config.SC_DOMAIN
13
- SC_FAST_SEARCH = config.SC_FAST_SEARCH
14
-
15
- headers = {
16
- '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',
17
- 'Accept-Language': 'en-US,en;q=0.5'
18
- }
19
-
20
- #GET VERSION OF STREAMING COMMUNITY:
21
- def get_version():
22
- #Extract the version from the main page of the site
23
-
24
-
25
- try:
26
- base_url = f'https://streamingcommunity.{SC_DOMAIN}/richiedi-un-titolo'
27
- response = requests.get(base_url, headers=headers)
28
- #Soup the response
29
- soup = BeautifulSoup(response.text, "lxml")
30
-
31
- # Extract version
32
- version = json.loads(soup.find("div", {"id": "app"}).get("data-page"))['version']
33
- return version
34
- except:
35
- print("Couldn't find the version")
36
- version = "65e52dcf34d64173542cd2dc6b8bb75b"
37
- return version
38
-
39
- def search(query,n_season,ismovie):
40
- #Do a request to get the ID of serie/move and it's slug in the URL
41
- response = requests.get(query).json()
42
- for item in response['data']:
43
- tid = item['id']
44
- slug = item['slug']
45
- idk = item['seasons_count']
46
- if SC_FAST_SEARCH == "0":
47
- if ismovie == 0:
48
- seasons_count = item['seasons_count']
49
- if seasons_count == n_season:
50
- return tid,slug
51
- elif ismovie == 1:
52
- return tid,slug
53
- elif SC_FAST_SEARCH == "1":
54
- return tid,slug
55
-
56
-
57
- def get_film(tid):
58
- #Access the iframe
59
- url = f'https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}'
60
- response = requests.get(url, headers=headers)
61
- iframe = BeautifulSoup(response.text, 'lxml')
62
- #Get the link of iframe
63
- iframe = iframe.find('iframe').get("src")
64
- #Get the ID containted in the src of iframe
65
- vixid = iframe.split("/embed/")[1].split("?")[0]
66
- #Build the url with 1080p, to get the highest resolution
67
- url = f'https://vixcloud.co/playlist/{vixid}'
68
- return url
69
-
70
- def get_season_episode_id(tid,slug,season,episode,version):
71
- #Set some basic headers for the request
72
- headers = {
73
- '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",
74
- 'x-inertia': 'true',
75
- #Version of streaming community
76
- 'x-inertia-version': version
77
- }
78
- #Get episode ID
79
- response = requests.get(f'https://streamingcommunity.{SC_DOMAIN}/titles/{tid}-{slug}/stagione-{season}', headers=headers)
80
- # Print the json got
81
- json_response = response.json().get('props', {}).get('loadedSeason', {}).get('episodes', [])
82
- for dict_episode in json_response:
83
- if dict_episode['number'] == episode:
84
- return dict_episode['id']
85
-
86
- def get_episode_link(episode_id,tid):
87
- #The parameters for the request
88
- params = {
89
- 'episode_id': episode_id,
90
- 'next_episode': '1'
91
- }
92
- #Let's try to get the link from iframe source
93
- # Make a request to get iframe source
94
- response = requests.get(f"https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}", params=params)
95
-
96
- # Parse response with BeautifulSoup to get iframe source
97
- soup = BeautifulSoup(response.text, "lxml")
98
- iframe = soup.find("iframe").get("src")
99
- vixid = iframe.split("/embed/")[1].split("?")[0]
100
- url = f"https://vixcloud.co/playlist/{vixid}"
101
- return url
102
-
103
-
104
- def streaming_community(imdb):
105
- try:
106
- general = is_movie(imdb)
107
- ismovie = general[0]
108
- imdb_id = general[1]
109
- type = "StreamingCommunity"
110
- if ismovie == 0 :
111
- season = int(general[2])
112
- episode = int(general[3])
113
- #Check if fast search is enabled or disabled
114
- if SC_FAST_SEARCH == "1":
115
- if "tt" in imdb:
116
- #Get showname
117
- showname = get_info_imdb(imdb_id,ismovie,type)
118
- n_season = None
119
- else:
120
- #I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled
121
- n_season = None
122
- #else just equals them
123
- tmdba = imdb_id.replace("tmdb:","")
124
- showname = get_info_tmdb(tmdba,ismovie,type)
125
- elif SC_FAST_SEARCH == "0":
126
- tmdba = get_TMDb_id_from_IMDb_id(imdb_id)
127
- showname,n_season = get_info_tmdb(tmdba,ismovie,type)
128
- #HERE THE CASE IF IT IS A MOVIE
129
- else:
130
- if "tt" in imdb:
131
- #Get showname
132
- n_season = None
133
- showname = get_info_imdb(imdb_id,ismovie,type)
134
- else:
135
- #I just set n season to None to avoid bugs, but it is not needed if Fast search is enabled
136
- #else just equals them
137
- n_season = None
138
- tmdba = imdb_id.replace("tmdb:","")
139
- showname = get_info_tmdb(tmdba,ismovie,type)
140
-
141
- showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
142
- query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}'
143
- tid,slug = search(query,n_season,ismovie)
144
- if ismovie == 1:
145
- #TID means temporaly ID
146
- url = get_film(tid)
147
- print(url)
148
- return url
149
- if ismovie == 0:
150
- #Uid = URL ID
151
- version = get_version()
152
- episode_id = get_season_episode_id(tid,slug,season,episode,version)
153
- url = get_episode_link(episode_id,tid)
154
- print(url)
155
- return url
156
- except Exception as e:
157
- print("Nope It failed")