-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathquickify.py
More file actions
36 lines (27 loc) · 948 Bytes
/
quickify.py
File metadata and controls
36 lines (27 loc) · 948 Bytes
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
import sys
import json
import re
from spotify import Spotify
from youtube import YouTube
# Parameters
spotify_playlist = "Quickify" # Set to None to sync all tracks
youtube_playlist = "Quickify"
# read config file
with open('config.json','r') as myfile:
data=myfile.read()
# parse config file
config_data = json.loads(data)
spotify = Spotify(config_data['spotify_username'], config_data['spotify_client_id'], config_data['spotify_client_secret'])
# Grab all tracks from saved tracks or specified playlist
if spotify_playlist is None:
tracks = spotify.get_saved_tracks()
else:
tracks = spotify.get_playlist_tracks(spotify_playlist)
if not tracks:
print("Spotify playlist does not exist")
exit()
# Sync playlists
print(f"Spotify playlist contains {len(tracks)} tracks")
youtube = YouTube(youtube_playlist)
print(f"YouTube playlist contains {len(youtube.videos)} videos")
youtube.sync_playlist(tracks,youtube.playlist)