From f2f7ee4eaeeb239a50ab9230b97a27678bfab3bf Mon Sep 17 00:00:00 2001 From: Myned Date: Thu, 16 Apr 2020 18:39:26 -0400 Subject: [PATCH] Fix link not being displayed for no artist --- src/cogs/booru.py | 6 ++++-- src/utils/scraper.py | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/cogs/booru.py b/src/cogs/booru.py index a432e2f..005a2fd 100644 --- a/src/cogs/booru.py +++ b/src/cogs/booru.py @@ -728,8 +728,10 @@ class MsG(cmds.Cog): except exc.Continue: continue if post['id'] not in posts.keys() and post['id'] not in previous.keys(): - posts[post['id']] = {'artist': ', '.join( - post['tags']['artist']), 'file_url': post['file']['url'], 'score': post['score']['total']} + posts[post['id']] = { + 'artist': ', '.join(post['tags']['artist']) if post['tags']['artist'] else 'unknown', + 'file_url': post['file']['url'], + 'score': post['score']['total']} if len(posts) == limit: break diff --git a/src/utils/scraper.py b/src/utils/scraper.py index 3f6539c..0cbb2c6 100644 --- a/src/utils/scraper.py +++ b/src/utils/scraper.py @@ -59,7 +59,7 @@ async def query_kheina(url): result = { 'source': content['results'][0]['sources'][0]['source'], - 'artist': content['results'][0]['sources'][0]['artist'], + 'artist': content['results'][0]['sources'][0]['artist'] if content['results'][0]['sources'][0]['artist'] else 'unknown', 'thumbnail': thumbnail, 'similarity': str(similarity), 'database': tld.extract(content['results'][0]['sources'][0]['source']).domain @@ -99,12 +99,12 @@ async def query_saucenao(url): source = e break - artist = 'Unknown' + artist = 'unknown' for e in ( 'author_name', 'member_name', 'creator'): - if e in match['data']: + if e in match['data'] and match['data'][e]: artist = match['data'][e] break