mirror of
https://github.com/myned/modufur.git
synced 2024-12-25 14:47:29 +00:00
Merge branch 'dev'
This commit is contained in:
commit
e4219bfdae
1 changed files with 31 additions and 16 deletions
|
@ -50,6 +50,10 @@ async def query_kheina(url):
|
||||||
iqdbdata = soup.find('data', id='iqdbdata').string
|
iqdbdata = soup.find('data', id='iqdbdata').string
|
||||||
iqdbdata = ast.literal_eval(iqdbdata)
|
iqdbdata = ast.literal_eval(iqdbdata)
|
||||||
|
|
||||||
|
similarity = int(float(iqdbdata[0]['similarity']))
|
||||||
|
if similarity < 55:
|
||||||
|
return False
|
||||||
|
|
||||||
for e in results:
|
for e in results:
|
||||||
if iqdbdata[0]['iqdbid'] in e:
|
if iqdbdata[0]['iqdbid'] in e:
|
||||||
match = e
|
match = e
|
||||||
|
@ -59,9 +63,9 @@ async def query_kheina(url):
|
||||||
'source': match[3],
|
'source': match[3],
|
||||||
'artist': match[4],
|
'artist': match[4],
|
||||||
'thumbnail': f'https://f002.backblazeb2.com/file/kheinacom/{match[1]}.jpg',
|
'thumbnail': f'https://f002.backblazeb2.com/file/kheinacom/{match[1]}.jpg',
|
||||||
'similarity': str(int(float(iqdbdata[0]['similarity']))),
|
'similarity': str(similarity),
|
||||||
'database': 'Kheina'
|
'database': 'Kheina'
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -74,22 +78,33 @@ async def query_saucenao(url):
|
||||||
|
|
||||||
match = content['results'][0]
|
match = content['results'][0]
|
||||||
|
|
||||||
if 'author_name' in match['data']:
|
similarity = int(float(match['header']['similarity']))
|
||||||
artist = 'author_name'
|
if similarity < 55:
|
||||||
elif 'member_name' in match['data']:
|
return False
|
||||||
artist = 'member_name'
|
|
||||||
elif 'creator' in match['data']:
|
source = match['data']['ext_urls'][0]
|
||||||
artist = 'creator'
|
for e in match['data']['ext_urls']:
|
||||||
else:
|
if 'e621' in e:
|
||||||
artist = 'imdb_id'
|
source = e
|
||||||
|
break
|
||||||
|
|
||||||
|
artist = 'Unknown'
|
||||||
|
for e in (
|
||||||
|
'author_name',
|
||||||
|
'member_name',
|
||||||
|
'creator'
|
||||||
|
):
|
||||||
|
if e in match['data']:
|
||||||
|
artist = match['data'][e]
|
||||||
|
break
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
'source': match['data']['ext_urls'][0],
|
'source': source,
|
||||||
'artist': match['data'][artist],
|
'artist': artist,
|
||||||
'thumbnail': match['header']['thumbnail'],
|
'thumbnail': match['header']['thumbnail'],
|
||||||
'similarity': str(int(float(match['header']['similarity']))),
|
'similarity': str(similarity),
|
||||||
'database': 'SauceNAO'
|
'database': 'SauceNAO'
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
@ -102,9 +117,9 @@ async def get_post(url):
|
||||||
raise exc.SizeError(size(filesize, system=alternative))
|
raise exc.SizeError(size(filesize, system=alternative))
|
||||||
|
|
||||||
result = await query_kheina(url)
|
result = await query_kheina(url)
|
||||||
if int(result['similarity']) < 55:
|
if not result:
|
||||||
result = await query_saucenao(url)
|
result = await query_saucenao(url)
|
||||||
if int(result['similarity']) < 55:
|
if not result:
|
||||||
raise exc.MatchError(re.search('\\/([^\\/]+)$', url).group(1))
|
raise exc.MatchError(re.search('\\/([^\\/]+)$', url).group(1))
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
Loading…
Reference in a new issue