Organise tracks by url rather than artist-author mishmash
This commit is contained in:
parent
fa9517a21d
commit
9e9a56386f
10
scrape.py
10
scrape.py
@ -146,15 +146,15 @@ def Get_Tracks_Info(url, limit = 100):
|
|||||||
track.title = title_elem.span.string.strip()
|
track.title = title_elem.span.string.strip()
|
||||||
track.url = 'https://soundcloud.com' + title_elem['href']
|
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)
|
# Grab who uploaded it (usually the artist unless it's a label)
|
||||||
artist_elem = track_elem.find(class_='soundTitle__usernameText')
|
artist_elem = track_elem.find(class_='soundTitle__usernameText')
|
||||||
if artist_elem:
|
if artist_elem:
|
||||||
track.artist = artist_elem.string.strip()
|
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
|
# Grab when it was uploaded
|
||||||
date_elem = track_elem.find(class_='soundTitle__uploadTime')
|
date_elem = track_elem.find(class_='soundTitle__uploadTime')
|
||||||
if date_elem:
|
if date_elem:
|
||||||
@ -186,7 +186,7 @@ def Get_Tracks_Info(url, limit = 100):
|
|||||||
track.reposts = repost_elem.string.strip()
|
track.reposts = repost_elem.string.strip()
|
||||||
|
|
||||||
# Finally add the track to the dictionary
|
# Finally add the track to the dictionary
|
||||||
tracks[track.artist + track.title] = track
|
tracks[track.url] = track
|
||||||
|
|
||||||
print(' ' + track.artist + ' - ' + track.title)
|
print(' ' + track.artist + ' - ' + track.title)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user