Check for None before using Counter

This commit is contained in:
Thomas Wade 2018-09-30 14:59:45 +09:30
parent 99d77a574b
commit 65a5a5c63b

View File

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