Mythus commited on
Commit
f1707a6
·
verified ·
1 Parent(s): 388f2ec

Update streamingcommunity.py

Browse files
Files changed (1) hide show
  1. streamingcommunity.py +70 -30
streamingcommunity.py CHANGED
@@ -9,6 +9,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
@@ -52,32 +54,31 @@ def search(query,date,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)
@@ -86,9 +87,25 @@ def get_film(tid):
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
@@ -106,7 +123,7 @@ def get_season_episode_id(tid,slug,season,episode,version):
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,
@@ -120,8 +137,31 @@ def get_episode_link(episode_id,tid):
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):
@@ -164,17 +204,17 @@ def streaming_community(imdb):
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")
 
9
  import config
10
  import json
11
  import re
12
+ from urllib.parse import urlparse, parse_qs
13
+
14
  #Get domain
15
  SC_DOMAIN= config.SC_DOMAIN
16
  SC_FAST_SEARCH = config.SC_FAST_SEARCH
 
54
  #Added a Check to see if the result is what it is supposed to be
55
  if SC_FAST_SEARCH == "0":
56
  if ismovie == 0:
57
+ #
58
+ response = requests.get ( f'https://streamingcommunity.boston/titles/{tid}-{slug}')
59
+ pattern = r'<div[^>]*class="features"[^>]*>.*?<span[^>]*>(.*?)<\/span>'
60
+ match = re.search(pattern, response.text)
61
+ print(match.group(1).split("-")[0])
62
+ first_air_year = match.group(1).split("-")[0]
63
+ date = int(date)
64
+ first_air_year = int(first_air_year)
65
+ if first_air_year == date:
66
+ return tid,slug
 
 
 
 
 
 
 
67
  elif ismovie == 1:
68
  return tid,slug
69
  elif SC_FAST_SEARCH == "1":
70
+ return tid,slug
71
  else:
72
  print("Couldn't find anything")
73
 
74
 
75
+ def get_film(tid,version):
76
+ headers = {
77
+ 'user-agent': "Mozilla/5.0 (Windows NT 10.10; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537",
78
+ 'x-inertia': 'true',
79
+ #Version of streaming community
80
+ 'x-inertia-version': version
81
+ }
82
  #Access the iframe
83
  url = f'https://streamingcommunity.{SC_DOMAIN}/iframe/{tid}'
84
  response = requests.get(url, headers=headers)
 
87
  iframe = iframe.find('iframe').get("src")
88
  #Get the ID containted in the src of iframe
89
  vixid = iframe.split("/embed/")[1].split("?")[0]
90
+ parsed_url = urlparse(iframe)
91
+ query_params = parse_qs(parsed_url.query)
92
+ #Get real token and expires by looking at the page in the iframe, vixcloud/embed
93
+ resp = requests.get(iframe, headers = headers)
94
+ soup= BeautifulSoup(resp.text, "lxml")
95
+ script = soup.find("body").find("script").text
96
+ token = re.search(r"'token':\s*'(\w+)'", script).group(1)
97
+ expires = re.search(r"'expires':\s*'(\d+)'", script).group(1)
98
+ quality = re.search(r'"quality":(\d+)', script).group(1)
99
+ #Example url https://vixcloud.co/playlist/231315?b=1&token=bce060eec3dc9d1965a5d258dc78c964&expires=1728995040&rendition=1080p
100
+ url = f'https://vixcloud.co/playlist/{vixid}?token={token}&expires={expires}'
101
+ if 'canPlayFHD' in query_params:
102
+ canPlayFHD = 'h=1'
103
+ url += "&h=1"
104
+ if 'b' in query_params:
105
+ b = 'b=1'
106
+ url += "&b=1"
107
+ url720 = f'https://vixcloud.co/playlist/{vixid}'
108
+ return url,url720,quality,
109
 
110
  def get_season_episode_id(tid,slug,season,episode,version):
111
  #Set some basic headers for the request
 
123
  if dict_episode['number'] == episode:
124
  return dict_episode['id']
125
 
126
+ def get_episode_link(episode_id,tid,version):
127
  #The parameters for the request
128
  params = {
129
  'episode_id': episode_id,
 
137
  soup = BeautifulSoup(response.text, "lxml")
138
  iframe = soup.find("iframe").get("src")
139
  vixid = iframe.split("/embed/")[1].split("?")[0]
140
+ headers = {
141
+ 'user-agent': "Mozilla/5.0 (Windows NT 10.10; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537",
142
+ 'x-inertia': 'true',
143
+ #Version of streaming community
144
+ 'x-inertia-version': version
145
+ }
146
+ parsed_url = urlparse(iframe)
147
+ query_params = parse_qs(parsed_url.query)
148
+ #Get real token and expires by looking at the page in the iframe, vixcloud/embed
149
+ resp = requests.get(iframe, headers = headers)
150
+ soup= BeautifulSoup(resp.text, "lxml")
151
+ script = soup.find("body").find("script").text
152
+ token = re.search(r"'token':\s*'(\w+)'", script).group(1)
153
+ expires = re.search(r"'expires':\s*'(\d+)'", script).group(1)
154
+ quality = re.search(r'"quality":(\d+)', script).group(1)
155
+ #Example url https://vixcloud.co/playlist/231315?b=1&token=bce060eec3dc9d1965a5d258dc78c964&expires=1728995040&rendition=1080p
156
+ url = f'https://vixcloud.co/playlist/{vixid}?token={token}&expires={expires}'
157
+ if 'canPlayFHD' in query_params:
158
+ canPlayFHD = 'h=1'
159
+ url += "&h=1"
160
+ if 'b' in query_params:
161
+ b = 'b=1'
162
+ url += "&b=1"
163
+ url720 = f'https://vixcloud.co/playlist/{vixid}'
164
+ return url,url720,quality
165
 
166
 
167
  def streaming_community(imdb):
 
204
  showname = showname.replace(" ", "+").replace("–", "+").replace("—","+")
205
  query = f'https://streamingcommunity.{SC_DOMAIN}/api/search?q={showname}'
206
  tid,slug = search(query,date,ismovie)
207
+ version = get_version()
208
  if ismovie == 1:
209
  #TID means temporaly ID
210
+ url,url720,quality = get_film(tid,version)
211
  print(url)
212
+ return url,url720,quality
213
  if ismovie == 0:
214
  #Uid = URL ID
 
215
  episode_id = get_season_episode_id(tid,slug,season,episode,version)
216
+ url,url720,quality = get_episode_link(episode_id,tid,version)
217
  print(url)
218
+ return url,url720,quality
219
  except Exception as e:
220
  print("Nope It failed")