From 65a5a5c63baea5476ee8445dbd4030dc5bb492c5 Mon Sep 17 00:00:00 2001 From: Thomas Wade Date: Sun, 30 Sep 2018 14:59:45 +0930 Subject: [PATCH] Check for None before using Counter --- scrape.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/scrape.py b/scrape.py index b225bb2..2aa6117 100755 --- a/scrape.py +++ b/scrape.py @@ -316,9 +316,12 @@ def Favourite_Tag_And_Artist(track_urls, track_db): tags.append(track_db[track].tag) artists.append(track_db[track].artist) - # Return the first mode of the list, originally by Christian Witts and Rory Daulton - # Found at https://stackoverflow.com/a/10797913, accessed on 2018/09/30 at 01:14 UTC - return [Counter(tags).most_common(1)[0][0], Counter(artists).most_common(1)[0][0]] + if tags and artists: + # Return the first mode of the list, originally by Christian Witts and Rory Daulton + # Found at https://stackoverflow.com/a/10797913, accessed on 2018/09/30 at 01:14 UTC + return [Counter(tags).most_common(1)[0][0], Counter(artists).most_common(1)[0][0]] + else: + return [None, None] ##### Scrape ################################################