forked from AbirHasan2005/Torrent-Search-Bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtool.py
35 lines (25 loc) · 1.57 KB
/
tool.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# (c) @AbirHasan2005
# Scrappers
import aiohttp
from configs import Config
from requests.utils import requote_uri
API_1337x = "https://api.abirhasan.wtf/1337x?query={}&limit={}"
API_YTS = "https://api.abirhasan.wtf/yts?query={}&limit={}"
API_PIRATEBAY = "https://api.abirhasan.wtf/piratebay?query={}&limit={}"
API_ANIME = "https://api.abirhasan.wtf/anime?query={}&limit={}"
async def Search1337x(query: str):
async with aiohttp.ClientSession() as session:
async with session.get(requote_uri(API_1337x.format(query, Config.MAX_INLINE_RESULTS))) as res:
return (await res.json())["results"] if ((await res.json()).get("results", None) is not None) else []
async def SearchYTS(query: str):
async with aiohttp.ClientSession() as session:
async with session.get(requote_uri(API_YTS.format(query, Config.MAX_INLINE_RESULTS))) as res:
return (await res.json())["results"] if ((await res.json()).get("results", None) is not None) else []
async def SearchPirateBay(query: str):
async with aiohttp.ClientSession() as session:
async with session.get(requote_uri(API_PIRATEBAY.format(query, Config.MAX_INLINE_RESULTS))) as res:
return (await res.json())["results"] if ((await res.json()).get("results", None) is not None) else []
async def SearchAnime(query: str):
async with aiohttp.ClientSession() as session:
async with session.get(requote_uri(API_ANIME.format(query, Config.MAX_INLINE_RESULTS))) as res:
return (await res.json())["results"] if ((await res.json()).get("results", None) is not None) else []