You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have 3 scripts that copy auto updating playlists into archive playlists whenever they update. These have been running for years without issue. At the end of November, however, 2 of them stopped working. All three scripts are identical except for the playlist IDs.
import random
import requests
import spotipy
from spotipy.oauth2 import SpotifyOAuth
# Set up your Spotify API credentials
client_id = '**client_id**'
client_secret = '*client_secret**'
redirect_uri = 'http://localhost'
# Set up the scope required for playlist access
scope = 'playlist-read-private playlist-modify-public playlist-read-collaborative playlist-modify-private'
# Create an instance of the Spotify client with authentication
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(client_id=client_id,
client_secret=client_secret,
redirect_uri=redirect_uri,
scope=scope))
# ID of the playlist you want to archive
playlist_id = '37i9dQZEVXbh5w4wwagITP'
# ID of the archive playlist
archive_playlist_id = '3a7E4UxlsArEpCp9jBUvIG'
def telegram_bot_sendtext(bot_message):
bot_token = '**bot_token**'
bot_chatID = '**chat_id**'
send_text = 'https://api.telegram.org/bot' + bot_token + '/sendMessage?chat_id=' + bot_chatID + '&parse_mode=Markdown&text=' + bot_message
response = requests.get(send_text)
return response.json()
# Retrieve the playlist details
playlist = sp.playlist(playlist_id, fields='tracks.items.track.id')
# Retrieve the track IDs from the current playlist
track_ids = set([item['track']['id'] for item in playlist['tracks']['items']])
# Retrieve all track IDs from the archive playlist
archive_track_ids = set()
offset = 0
limit = 100
while True:
archive_playlist = sp.playlist_tracks(archive_playlist_id, offset=offset, limit=limit)
track_items = archive_playlist['items']
for item in track_items:
archive_track_ids.add(item['track']['id'])
if not archive_playlist['next']:
break
offset += limit
# Add only the new tracks from the playlist to the archive playlist
tracks_to_add = list(track_ids - archive_track_ids)
if tracks_to_add:
# Split the tracks into batches of 100 and add them to the archive playlist
for i in range(0, len(tracks_to_add), 100):
batch = tracks_to_add[i:i+100]
sp.playlist_add_items(archive_playlist_id, batch)
print(telegram_bot_sendtext(f"{len(tracks_to_add)} new tracks added to the Release Radar archive playlist."))
else:
print(telegram_bot_sendtext("No new tracks to add to the Release Radar Archive."))
The response I get back from the 2 that failis
HTTP Error for GET to https://api.spotify.com/v1/playlists/37i9dQZEVXbh5w4wwagITP with Params: {'fields': 'tracks.items.track.id', 'market': None, 'additional_types': 'track'} returned 404 due to Resource not found
Traceback (most recent call last):
File "/home/user/.local/lib/python3.12/site-packages/spotipy/client.py", line 275, in _internal_call
response.raise_for_status()
File "/usr/lib/python3/dist-packages/requests/models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://api.spotify.com/v1/playlists/37i9dQZEVXbh5w4wwagITP?fields=tracks.items.track.id&additional_types=track
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/home/user/PycharmProjects/pythonProject/Spotify/Release.py", line 37, in <module>
playlist = sp.playlist(playlist_id, fields='tracks.items.track.id')
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.12/site-packages/spotipy/client.py", line 666, in playlist
return self._get(
^^^^^^^^^^
File "/home/user/.local/lib/python3.12/site-packages/spotipy/client.py", line 327, in _get
return self._internal_call("GET", url, payload, kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/user/.local/lib/python3.12/site-packages/spotipy/client.py", line 297, in _internal_call
raise SpotifyException(
spotipy.exceptions.SpotifyException: http status: 404, code:-1 - https://api.spotify.com/v1/playlists/37i9dQZEVXbh5w4wwagITP?fields=tracks.items.track.id&additional_types=track:
Resource not found, reason: None
I have confirmed that the playlist IDs haven't changed, the ones listed above are present and correct.
Any help appreciated, as I say, these scripts have been rock solid for years, and I haven't changed anything. Also, one of them still works and is no different!!
The text was updated successfully, but these errors were encountered:
I have 3 scripts that copy auto updating playlists into archive playlists whenever they update. These have been running for years without issue. At the end of November, however, 2 of them stopped working. All three scripts are identical except for the playlist IDs.
The response I get back from the 2 that failis
I have confirmed that the playlist IDs haven't changed, the ones listed above are present and correct.
Any help appreciated, as I say, these scripts have been rock solid for years, and I haven't changed anything. Also, one of them still works and is no different!!
The text was updated successfully, but these errors were encountered: