mirror of
https://github.com/myned/modufur.git
synced 2024-11-01 13:02:38 +00:00
Add check for furaffinity before requesting submission info
This commit is contained in:
parent
7e9ba1b437
commit
689b94fa0a
1 changed files with 5 additions and 3 deletions
|
@ -47,18 +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:
|
try:
|
||||||
export = await u.fetch(f'https://faexport.spangle.org.uk/submission/{submission}.json', json=True)
|
export = await u.fetch(f'https://faexport.spangle.org.uk/submission/{submission}.json', json=True)
|
||||||
thumbnail = export['full']
|
thumbnail = export['full']
|
||||||
except AssertionError:
|
except AssertionError:
|
||||||
thumbnail = ''
|
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
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue