forked from piyx/YoutubeToSpotify
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
27 lines (19 loc) · 816 Bytes
/
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
from spotify import Spotify
from youtube import Youtube
def main():
sp = Spotify()
yt = Youtube()
yt_playlist_id = input("Enter youtube playlist id: ")
spotify_playlist_name = input("Enter a name for your spotify playlist: ")
spotify_playlist_id = sp.create_playlist(spotify_playlist_name)
songs = yt.get_songs_from_playlist(yt_playlist_id)
for song in songs:
song_uri = sp.get_song_uri(song.artist, song.title)
if not song_uri:
print(f"{song.artist} - {song.title} was not found!")
continue
was_added = sp.add_song_to_playlist(song_uri, spotify_playlist_id)
if was_added:
print(f'{song.artist} - {song.title} was added to playlist.')
if __name__ == "__main__":
main()