Ufoptg commited on
Commit
32ee00f
1 Parent(s): 32411f6

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +31 -33
main.py CHANGED
@@ -346,41 +346,39 @@ def sibyl_system(
346
 
347
  async def get_torrent_info(url):
348
  try:
349
- async with aiohttp.ClientSession() as session:
350
- async with session.get(url) as response:
351
- html = await response.text()
352
- soup = BeautifulSoup(html, "html.parser")
353
- torrents = []
354
- for movie_div in soup.find_all("div", class_="container", id="movie-content"):
355
- poster = movie_div.find("img", itemprop="image")
356
- if poster:
357
- poster_url = poster["src"]
358
- else:
359
- poster_url = "N/A"
360
 
361
  # Extract other torrent information
362
- torrent_divs = movie_div.find_all("div", class_="modal-torrent")
363
- for div in torrent_divs:
364
- quality = div.find("div", class_="modal-quality").find("span").text
365
- all_p = div.find_all("p", class_="quality-size")
366
- quality_type = all_p[0].text if all_p else "N/A"
367
- size = all_p[1].text if len(all_p) > 1 else "N/A"
368
- torrent_link = div.find("a", class_="download-torrent")["href"]
369
- magnet = div.find("a", class_="magnet-download")["href"]
370
- hash = re.search(r"([{a-f\d,A-F\d}]{32,40})\b", magnet).group(0)
371
 
372
- torrents.append(
373
- {
374
- "poster": poster_url,
375
- "quality": quality,
376
- "type": quality_type,
377
- "size": size,
378
- "torrent": torrent_link,
379
- "magnet": magnet,
380
- "hash": hash,
381
- }
382
- )
383
- return torrents
384
  except Exception as e:
385
  print("Error fetching torrent info:", e)
386
  return []
@@ -393,7 +391,7 @@ async def get_movie_info(name: str, api_key: str = Header(...)):
393
  try:
394
  for page in range(1, 2):
395
  url = f"https://yts.mx/browse-movies/{name}/all/all/0/seeds/0/all"
396
- r = await async_searcher(url, head=True)
397
  soup = BeautifulSoup(r, "lxml")
398
  for movie in soup.findAll("div", class_="browse-movie-wrap col-xs-10 col-sm-4 col-md-5 col-lg-4"):
399
  mov_name = movie.find("div", class_="browse-movie-bottom")
 
346
 
347
  async def get_torrent_info(url):
348
  try:
349
+ html = await async_searcher(url)
350
+ soup = BeautifulSoup(html, "html.parser")
351
+ torrents = []
352
+ for movie_div in soup.find_all("div", class_="container", id="movie-content"):
353
+ poster = movie_div.find("img", itemprop="image")
354
+ if poster:
355
+ poster_url = poster["src"]
356
+ else:
357
+ poster_url = "N/A"
 
 
358
 
359
  # Extract other torrent information
360
+ torrent_divs = movie_div.find_all("div", class_="modal-torrent")
361
+ for div in torrent_divs:
362
+ quality = div.find("div", class_="modal-quality").find("span").text
363
+ all_p = div.find_all("p", class_="quality-size")
364
+ quality_type = all_p[0].text if all_p else "N/A"
365
+ size = all_p[1].text if len(all_p) > 1 else "N/A"
366
+ torrent_link = div.find("a", class_="download-torrent")["href"]
367
+ magnet = div.find("a", class_="magnet-download")["href"]
368
+ hash = re.search(r"([{a-f\d,A-F\d}]{32,40})\b", magnet).group(0)
369
 
370
+ torrents.append(
371
+ {
372
+ "poster": poster_url,
373
+ "quality": quality,
374
+ "type": quality_type,
375
+ "size": size,
376
+ "torrent": torrent_link,
377
+ "magnet": magnet,
378
+ "hash": hash,
379
+ }
380
+ )
381
+ return torrents
382
  except Exception as e:
383
  print("Error fetching torrent info:", e)
384
  return []
 
391
  try:
392
  for page in range(1, 2):
393
  url = f"https://yts.mx/browse-movies/{name}/all/all/0/seeds/0/all"
394
+ r = await async_searcher(url)
395
  soup = BeautifulSoup(r, "lxml")
396
  for movie in soup.findAll("div", class_="browse-movie-wrap col-xs-10 col-sm-4 col-md-5 col-lg-4"):
397
  mov_name = movie.find("div", class_="browse-movie-bottom")