1
0
Fork 0
mirror of https://github.com/myned/modufur.git synced 2024-11-01 13:02:38 +00:00

Add limit to similarity of search result

This commit is contained in:
Dylan Dizon 2019-09-22 13:32:26 -04:00 committed by GitHub
parent 11e8abbc01
commit fb97825b98
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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))