-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.py
30 lines (22 loc) · 1000 Bytes
/
run.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
import os
from spotify_client import SpotifyClient
from youtube_client import YouTubeClient
def run():
youtube_client = YouTubeClient('./secrets/client_secret.json')
spotify_client = SpotifyClient(os.getenv('SPOTIFY_AUTH_TOKEN'))
playlists = youtube_client.get_playlists()
for index, playlist in enumerate(playlists):
print(f"{index}: {playlist.title}")
choice = int(input("Enter your choice: "))
chosen_playlist = playlists[choice]
print(f"You selected: {chosen_playlist.title}")
songs = youtube_client.get_videos_from_playlist(chosen_playlist.id)
print(f"Attempting to add {len(songs)}")
for song in songs:
spotify_song_id = spotify_client.search_song(song.artist, song.track)
if spotify_song_id:
added_song = spotify_client.add_song_to_spotify(spotify_song_id)
if added_song:
print(f"Added {song.artist} - {song.track} to your Spotify Liked Songs")
if __name__ == '__main__':
run()