Skip to content

Commit fed55ea

Browse files
committed
🚧 Include print outputs in python script
1 parent 7f2e511 commit fed55ea

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

heardle_server/update_loona_track_info.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,20 +50,20 @@ def extract_track_from_playlist_item(item: dict):
5050
# Scrape the mp3 preview URLs manually
5151
full_track_info = []
5252
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")
5454
track_resp = requests.get(track["url"])
5555
if track_resp.status_code == 200:
5656
raw = track_resp.content.decode("utf-8")
5757
preview_re_search = re.search(r'content="(https://p\.scdn\.co/mp3-preview/.+?)"/>', raw)
5858
if preview_re_search:
5959
track["preview_url"] = preview_re_search.group(1)
6060
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")
6565

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
6767

6868
output_file = Path("~/loona_track_info.json").expanduser()
6969
json.dump(full_track_info, output_file.open("w+"), indent=2)

0 commit comments

Comments
 (0)