mirror of
https://github.com/myned/modufur.git
synced 2024-12-25 06:37:29 +00:00
Merge branch 'dev'
This commit is contained in:
commit
048dbb28ff
1 changed files with 14 additions and 15 deletions
|
@ -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))
|
||||
|
||||
|
|
Loading…
Reference in a new issue