-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.py
48 lines (31 loc) · 1.22 KB
/
main.py
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
41
42
43
44
45
46
import json
import funcs
class config:
class spotify:
user = "" # your spotify username
playlist_name = "Deezify" # spotify playlist name
description = "test" # spotify playlist description
token = "" # spotify bearer token
class deezer:
playlist = "" # deezer playlist id
Spotify = funcs.Spotify(config.spotify.token)
Deezer = funcs.Deezer(config.deezer.playlist)
deezer_songs = []
data = ""
while True:
playlist_resp = Deezer.get_tracks(data=data).json()
tracks = playlist_resp["data"]
for track in tracks:
print("[DEEZER] Found: " + track["title"] + " by " + track["artist"]["name"])
deezer_songs.append([track["title"], track["artist"]["name"]])
try:
data = playlist_resp["next"].split("?")[1]
except KeyError:
break
print(deezer_songs)
spotify_tracks, errors = Spotify.convert_tracks(deezer_songs)
print(spotify_tracks)
create_resp = Spotify.create_playlist(config.spotify.playlist_name, config.spotify.description)
print(create_resp.text, create_resp)
print(Spotify.add_tracks(spotify_tracks, json.loads(create_resp.text)["href"]))
print("ERROR TRACKS: " + str(errors))