Ufoptg commited on
Commit
27cc935
1 Parent(s): 5d2c79d

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +69 -0
main.py CHANGED
@@ -341,6 +341,75 @@ def sibyl_system(
341
  else:
342
  return {"status": "false", "message": "Not Found User"}
343
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
 
345
  @app.post(
346
  "/UFoP/gemini-the-oracle",
 
341
  else:
342
  return {"status": "false", "message": "Not Found User"}
343
 
344
+ @app.get("/UFoP/yts", response_model=List[MovieInfo])
345
+ def get_movie_info(name: str, api_key: str = Header(...)):
346
+ validate_api_key(api_key) # Validate API key here
347
+ results = []
348
+ try:
349
+ for page in range(1, 2):
350
+ url = f"https://yts.mx/browse-movies/{name}/all/all/0/seeds/0/all"
351
+ r = requests.get(url).text
352
+ soup = BeautifulSoup(r, "lxml")
353
+ for movie in soup.findAll("div", class_="browse-movie-wrap col-xs-10 col-sm-4 col-md-5 col-lg-4"):
354
+ mov_name = movie.find("div", class_="browse-movie-bottom")
355
+ movie_name = mov_name.a.text
356
+ movie_year = mov_name.div.text
357
+ movie_name = movie_name + " " + movie_year
358
+ rating = movie.find("h4", class_="rating", text=True)
359
+ if rating is not None:
360
+ rating = rating.text
361
+ rating = rating[:3]
362
+ else:
363
+ rating = "0.0"
364
+ if rating[2] == "/":
365
+ rating = rating[0:2]
366
+ try:
367
+ if movie_name[0] == "[" and movie_name[3] == "]":
368
+ movie_name = movie_name[5:]
369
+ movie_name = movie_name.replace(" ", "-")
370
+ index = 0
371
+ for char in movie_name:
372
+ if not char.isalnum() and char != "-":
373
+ movie_name = movie_name.replace(char, "")
374
+ for char in movie_name:
375
+ if char == "-" and movie_name[index + 1] == "-":
376
+ movie_name = movie_name[:index] + movie_name[index + 1:]
377
+ if index < len(movie_name) - 1:
378
+ index = index + 1
379
+ if "--" in movie_name:
380
+ movie_name = movie_name.replace("--", "-")
381
+ movie_url = f"https://yts.mx/movie/{movie_name.lower()}"
382
+ request = requests.get(movie_url).text
383
+ n_soup = BeautifulSoup(request, "lxml")
384
+ info = n_soup.find("div", class_="bottom-info")
385
+ torrent_info = n_soup.find("p", class_="hidden-xs hidden-sm")
386
+ genre = n_soup.findAll("h2")[1].text
387
+ likes = info.find("span", id="movie-likes").text
388
+ imdb_link = info.find("a", title="IMDb Rating")["href"]
389
+ for torrent in torrent_info.findAll("a"):
390
+ if torrent.text[:3] == "720":
391
+ torrent_720 = torrent["href"]
392
+ if torrent.text[:4] == "1080":
393
+ torrent_1080 = torrent["href"]
394
+ entry = {
395
+ "yts_link": movie_url,
396
+ "name": movie_name,
397
+ "year": movie_year,
398
+ "imdb_links": imdb_link,
399
+ "genre": genre,
400
+ "imdb_ratings": rating,
401
+ "likes": likes,
402
+ "torrent_720p": torrent_720,
403
+ "torrent_1080p": torrent_1080
404
+ }
405
+ results.append(entry)
406
+ except Exception as e:
407
+ print("Error:", e)
408
+ continue
409
+ except Exception as e:
410
+ print("Error:", e)
411
+ return results
412
+
413
 
414
  @app.post(
415
  "/UFoP/gemini-the-oracle",