From 9e9a56386fbdace13f61bc73e4b850a259ff494e Mon Sep 17 00:00:00 2001 From: Thomas Wade Date: Tue, 25 Sep 2018 17:23:53 +0930 Subject: [PATCH] Organise tracks by url rather than artist-author mishmash --- scrape.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scrape.py b/scrape.py index cd8ed2f..6042b33 100755 --- a/scrape.py +++ b/scrape.py @@ -146,15 +146,15 @@ def Get_Tracks_Info(url, limit = 100): track.title = title_elem.span.string.strip() track.url = 'https://soundcloud.com' + title_elem['href'] + # Check if we have already gotten this track before + if track.url in tracks.keys(): + continue + # Grab who uploaded it (usually the artist unless it's a label) artist_elem = track_elem.find(class_='soundTitle__usernameText') if artist_elem: track.artist = artist_elem.string.strip() - # Check if we have already gotten this track before - if str(track.artist) + str(track.title) in tracks.keys(): - continue - # Grab when it was uploaded date_elem = track_elem.find(class_='soundTitle__uploadTime') if date_elem: @@ -186,7 +186,7 @@ def Get_Tracks_Info(url, limit = 100): track.reposts = repost_elem.string.strip() # Finally add the track to the dictionary - tracks[track.artist + track.title] = track + tracks[track.url] = track print(' ' + track.artist + ' - ' + track.title)