Spaces:
Sleeping
Sleeping
Update main.py
Browse files
main.py
CHANGED
@@ -18,6 +18,7 @@
|
|
18 |
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
19 |
|
20 |
import asyncio
|
|
|
21 |
import base64
|
22 |
import json
|
23 |
import logging
|
@@ -341,8 +342,39 @@ def sibyl_system(
|
|
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:
|
@@ -390,6 +422,11 @@ def get_movie_info(name: str, api_key: str = Header(...)):
|
|
390 |
for torrent in torrent_info.findAll("a"):
|
391 |
if "magnet" in torrent["href"]:
|
392 |
magnet_links.append(torrent["href"])
|
|
|
|
|
|
|
|
|
|
|
393 |
entry = {
|
394 |
"yts_link": movie_url,
|
395 |
"name": movie_name,
|
@@ -398,7 +435,7 @@ def get_movie_info(name: str, api_key: str = Header(...)):
|
|
398 |
"genre": genre,
|
399 |
"imdb_ratings": rating,
|
400 |
"likes": likes,
|
401 |
-
"
|
402 |
}
|
403 |
results.append(entry)
|
404 |
except Exception as e:
|
|
|
18 |
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
19 |
|
20 |
import asyncio
|
21 |
+
import aiohttp
|
22 |
import base64
|
23 |
import json
|
24 |
import logging
|
|
|
342 |
else:
|
343 |
return {"status": "false", "message": "Not Found User"}
|
344 |
|
345 |
+
|
346 |
+
async def get_torrent_info(url):
|
347 |
+
try:
|
348 |
+
async with aiohttp.ClientSession() as session:
|
349 |
+
async with session.get(url) as response:
|
350 |
+
html = await response.text()
|
351 |
+
soup = BeautifulSoup(html, "html.parser")
|
352 |
+
torrents = []
|
353 |
+
for div in soup.find_all("div", class_="modal-torrent"):
|
354 |
+
quality = div.find("div", class_="modal-quality").find("span").text
|
355 |
+
all_p = div.find_all("p", class_="quality-size")
|
356 |
+
quality_type = all_p[0].text if all_p else "N/A"
|
357 |
+
size = all_p[1].text if len(all_p) > 1 else "N/A"
|
358 |
+
torrent_link = div.find("a", class_="download-torrent")["href"]
|
359 |
+
magnet = div.find("a", class_="magnet-download")["href"]
|
360 |
+
hash = re.search(r"([{a-f\d,A-F\d}]{32,40})\b", magnet).group(0)
|
361 |
+
torrents.append(
|
362 |
+
{
|
363 |
+
"quality": quality,
|
364 |
+
"type": quality_type,
|
365 |
+
"size": size,
|
366 |
+
"torrent": torrent_link,
|
367 |
+
"magnet": magnet,
|
368 |
+
"hash": hash,
|
369 |
+
}
|
370 |
+
)
|
371 |
+
return torrents
|
372 |
+
except Exception as e:
|
373 |
+
print("Error fetching torrent info:", e)
|
374 |
+
return []
|
375 |
+
|
376 |
@app.get("/UFoP/yts", response_model=List[MovieInfo])
|
377 |
+
async def get_movie_info(name: str, api_key: str = Header(...)):
|
378 |
validate_api_key(api_key) # Validate API key here
|
379 |
results = []
|
380 |
try:
|
|
|
422 |
for torrent in torrent_info.findAll("a"):
|
423 |
if "magnet" in torrent["href"]:
|
424 |
magnet_links.append(torrent["href"])
|
425 |
+
elif torrent.text[:3] == "720":
|
426 |
+
torrent_720 = torrent["href"]
|
427 |
+
elif torrent.text[:4] == "1080":
|
428 |
+
torrent_1080 = torrent["href"]
|
429 |
+
torrents = await get_torrent_info(movie_url) # Get torrent info asynchronously
|
430 |
entry = {
|
431 |
"yts_link": movie_url,
|
432 |
"name": movie_name,
|
|
|
435 |
"genre": genre,
|
436 |
"imdb_ratings": rating,
|
437 |
"likes": likes,
|
438 |
+
"torrents": torrents,
|
439 |
}
|
440 |
results.append(entry)
|
441 |
except Exception as e:
|