mirror of
https://github.com/myned/modufur.git
synced 2024-12-24 22:27:28 +00:00
Fix Kheina parsing and eval
This commit is contained in:
parent
1262dc2ba7
commit
5987b46925
1 changed files with 18 additions and 9 deletions
|
@ -12,7 +12,7 @@ from utils import utils as u
|
||||||
|
|
||||||
# async def get_harry(url):
|
# async def get_harry(url):
|
||||||
# content = await u.fetch('https://iqdb.harry.lu', params={'url': url})
|
# content = await u.fetch('https://iqdb.harry.lu', params={'url': url})
|
||||||
# soup = BeautifulSoup(content, 'html.parser')
|
# soup = BeautifulSoup(content, 'html5lib')
|
||||||
#
|
#
|
||||||
# if soup.find('div', id='show1').string is 'Not the right one? ':
|
# if soup.find('div', id='show1').string is 'Not the right one? ':
|
||||||
# parent = soup.find('th', string='Probable match:').parent.parent
|
# parent = soup.find('th', string='Probable match:').parent.parent
|
||||||
|
@ -41,17 +41,25 @@ from utils import utils as u
|
||||||
|
|
||||||
|
|
||||||
async def get_kheina(url):
|
async def get_kheina(url):
|
||||||
content = await u.fetch('https://kheina.com', params={'url': url})
|
content = await u.fetch('https://kheina.com', params={'url': url}, text=True)
|
||||||
soup = BeautifulSoup(content, 'html.parser')
|
|
||||||
|
|
||||||
results = ast.literal_eval(soup.find('data', id='results').string)[-1]
|
content = content.replace('"', 'quot;').replace(''', 'apos;')
|
||||||
iqdbdata = ast.literal_eval(soup.find('data', id='iqdbdata').string)[0]
|
soup = BeautifulSoup(content, 'html5lib')
|
||||||
|
results = soup.find('data', id='results').string.replace('quot;', '"').replace('apos;', ''')
|
||||||
|
results = ast.literal_eval(results)
|
||||||
|
iqdbdata = soup.find('data', id='iqdbdata').string
|
||||||
|
iqdbdata = ast.literal_eval(iqdbdata)
|
||||||
|
|
||||||
|
for e in results:
|
||||||
|
if iqdbdata[0]['iqdbid'] in e:
|
||||||
|
match = e
|
||||||
|
break
|
||||||
|
|
||||||
result = {
|
result = {
|
||||||
'source': results[3],
|
'source': match[3],
|
||||||
'artist': results[4],
|
'artist': match[4],
|
||||||
'thumbnail': f'https://f002.backblazeb2.com/file/kheinacom/{results[1]}.jpg',
|
'thumbnail': f'https://f002.backblazeb2.com/file/kheinacom/{match[1]}.jpg',
|
||||||
'similarity': str(int(float(iqdbdata['similarity']))),
|
'similarity': str(int(float(iqdbdata[0]['similarity']))),
|
||||||
'database': 'Kheina'
|
'database': 'Kheina'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -63,6 +71,7 @@ async def get_saucenao(url):
|
||||||
'https://saucenao.com/search.php',
|
'https://saucenao.com/search.php',
|
||||||
params={'url': url, 'api_key': u.config['saucenao_api'], 'output_type': 2},
|
params={'url': url, 'api_key': u.config['saucenao_api'], 'output_type': 2},
|
||||||
json=True)
|
json=True)
|
||||||
|
|
||||||
results = content['results'][0]
|
results = content['results'][0]
|
||||||
for i in range(len(content['results'])):
|
for i in range(len(content['results'])):
|
||||||
if 'e621' in content['results'][i]['header']['index_name']:
|
if 'e621' in content['results'][i]['header']['index_name']:
|
||||||
|
|
Loading…
Reference in a new issue