File tree Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Expand file tree Collapse file tree 1 file changed +6
-6
lines changed Original file line number Diff line number Diff line change @@ -50,20 +50,20 @@ def extract_track_from_playlist_item(item: dict):
50
50
# Scrape the mp3 preview URLs manually
51
51
full_track_info = []
52
52
for i , track in enumerate (tracks_got ):
53
- # print(f"On track: {i+1: 3}/{len(tracks_got):03}", end="\r")
53
+ print (f"On track: { i + 1 : 3} /{ len (tracks_got ):03} " , end = "\r " )
54
54
track_resp = requests .get (track ["url" ])
55
55
if track_resp .status_code == 200 :
56
56
raw = track_resp .content .decode ("utf-8" )
57
57
preview_re_search = re .search (r'content="(https://p\.scdn\.co/mp3-preview/.+?)"/>' , raw )
58
58
if preview_re_search :
59
59
track ["preview_url" ] = preview_re_search .group (1 )
60
60
full_track_info .append (track )
61
- # else:
62
- # print(f"Failed to find preview URL for {track['name']}\n")
63
- # else:
64
- # print(f"Got non-OK {track_resp.status_code} status for {track['name']}\n")
61
+ else :
62
+ print (f"Failed to find preview URL for { track ['name' ]} \n " )
63
+ else :
64
+ print (f"Got non-OK { track_resp .status_code } status for { track ['name' ]} \n " )
65
65
66
- time .sleep (random .random () * 2 ) # to avoid spamming the page/avoid rate limiting
66
+ time .sleep (random .random () / 2 ) # to avoid spamming the page/avoid rate limiting
67
67
68
68
output_file = Path ("~/loona_track_info.json" ).expanduser ()
69
69
json .dump (full_track_info , output_file .open ("w+" ), indent = 2 )
You can’t perform that action at this time.
0 commit comments