1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-12-24 22:27:28 +00:00

Merge branch 'dev'

This commit is contained in:
Myned 2020-03-18 02:37:24 -04:00
commit 8e0bf1b25d
No known key found for this signature in database
GPG key ID: 2EF9C0C44229D034
2 changed files with 13 additions and 6 deletions

View file

@ -47,13 +47,20 @@ async def query_kheina(url):
if similarity < 55: if similarity < 55:
return None return None
source = re.search('\\d+$', content['results'][0]['sources'][0]['source']).group(0) if tld.extract(content['results'][0]['sources'][0]['source']).domain == 'furaffinity':
export = await u.fetch(f'https://faexport.spangle.org.uk/submission/{source}.json', json=True) submission = re.search('\\d+$', content['results'][0]['sources'][0]['source']).group(0)
try:
export = await u.fetch(f'https://faexport.spangle.org.uk/submission/{submission}.json', json=True)
thumbnail = export['full']
except AssertionError:
thumbnail = ''
else:
thumbnail = ''
result = { result = {
'source': content['results'][0]['sources'][0]['source'], 'source': content['results'][0]['sources'][0]['source'],
'artist': content['results'][0]['sources'][0]['artist'], 'artist': content['results'][0]['sources'][0]['artist'],
'thumbnail': '' if isinstance(export, int) and export != 200 else export['full'], 'thumbnail': thumbnail,
'similarity': str(similarity), 'similarity': str(similarity),
'database': tld.extract(content['results'][0]['sources'][0]['source']).domain 'database': tld.extract(content['results'][0]['sources'][0]['source']).domain
} }

View file

@ -91,9 +91,9 @@ async def fetch(url, *, post={}, response=False, text=False, json=False):
if post: if post:
async with asession.post(url, data=post, headers={ async with asession.post(url, data=post, headers={
'User-Agent': 'Myned/Modufur (https://github.com/Myned/Modufur)'}, ssl=False) as r: 'User-Agent': 'Myned/Modufur (https://github.com/Myned/Modufur)'}, ssl=False) as r:
if r.status != 200: assert r.status == 200
return r.status
elif response: if response:
return r return r
elif text: elif text:
return await r.text() return await r.text()