From 68fc9bb54128f68e49ff55f14d60333376e83bae Mon Sep 17 00:00:00 2001 From: Myned Date: Tue, 12 Nov 2019 15:28:11 -0500 Subject: [PATCH] Change reverse image preference to SauceNAO and improve filtering --- src/utils/scraper.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/utils/scraper.py b/src/utils/scraper.py index dada6fd..17e9753 100644 --- a/src/utils/scraper.py +++ b/src/utils/scraper.py @@ -140,9 +140,16 @@ async def get_post(url): if filesize > 8192 * 1024: raise exc.SizeError(size(filesize, system=alternative)) - result = await query_kheina(url) - if not result: - result = await query_saucenao(url) + # Prioritize SauceNAO if e621/furaffinity, Kheina>SauceNAO if not + result = await query_saucenao(url) + if result: + if not any(s in result['source'] for s in ('e621', 'furaffinity')): + kheina = await query_kheina(url) + if kheina: + result = kheina + else: + result = await query_kheina(url) + if not result: raise exc.MatchError(re.search('\\/([^\\/]+)$', url).group(1))