Check for None before using Counter
This commit is contained in:
parent
99d77a574b
commit
65a5a5c63b
@ -316,9 +316,12 @@ def Favourite_Tag_And_Artist(track_urls, track_db):
|
|||||||
tags.append(track_db[track].tag)
|
tags.append(track_db[track].tag)
|
||||||
artists.append(track_db[track].artist)
|
artists.append(track_db[track].artist)
|
||||||
|
|
||||||
|
if tags and artists:
|
||||||
# Return the first mode of the list, originally by Christian Witts and Rory Daulton
|
# 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
|
# 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]]
|
return [Counter(tags).most_common(1)[0][0], Counter(artists).most_common(1)[0][0]]
|
||||||
|
else:
|
||||||
|
return [None, None]
|
||||||
|
|
||||||
##### Scrape ################################################
|
##### Scrape ################################################
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user