mirror of
https://github.com/myned/modufur.git
synced 2024-11-01 21:02:38 +00:00
Add limit to similarity of search result
This commit is contained in:
parent
11e8abbc01
commit
fb97825b98
1 changed files with 5 additions and 4 deletions
|
@ -27,9 +27,9 @@ async def get_post(url):
|
||||||
ident = re.search('#(\\d+)', post['delreason']).group(1)
|
ident = re.search('#(\\d+)', post['delreason']).group(1)
|
||||||
post = await u.fetch('http://e621.net/post/show.json', params={'id': ident}, json=True)
|
post = await u.fetch('http://e621.net/post/show.json', params={'id': ident}, json=True)
|
||||||
source = f'https://e621.net/post/show/{post["id"]}'
|
source = f'https://e621.net/post/show/{post["id"]}'
|
||||||
similarity = re.search('\\d+', soup.find(string=re.compile('similarity'))).group(0) + '% Match'
|
similarity = re.search('\\d+', soup.find(string=re.compile('similarity'))).group(0)
|
||||||
|
|
||||||
return post, source, similarity
|
return post, source, similarity + '% Match'
|
||||||
else:
|
else:
|
||||||
raise IndexError
|
raise IndexError
|
||||||
|
|
||||||
|
@ -53,9 +53,10 @@ async def get_post(url):
|
||||||
'artist': [result['data'][artist]],
|
'artist': [result['data'][artist]],
|
||||||
'score': 'SauceNAO'}
|
'score': 'SauceNAO'}
|
||||||
source = result['data']['ext_urls'][0]
|
source = result['data']['ext_urls'][0]
|
||||||
similarity = re.search('(\\d+)\\.', result['header']['similarity']).group(1) + '% Match'
|
similarity = re.search('(\\d+)\\.', result['header']['similarity']).group(1)
|
||||||
|
|
||||||
return post, source, similarity
|
if int(similarity) >= 55:
|
||||||
|
return post, source, similarity + '% Match'
|
||||||
|
|
||||||
raise exc.MatchError(re.search('\\/([^\\/]+)$', url).group(1))
|
raise exc.MatchError(re.search('\\/([^\\/]+)$', url).group(1))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue