diff --git a/main-experimental.py b/main-experimental.py index 49a8c01..916de76 100644 --- a/main-experimental.py +++ b/main-experimental.py @@ -41,6 +41,10 @@ while True: track_id = track['id'] # Check if the track is different from the last played track + + if track_id == last_track_id: + print("previous song is still playing") + if track_id != last_track_id: track_name = track['name'] album_name = track['album']['name'] @@ -68,7 +72,7 @@ while True: context_url = context['external_urls']['spotify'] # Format the message - description = f"**Artists**\n{artists}\n**Album**\n{album_name}\n\n\n[Listen on Spotify]({track_url})" + description = f"**Artists**\n{artists}\n\n**Album**\n{album_name}\n\n\n[Listen on Spotify]({track_url})" if context_name and context_url: description += f" | [{context_name}]({context_url})" description += f" | [visit the source](https://git.rintyuu.dev/rintyuu/discord-nowplaying)" @@ -83,13 +87,13 @@ while True: ] } - print(f"Current Epoch Time: {current_epoch:.0f}") + # print(f"Current Epoch Time: {current_epoch:.0f}") # Send the message to the Discord webhook response = requests.post(discord_webhook_url, json=message) if response.status_code == 204: - print("Message sent to Discord successfully.") + print(f"Currently playing: {track_name} by {artists}") else: print(f"Failed to send message to Discord. Status code: {response.status_code}") @@ -99,13 +103,13 @@ while True: else: print("No track is currently playing.") - if interval_start == 1 and not interval_verif: - print("ignore this seconds has passed message please") - print("im still working out the bugs in this program") - interval_start = 0 - interval_verif = True + #if interval_start == 1 and not interval_verif: + # print("ignore this seconds has passed message please") + # print("im still working out the bugs in this program") + # interval_start = 0 + # interval_verif = True # Wait for a certain time before checking again (e.g., 15 seconds) - print("it has been", interval,"seconds") + #print("it has been", interval,"seconds") time.sleep(int(interval))