Small fixes
Added detecting if last_track_id is equal to track_id, made things less messy in stdout
This commit is contained in:
parent
5c7ee9d8fe
commit
05e64eeafa
1 changed files with 13 additions and 9 deletions
|
@ -41,6 +41,10 @@ while True:
|
||||||
track_id = track['id']
|
track_id = track['id']
|
||||||
|
|
||||||
# Check if the track is different from the last played track
|
# 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:
|
if track_id != last_track_id:
|
||||||
track_name = track['name']
|
track_name = track['name']
|
||||||
album_name = track['album']['name']
|
album_name = track['album']['name']
|
||||||
|
@ -68,7 +72,7 @@ while True:
|
||||||
context_url = context['external_urls']['spotify']
|
context_url = context['external_urls']['spotify']
|
||||||
|
|
||||||
# Format the message
|
# Format the message
|
||||||
description = f"**Artists**\n{artists}\n**Album**\n{album_name}\n\n<t:{current_epoch:.0f}:R>\n[Listen on Spotify]({track_url})"
|
description = f"**Artists**\n{artists}\n\n**Album**\n{album_name}\n\n<t:{current_epoch:.0f}:R>\n[Listen on Spotify]({track_url})"
|
||||||
if context_name and context_url:
|
if context_name and context_url:
|
||||||
description += f" | [{context_name}]({context_url})"
|
description += f" | [{context_name}]({context_url})"
|
||||||
description += f" | [visit the source](https://git.rintyuu.dev/rintyuu/discord-nowplaying)"
|
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
|
# Send the message to the Discord webhook
|
||||||
response = requests.post(discord_webhook_url, json=message)
|
response = requests.post(discord_webhook_url, json=message)
|
||||||
|
|
||||||
if response.status_code == 204:
|
if response.status_code == 204:
|
||||||
print("Message sent to Discord successfully.")
|
print(f"Currently playing: {track_name} by {artists}")
|
||||||
else:
|
else:
|
||||||
print(f"Failed to send message to Discord. Status code: {response.status_code}")
|
print(f"Failed to send message to Discord. Status code: {response.status_code}")
|
||||||
|
|
||||||
|
@ -99,13 +103,13 @@ while True:
|
||||||
else:
|
else:
|
||||||
print("No track is currently playing.")
|
print("No track is currently playing.")
|
||||||
|
|
||||||
if interval_start == 1 and not interval_verif:
|
#if interval_start == 1 and not interval_verif:
|
||||||
print("ignore this seconds has passed message please")
|
# print("ignore this seconds has passed message please")
|
||||||
print("im still working out the bugs in this program")
|
# print("im still working out the bugs in this program")
|
||||||
interval_start = 0
|
# interval_start = 0
|
||||||
interval_verif = True
|
# interval_verif = True
|
||||||
|
|
||||||
# Wait for a certain time before checking again (e.g., 15 seconds)
|
# 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))
|
time.sleep(int(interval))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue