Added check for no likes or reposts on tracks

This commit is contained in:
Thomas Wade 2018-09-29 13:34:18 +09:30
parent 717d7ae6c0
commit 3c160b71c1

View File

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