thejagstudio commited on
Commit
af65ed8
·
verified ·
1 Parent(s): e2e2e1d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +360 -360
app.py CHANGED
@@ -1,360 +1,360 @@
1
- from flask import Flask, render_template, redirect, url_for
2
- import requests
3
- from bs4 import BeautifulSoup
4
- from base64 import b64decode
5
- from Crypto.Cipher import AES
6
- from Crypto.Util.Padding import unpad
7
- from selenium import webdriver
8
- from selenium.webdriver.chrome.service import Service
9
- from selenium.webdriver.chrome.options import Options
10
- from selenium.webdriver.common.by import By
11
- from selenium.webdriver.support.ui import WebDriverWait
12
- from selenium.webdriver.support import expected_conditions as EC
13
- from webdriver_manager.chrome import ChromeDriverManager
14
- import time
15
-
16
- app = Flask(__name__, static_url_path='/static', static_folder='static')
17
-
18
-
19
- def create_driver():
20
- """Create and configure Chrome WebDriver"""
21
- chrome_options = Options()
22
- chrome_options.add_argument("--headless") # Run in background
23
- chrome_options.add_argument("--no-sandbox")
24
- chrome_options.add_argument("--disable-dev-shm-usage")
25
- chrome_options.add_argument("--disable-gpu")
26
- chrome_options.add_argument("--window-size=1920,1080")
27
- chrome_options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
28
-
29
- service = Service(ChromeDriverManager().install())
30
- driver = webdriver.Chrome(service=service, options=chrome_options)
31
- return driver
32
-
33
-
34
- def homeFetch():
35
- driver = create_driver()
36
- try:
37
- driver.get('https://www.shemaroome.com/')
38
- # Wait for the page to load
39
- WebDriverWait(driver, 10).until(
40
- EC.presence_of_element_located((By.CLASS_NAME, "masthead-card"))
41
- )
42
-
43
- # Get page source and parse with BeautifulSoup
44
- page_source = driver.page_source
45
- soup = BeautifulSoup(page_source, features="html5lib")
46
-
47
- # fetches all slider images
48
- slider = soup.find_all("div", {"class": "masthead-card"})
49
- sliderImages = []
50
- for element in slider:
51
- tempImage = element.find("img")
52
- if tempImage:
53
- sliderImages.append(tempImage['src'])
54
-
55
- # fetches all catagories with images
56
- catagory = soup.find_all(
57
- "div", {"class": "float-left w-100 slick-container slick-gap"})
58
- catagoryObject = []
59
- for element in catagory:
60
- tempTitle = element.find("h2")
61
- if tempTitle != None:
62
- tempTitle = str(tempTitle).split(">")[1].split("<")[0]
63
- tempImages = element.find_all("a")
64
- tempImagesArr = []
65
- for image in tempImages:
66
- try:
67
- imgLink = image.find("img")["src"]
68
- except:
69
- imgLink = ""
70
- tempImagesArr.append([image["href"], imgLink])
71
- catagoryObject.append([tempTitle, tempImagesArr])
72
-
73
- return sliderImages, catagoryObject
74
-
75
- finally:
76
- driver.quit()
77
-
78
-
79
- def movieDetailFetch(title):
80
- driver = create_driver()
81
- try:
82
- driver.get('https://www.shemaroome.com/' + title)
83
- # Wait for the main content to load
84
- WebDriverWait(driver, 10).until(
85
- EC.presence_of_element_located((By.CLASS_NAME, "main-content"))
86
- )
87
-
88
- page_source = driver.page_source
89
- soup = BeautifulSoup(page_source, features="html5lib")
90
-
91
- pathList = []
92
- pathsContainer = soup.find("section", {"class": "main-content"})
93
- if pathsContainer and pathsContainer.find("ul"):
94
- paths = pathsContainer.find("ul").find_all("li")
95
- for path in paths:
96
- if path.find("a"):
97
- pathList.append([path.find("a")["href"], path.text.strip()])
98
-
99
- title_element = soup.find(
100
- "h1", {
101
- "class":
102
- "float-left w-100 app-color1 font-black margin-bottom-10 section-title2"
103
- })
104
- title = title_element.text if title_element else ""
105
-
106
- catagoriesArr = []
107
- catagories = soup.find_all(
108
- "li", {"class": "float-left font-regular app-color5 app-color1"})
109
- for catagory in catagories:
110
- catagoriesArr.append(catagory.text.strip())
111
-
112
- movieDataArr = []
113
- Synopsis = soup.find_all(
114
- "p", {"class": "float-left w-100 app-color1 font-regular"})
115
- for data in Synopsis:
116
- movieDataArr.append(data.text.strip())
117
-
118
- youMayLikeArr = []
119
- youMayLikeContainer = soup.find(
120
- "div", {"class": "float-left w-100 app-slick-slider-container"})
121
- if youMayLikeContainer:
122
- youMayLike = youMayLikeContainer.find_all("a")
123
- for data in youMayLike:
124
- img_element = data.find("img")
125
- if img_element:
126
- youMayLikeArr.append([data["href"], img_element["src"]])
127
-
128
- return {
129
- "pathList": pathList,
130
- "title": title,
131
- "catagoriesArr": catagoriesArr,
132
- "movieDataArr": movieDataArr,
133
- "youMayLikeArr": youMayLikeArr
134
- }
135
-
136
- finally:
137
- driver.quit()
138
-
139
-
140
- def showDetailFetch(title):
141
- driver = create_driver()
142
- try:
143
- driver.get('https://www.shemaroome.com/' + title)
144
- # Wait for the main content to load
145
- WebDriverWait(driver, 10).until(
146
- EC.presence_of_element_located((By.CLASS_NAME, "main-content"))
147
- )
148
-
149
- page_source = driver.page_source
150
- soup = BeautifulSoup(page_source, features="html5lib")
151
-
152
- pathsContainer = soup.find("section", {"class": "main-content"})
153
- pathList = []
154
- if pathsContainer and pathsContainer.find("ul"):
155
- paths = pathsContainer.find("ul").find_all("li")
156
- for path in paths:
157
- if path.find("a"):
158
- pathList.append([path.find("a")["href"], path.text.strip()])
159
-
160
- title_element = soup.find(
161
- "h1", {
162
- "class":
163
- "float-left w-100 app-color1 font-black margin-bottom-10 section-title2"
164
- })
165
- title = title_element.text.strip() if title_element else ""
166
-
167
- catagories = soup.find_all("li",
168
- {"class": "float-left font-regular app-color5"})
169
- catagoriesArr = []
170
- for catagory in catagories:
171
- catagoriesArr.append(catagory.text.strip())
172
-
173
- Synopsis = soup.find_all(
174
- "p", {"class": "float-left w-100 app-color1 font-regular"})
175
- movieDataArr = []
176
- for data in Synopsis:
177
- movieDataArr.append(data.text.strip())
178
-
179
- episodesArr = []
180
- episodeContainers = soup.find_all(
181
- "div", {"class": "float-left w-100 app-slick-slider-container"})
182
- if len(episodeContainers) > 0:
183
- episodes = episodeContainers[0].find_all("a")
184
- for episode in episodes:
185
- img_element = episode.find("img")
186
- if img_element:
187
- episodesArr.append([episode["href"], img_element["src"]])
188
-
189
- youMayLikeArr = []
190
- if len(episodeContainers) > 1:
191
- youMayLike = episodeContainers[1].find_all("a")
192
- for data in youMayLike:
193
- img_element = data.find("img")
194
- if img_element:
195
- youMayLikeArr.append([data["href"], img_element["src"]])
196
-
197
- poster = ""
198
- poster_element = soup.find(
199
- "div", {
200
- "class": "player_section w-100 embed-responsive embed-responsive-16by9"
201
- })
202
- if poster_element:
203
- img_element = poster_element.find("img")
204
- if img_element:
205
- poster = img_element["src"]
206
-
207
- return {
208
- "pathList": pathList,
209
- "title": title,
210
- "catagoriesArr": catagoriesArr,
211
- "movieDataArr": movieDataArr,
212
- "episodesArr": episodesArr,
213
- "youMayLikeArr": youMayLikeArr,
214
- "poster": poster
215
- }
216
-
217
- finally:
218
- driver.quit()
219
-
220
-
221
- def decryptLink(encrypted, key, type):
222
- key = b64decode(key)
223
- iv = b'0000000000000000'
224
- ct = b64decode(encrypted)
225
- cipher = AES.new(key, AES.MODE_CBC, iv)
226
- pt = unpad(cipher.decrypt(ct), AES.block_size)
227
- link = pt.decode()
228
- tempUrl = "https://d1fcqrzxghru70.cloudfront.net/" + \
229
- link.split("cloudfront.net/")[1]
230
- response = requests.request("GET", tempUrl)
231
- tempArr = response.text.split("RESOLUTION=")
232
- tempArr.pop(0)
233
- tempUrl2 = '/'.join(tempUrl.split("/")[:-1])
234
- bestResolution = 0
235
- for i in range(len(tempArr)):
236
- if int(tempArr[i].split("x")[0]) > int(
237
- tempArr[bestResolution].split("x")[0]):
238
- bestResolution = i
239
- resolutionLink = tempUrl2 + "/" + tempArr[bestResolution].split("\n")[-2]
240
- return resolutionLink
241
-
242
-
243
- def stremKeyAPI(catalog_id, content_id, item_category, content_definition):
244
- url = "https://www.shemaroome.com/users/user_all_lists"
245
- payload = 'catalog_id='+catalog_id+'&content_id='+content_id + \
246
- '&category='+item_category+'&content_def='+content_definition
247
- response = requests.request("POST", url, data=payload)
248
- try:
249
- return {
250
- "streamKey": response.json()['stream_key'],
251
- "key": response.json()['key'],
252
- "newPlayUrl": response.json()['new_play_url'],
253
- "ios_key": response.json()['ios_key'],
254
- "ios_play_url": response.json()['ios_play_url'],
255
- "subtitle": response.json()['subtitle']
256
- }
257
- except:
258
- return {"error": "There's an error in data."}
259
-
260
-
261
- def pageLoderAPI(title):
262
- driver = create_driver()
263
- try:
264
- driver.get("https://www.shemaroome.com/" + title)
265
- # Wait for the page to load
266
- WebDriverWait(driver, 10).until(
267
- EC.presence_of_element_located((By.ID, "catalog_id"))
268
- )
269
-
270
- page_source = driver.page_source
271
- soup = BeautifulSoup(page_source, features="html5lib")
272
-
273
- catalog_id_elem = soup.find("input", {"id": "catalog_id"})
274
- content_id_elem = soup.find("input", {"id": "content_id"})
275
- item_category_elem = soup.find("input", {"id": "item_category"})
276
- content_definition_elem = soup.find("input", {"id": "content_definition"})
277
-
278
- if not all([catalog_id_elem, content_id_elem, item_category_elem, content_definition_elem]):
279
- return {"error": "Required elements not found on page."}
280
-
281
- return {
282
- "catalog_id": catalog_id_elem['value'],
283
- "content_id": content_id_elem['value'],
284
- "item_category": item_category_elem['value'],
285
- "content_definition": content_definition_elem['value']
286
- }
287
- except Exception as e:
288
- return {"error": f"There's an error in URL: {str(e)}"}
289
- finally:
290
- driver.quit()
291
-
292
-
293
- @app.route('/')
294
- def home():
295
- sliderImages, catagoryObject = homeFetch()
296
- return render_template('home.html',
297
- sliderImages=sliderImages,
298
- catagoryObject=catagoryObject)
299
-
300
-
301
- @app.route('/hello')
302
- def hello():
303
- return "Hello world from Shemaroome!"
304
-
305
-
306
- @app.route('/movies/<title>')
307
- def movieDetail(title):
308
- try:
309
- dataObj = movieDetailFetch("movies/" + title)
310
- contentObj = pageLoderAPI("movies/" + title)
311
- keyData = stremKeyAPI(contentObj["catalog_id"], contentObj["content_id"],
312
- contentObj["item_category"], "AVOD")
313
- movieUrl = decryptLink(keyData["ios_play_url"], keyData["ios_key"], "movie")
314
- return render_template('detailMovie.html',
315
- dataObj=dataObj,
316
- movieUrl=movieUrl)
317
- except:
318
- return redirect(url_for('home'))
319
-
320
-
321
- @app.route('/gujarati-plays/<title>')
322
- def detailsGujaratiPlays(title):
323
- try:
324
- dataObj = movieDetailFetch("gujarati-plays/" + title)
325
- contentObj = pageLoderAPI("gujarati-plays/" + title)
326
- keyData = stremKeyAPI(contentObj["catalog_id"], contentObj["content_id"],
327
- contentObj["item_category"], "AVOD")
328
- movieUrl = decryptLink(keyData["ios_play_url"], keyData["ios_key"], "movie")
329
- return render_template('detailsGujaratiPlays.html',
330
- dataObj=dataObj,
331
- movieUrl=movieUrl)
332
- except:
333
- return redirect(url_for('home'))
334
-
335
-
336
- @app.route('/shows/<title>')
337
- def detailShowHome(title):
338
- try:
339
- dataObj = showDetailFetch("shows/" + title)
340
- return render_template('detailShowHome.html', dataObj=dataObj)
341
- except:
342
- return redirect(url_for('home'))
343
-
344
-
345
- @app.route('/shows/<title>/<episode>')
346
- def detailShowEpisode(title, episode):
347
- try:
348
- dataObj = showDetailFetch("shows/" + title + "/" + episode)
349
- contentObj = pageLoderAPI("shows/" + title + "/" + episode)
350
- keyData = stremKeyAPI(contentObj["catalog_id"], contentObj["content_id"],
351
- contentObj["item_category"], "AVOD")
352
- movieUrl = decryptLink(keyData["ios_play_url"], keyData["ios_key"], "show")
353
- return render_template('detailShowEpisode.html',
354
- dataObj=dataObj,
355
- movieUrl=movieUrl)
356
- except:
357
- return redirect(url_for('home'))
358
-
359
-
360
- app.run(host="0.0.0.0", port="8080", debug="true")
 
1
+ from flask import Flask, render_template, redirect, url_for
2
+ import requests
3
+ from bs4 import BeautifulSoup
4
+ from base64 import b64decode
5
+ from Crypto.Cipher import AES
6
+ from Crypto.Util.Padding import unpad
7
+ from selenium import webdriver
8
+ from selenium.webdriver.chrome.service import Service
9
+ from selenium.webdriver.chrome.options import Options
10
+ from selenium.webdriver.common.by import By
11
+ from selenium.webdriver.support.ui import WebDriverWait
12
+ from selenium.webdriver.support import expected_conditions as EC
13
+ from webdriver_manager.chrome import ChromeDriverManager
14
+ import time
15
+
16
+ app = Flask(__name__, static_url_path='/static', static_folder='static')
17
+
18
+
19
+ def create_driver():
20
+ """Create and configure Chrome WebDriver"""
21
+ chrome_options = Options()
22
+ chrome_options.add_argument("--headless") # Run in background
23
+ chrome_options.add_argument("--no-sandbox")
24
+ chrome_options.add_argument("--disable-dev-shm-usage")
25
+ chrome_options.add_argument("--disable-gpu")
26
+ chrome_options.add_argument("--window-size=1920,1080")
27
+ chrome_options.add_argument("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36")
28
+
29
+ service = Service(ChromeDriverManager().install())
30
+ driver = webdriver.Chrome(service=service, options=chrome_options)
31
+ return driver
32
+
33
+
34
+ def homeFetch():
35
+ driver = create_driver()
36
+ try:
37
+ driver.get('https://www.shemaroome.com/')
38
+ # Wait for the page to load
39
+ WebDriverWait(driver, 10).until(
40
+ EC.presence_of_element_located((By.CLASS_NAME, "masthead-card"))
41
+ )
42
+
43
+ # Get page source and parse with BeautifulSoup
44
+ page_source = driver.page_source
45
+ soup = BeautifulSoup(page_source, features="html5lib")
46
+
47
+ # fetches all slider images
48
+ slider = soup.find_all("div", {"class": "masthead-card"})
49
+ sliderImages = []
50
+ for element in slider:
51
+ tempImage = element.find("img")
52
+ if tempImage:
53
+ sliderImages.append(tempImage['src'])
54
+
55
+ # fetches all catagories with images
56
+ catagory = soup.find_all(
57
+ "div", {"class": "float-left w-100 slick-container slick-gap"})
58
+ catagoryObject = []
59
+ for element in catagory:
60
+ tempTitle = element.find("h2")
61
+ if tempTitle != None:
62
+ tempTitle = str(tempTitle).split(">")[1].split("<")[0]
63
+ tempImages = element.find_all("a")
64
+ tempImagesArr = []
65
+ for image in tempImages:
66
+ try:
67
+ imgLink = image.find("img")["src"]
68
+ except:
69
+ imgLink = ""
70
+ tempImagesArr.append([image["href"], imgLink])
71
+ catagoryObject.append([tempTitle, tempImagesArr])
72
+
73
+ return sliderImages, catagoryObject
74
+
75
+ finally:
76
+ driver.quit()
77
+
78
+
79
+ def movieDetailFetch(title):
80
+ driver = create_driver()
81
+ try:
82
+ driver.get('https://www.shemaroome.com/' + title)
83
+ # Wait for the main content to load
84
+ WebDriverWait(driver, 10).until(
85
+ EC.presence_of_element_located((By.CLASS_NAME, "main-content"))
86
+ )
87
+
88
+ page_source = driver.page_source
89
+ soup = BeautifulSoup(page_source, features="html5lib")
90
+
91
+ pathList = []
92
+ pathsContainer = soup.find("section", {"class": "main-content"})
93
+ if pathsContainer and pathsContainer.find("ul"):
94
+ paths = pathsContainer.find("ul").find_all("li")
95
+ for path in paths:
96
+ if path.find("a"):
97
+ pathList.append([path.find("a")["href"], path.text.strip()])
98
+
99
+ title_element = soup.find(
100
+ "h1", {
101
+ "class":
102
+ "float-left w-100 app-color1 font-black margin-bottom-10 section-title2"
103
+ })
104
+ title = title_element.text if title_element else ""
105
+
106
+ catagoriesArr = []
107
+ catagories = soup.find_all(
108
+ "li", {"class": "float-left font-regular app-color5 app-color1"})
109
+ for catagory in catagories:
110
+ catagoriesArr.append(catagory.text.strip())
111
+
112
+ movieDataArr = []
113
+ Synopsis = soup.find_all(
114
+ "p", {"class": "float-left w-100 app-color1 font-regular"})
115
+ for data in Synopsis:
116
+ movieDataArr.append(data.text.strip())
117
+
118
+ youMayLikeArr = []
119
+ youMayLikeContainer = soup.find(
120
+ "div", {"class": "float-left w-100 app-slick-slider-container"})
121
+ if youMayLikeContainer:
122
+ youMayLike = youMayLikeContainer.find_all("a")
123
+ for data in youMayLike:
124
+ img_element = data.find("img")
125
+ if img_element:
126
+ youMayLikeArr.append([data["href"], img_element["src"]])
127
+
128
+ return {
129
+ "pathList": pathList,
130
+ "title": title,
131
+ "catagoriesArr": catagoriesArr,
132
+ "movieDataArr": movieDataArr,
133
+ "youMayLikeArr": youMayLikeArr
134
+ }
135
+
136
+ finally:
137
+ driver.quit()
138
+
139
+
140
+ def showDetailFetch(title):
141
+ driver = create_driver()
142
+ try:
143
+ driver.get('https://www.shemaroome.com/' + title)
144
+ # Wait for the main content to load
145
+ WebDriverWait(driver, 10).until(
146
+ EC.presence_of_element_located((By.CLASS_NAME, "main-content"))
147
+ )
148
+
149
+ page_source = driver.page_source
150
+ soup = BeautifulSoup(page_source, features="html5lib")
151
+
152
+ pathsContainer = soup.find("section", {"class": "main-content"})
153
+ pathList = []
154
+ if pathsContainer and pathsContainer.find("ul"):
155
+ paths = pathsContainer.find("ul").find_all("li")
156
+ for path in paths:
157
+ if path.find("a"):
158
+ pathList.append([path.find("a")["href"], path.text.strip()])
159
+
160
+ title_element = soup.find(
161
+ "h1", {
162
+ "class":
163
+ "float-left w-100 app-color1 font-black margin-bottom-10 section-title2"
164
+ })
165
+ title = title_element.text.strip() if title_element else ""
166
+
167
+ catagories = soup.find_all("li",
168
+ {"class": "float-left font-regular app-color5"})
169
+ catagoriesArr = []
170
+ for catagory in catagories:
171
+ catagoriesArr.append(catagory.text.strip())
172
+
173
+ Synopsis = soup.find_all(
174
+ "p", {"class": "float-left w-100 app-color1 font-regular"})
175
+ movieDataArr = []
176
+ for data in Synopsis:
177
+ movieDataArr.append(data.text.strip())
178
+
179
+ episodesArr = []
180
+ episodeContainers = soup.find_all(
181
+ "div", {"class": "float-left w-100 app-slick-slider-container"})
182
+ if len(episodeContainers) > 0:
183
+ episodes = episodeContainers[0].find_all("a")
184
+ for episode in episodes:
185
+ img_element = episode.find("img")
186
+ if img_element:
187
+ episodesArr.append([episode["href"], img_element["src"]])
188
+
189
+ youMayLikeArr = []
190
+ if len(episodeContainers) > 1:
191
+ youMayLike = episodeContainers[1].find_all("a")
192
+ for data in youMayLike:
193
+ img_element = data.find("img")
194
+ if img_element:
195
+ youMayLikeArr.append([data["href"], img_element["src"]])
196
+
197
+ poster = ""
198
+ poster_element = soup.find(
199
+ "div", {
200
+ "class": "player_section w-100 embed-responsive embed-responsive-16by9"
201
+ })
202
+ if poster_element:
203
+ img_element = poster_element.find("img")
204
+ if img_element:
205
+ poster = img_element["src"]
206
+
207
+ return {
208
+ "pathList": pathList,
209
+ "title": title,
210
+ "catagoriesArr": catagoriesArr,
211
+ "movieDataArr": movieDataArr,
212
+ "episodesArr": episodesArr,
213
+ "youMayLikeArr": youMayLikeArr,
214
+ "poster": poster
215
+ }
216
+
217
+ finally:
218
+ driver.quit()
219
+
220
+
221
+ def decryptLink(encrypted, key, type):
222
+ key = b64decode(key)
223
+ iv = b'0000000000000000'
224
+ ct = b64decode(encrypted)
225
+ cipher = AES.new(key, AES.MODE_CBC, iv)
226
+ pt = unpad(cipher.decrypt(ct), AES.block_size)
227
+ link = pt.decode()
228
+ tempUrl = "https://d1fcqrzxghru70.cloudfront.net/" + \
229
+ link.split("cloudfront.net/")[1]
230
+ response = requests.request("GET", tempUrl)
231
+ tempArr = response.text.split("RESOLUTION=")
232
+ tempArr.pop(0)
233
+ tempUrl2 = '/'.join(tempUrl.split("/")[:-1])
234
+ bestResolution = 0
235
+ for i in range(len(tempArr)):
236
+ if int(tempArr[i].split("x")[0]) > int(
237
+ tempArr[bestResolution].split("x")[0]):
238
+ bestResolution = i
239
+ resolutionLink = tempUrl2 + "/" + tempArr[bestResolution].split("\n")[-2]
240
+ return resolutionLink
241
+
242
+
243
+ def stremKeyAPI(catalog_id, content_id, item_category, content_definition):
244
+ url = "https://www.shemaroome.com/users/user_all_lists"
245
+ payload = 'catalog_id='+catalog_id+'&content_id='+content_id + \
246
+ '&category='+item_category+'&content_def='+content_definition
247
+ response = requests.request("POST", url, data=payload)
248
+ try:
249
+ return {
250
+ "streamKey": response.json()['stream_key'],
251
+ "key": response.json()['key'],
252
+ "newPlayUrl": response.json()['new_play_url'],
253
+ "ios_key": response.json()['ios_key'],
254
+ "ios_play_url": response.json()['ios_play_url'],
255
+ "subtitle": response.json()['subtitle']
256
+ }
257
+ except:
258
+ return {"error": "There's an error in data."}
259
+
260
+
261
+ def pageLoderAPI(title):
262
+ driver = create_driver()
263
+ try:
264
+ driver.get("https://www.shemaroome.com/" + title)
265
+ # Wait for the page to load
266
+ WebDriverWait(driver, 10).until(
267
+ EC.presence_of_element_located((By.ID, "catalog_id"))
268
+ )
269
+
270
+ page_source = driver.page_source
271
+ soup = BeautifulSoup(page_source, features="html5lib")
272
+
273
+ catalog_id_elem = soup.find("input", {"id": "catalog_id"})
274
+ content_id_elem = soup.find("input", {"id": "content_id"})
275
+ item_category_elem = soup.find("input", {"id": "item_category"})
276
+ content_definition_elem = soup.find("input", {"id": "content_definition"})
277
+
278
+ if not all([catalog_id_elem, content_id_elem, item_category_elem, content_definition_elem]):
279
+ return {"error": "Required elements not found on page."}
280
+
281
+ return {
282
+ "catalog_id": catalog_id_elem['value'],
283
+ "content_id": content_id_elem['value'],
284
+ "item_category": item_category_elem['value'],
285
+ "content_definition": content_definition_elem['value']
286
+ }
287
+ except Exception as e:
288
+ return {"error": f"There's an error in URL: {str(e)}"}
289
+ finally:
290
+ driver.quit()
291
+
292
+
293
+ @app.route('/')
294
+ def home():
295
+ sliderImages, catagoryObject = homeFetch()
296
+ return render_template('home.html',
297
+ sliderImages=sliderImages,
298
+ catagoryObject=catagoryObject)
299
+
300
+
301
+ @app.route('/hello')
302
+ def hello():
303
+ return "Hello world from Shemaroome!"
304
+
305
+
306
+ @app.route('/movies/<title>')
307
+ def movieDetail(title):
308
+ try:
309
+ dataObj = movieDetailFetch("movies/" + title)
310
+ contentObj = pageLoderAPI("movies/" + title)
311
+ keyData = stremKeyAPI(contentObj["catalog_id"], contentObj["content_id"],
312
+ contentObj["item_category"], "AVOD")
313
+ movieUrl = decryptLink(keyData["ios_play_url"], keyData["ios_key"], "movie")
314
+ return render_template('detailMovie.html',
315
+ dataObj=dataObj,
316
+ movieUrl=movieUrl)
317
+ except:
318
+ return redirect(url_for('home'))
319
+
320
+
321
+ @app.route('/gujarati-plays/<title>')
322
+ def detailsGujaratiPlays(title):
323
+ try:
324
+ dataObj = movieDetailFetch("gujarati-plays/" + title)
325
+ contentObj = pageLoderAPI("gujarati-plays/" + title)
326
+ keyData = stremKeyAPI(contentObj["catalog_id"], contentObj["content_id"],
327
+ contentObj["item_category"], "AVOD")
328
+ movieUrl = decryptLink(keyData["ios_play_url"], keyData["ios_key"], "movie")
329
+ return render_template('detailsGujaratiPlays.html',
330
+ dataObj=dataObj,
331
+ movieUrl=movieUrl)
332
+ except:
333
+ return redirect(url_for('home'))
334
+
335
+
336
+ @app.route('/shows/<title>')
337
+ def detailShowHome(title):
338
+ try:
339
+ dataObj = showDetailFetch("shows/" + title)
340
+ return render_template('detailShowHome.html', dataObj=dataObj)
341
+ except:
342
+ return redirect(url_for('home'))
343
+
344
+
345
+ @app.route('/shows/<title>/<episode>')
346
+ def detailShowEpisode(title, episode):
347
+ try:
348
+ dataObj = showDetailFetch("shows/" + title + "/" + episode)
349
+ contentObj = pageLoderAPI("shows/" + title + "/" + episode)
350
+ keyData = stremKeyAPI(contentObj["catalog_id"], contentObj["content_id"],
351
+ contentObj["item_category"], "AVOD")
352
+ movieUrl = decryptLink(keyData["ios_play_url"], keyData["ios_key"], "show")
353
+ return render_template('detailShowEpisode.html',
354
+ dataObj=dataObj,
355
+ movieUrl=movieUrl)
356
+ except:
357
+ return redirect(url_for('home'))
358
+
359
+
360
+ app.run(host="0.0.0.0", port="7860", debug="true")