1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 13:02:38 +00:00

Remove internal marker

This commit is contained in:
Myned 2022-03-04 00:00:06 -06:00
parent ab1cd302cc
commit 417b43c4e0
No known key found for this signature in database
GPG key ID: 33790F979F7A28B8

View file

@ -12,10 +12,11 @@ sauce = pysaucenao.SauceNao(api_key=c.config["saucenao"], priority=(29, 40, 41))
# Return list of matches # Return list of matches
async def reverse(urls): async def reverse(urls):
return [await _saucenao(url) or await _kheina(url) for url in urls] return [await saucenao(url) or await kheina(url) for url in urls]
async def _saucenao(url): # Query SauceNAO
async def saucenao(url):
try: try:
results = await sauce.from_url(url) results = await sauce.from_url(url)
except pysaucenao.FileSizeLimitException: except pysaucenao.FileSizeLimitException:
@ -40,8 +41,9 @@ async def _saucenao(url):
) )
async def _kheina(url): # Query Kheina
content = await _post("https://api.kheina.com/v1/search", {"url": url}) async def kheina(url):
content = await post("https://api.kheina.com/v1/search", {"url": url})
if content["results"][0]["similarity"] < 50: if content["results"][0]["similarity"] < 50:
return None return None
@ -55,7 +57,8 @@ async def _kheina(url):
} }
async def _post(url, data): # Return post response as json
async def post(url, data):
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
async with session.post(url, data=data) as response: async with session.post(url, data=data) as response:
return await response.json() if response.status == 200 else None return await response.json() if response.status == 200 else None