From 3c160b71c17290f0741b857f0c504e40faf33829 Mon Sep 17 00:00:00 2001 From: Thomas Wade Date: Sat, 29 Sep 2018 13:34:18 +0930 Subject: [PATCH] Added check for no likes or reposts on tracks --- scrape.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/scrape.py b/scrape.py index 4c7b26e..2a49339 100755 --- a/scrape.py +++ b/scrape.py @@ -219,12 +219,20 @@ def Get_Tracks_Info(url, limit = 100): # Grab the like count like_elem = track_elem.find(class_='sc-button-like') if like_elem: - track.likes = Human_Str_To_Int(str(like_elem.string.strip())) + like_elem_text = str(like_elem.string.strip()) + if 'like' in like_elem_text.lower(): + track.likes = 0 + else: + track.likes = Human_Str_To_Int(like_elem_text) # Grab the repost count repost_elem = track_elem.find(class_='sc-button-repost') if repost_elem: - track.reposts = Human_Str_To_Int(str(repost_elem.string.strip())) + repost_elem_text = str(repost_elem.string.strip()) + if 'repost' in repost_elem_text.lower(): + track.reposts = 0 + else: + track.reposts = Human_Str_To_Int(repost_elem_text) # Finally add the track to the dictionary tracks[track.url] = track