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 2019-09-24 20:05:38 -04:00
commit 048dbb28ff
No known key found for this signature in database
GPG key ID: BC58C09870A63E59

View file

@ -40,7 +40,7 @@ from utils import utils as u
# return False
async def get_kheina(url):
async def query_kheina(url):
content = await u.fetch('https://kheina.com', params={'url': url}, text=True)
content = content.replace('"', 'quot;').replace(''', 'apos;')
@ -66,29 +66,28 @@ async def get_kheina(url):
return result
async def get_saucenao(url):
async def query_saucenao(url):
content = await u.fetch(
'https://saucenao.com/search.php',
params={'url': url, 'api_key': u.config['saucenao_api'], 'output_type': 2},
json=True)
results = content['results'][0]
for i in range(len(content['results'])):
if 'e621' in content['results'][i]['header']['index_name']:
results = content['results'][i]
match = content['results'][0]
if 'author_name' in results['data']:
if 'author_name' in match['data']:
artist = 'author_name'
elif 'member_name' in results['data']:
elif 'member_name' in match['data']:
artist = 'member_name'
else:
elif 'creator' in match['data']:
artist = 'creator'
else:
artist = 'imdb_id'
result = {
'source': results['data']['ext_urls'][0],
'artist': results['data'][artist],
'thumbnail': results['header']['thumbnail'],
'similarity': str(int(float(results['header']['similarity']))),
'source': match['data']['ext_urls'][0],
'artist': match['data'][artist],
'thumbnail': match['header']['thumbnail'],
'similarity': str(int(float(match['header']['similarity']))),
'database': 'SauceNAO'
}
@ -102,9 +101,9 @@ async def get_post(url):
if filesize > 8192 * 1024:
raise exc.SizeError(size(filesize, system=alternative))
result = await get_kheina(url)
result = await query_kheina(url)
if int(result['similarity']) < 55:
result = await get_saucenao(url)
result = await query_saucenao(url)
if int(result['similarity']) < 55:
raise exc.MatchError(re.search('\\/([^\\/]+)$', url).group(1))