-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSpotifyFindUnavailable.py
More file actions
40 lines (32 loc) · 1.16 KB
/
SpotifyFindUnavailable.py
File metadata and controls
40 lines (32 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import spotipy
from spotipy.oauth2 import SpotifyOAuth
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(
# https://developer.spotify.com/dashboard
client_id="...",
client_secret="...",
redirect_uri="http://127.0.0.1:8080/callback",
scope="playlist-read-private user-read-private")
)
PLAYLIST_ID = "2pwdfmrLlI6aMgs6AhnKOa" # ID вашего плейлиста
print("Сканирую плейлист...")
print("-" * 50)
def check_tracks(results):
for item in results['items']:
if not item or not item.get('track'):
continue
track = item['track']
name = track.get('name', 'Unknown')
artists = ", ".join([a['name'] for a in track.get('artists', [])])
uri = track.get('uri')
if track.get('is_local'):
continue
is_playable = track.get('is_playable')
if is_playable is False:
print(f"[X] НЕДОСТУПЕН: {artists} - {name}")
print(f" URI: {uri}")
print("-" * 20)
results = sp.playlist_tracks(PLAYLIST_ID, market="from_token")
check_tracks(results)
while results['next']:
results = sp.next(results)
check_tracks(results)