-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
28 lines (22 loc) · 893 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
import spotify
import youtube
def main():
sp = spotify.auth()
yt = youtube.auth()
playlists = spotify.get_playlists(sp)
playlist_number = int(input("Enter the above number \
of the playlist you would like to convert:\n"))
playlist_id = playlists['items'][playlist_number]['uri']
tracks, playlist_name = spotify.get_tracks(sp, playlist_id)
playlistId = youtube.createPlaylist(yt, playlist_name)
print("\n\n\n\nAdding songs...")
for track in tracks:
videoId = youtube.search(yt, track)
response = youtube.insertIntoPlaylist(yt, playlistId, videoId)
vid_title = response['snippet']['title']
print("%s added to playlist ✓" % vid_title)
print('Playlist "%s" created!' % playlist_name)
link = "https://www.youtube.com/playlist?list=" + playlistId
print("Link:\n%s" % link)
if __name__ == "__main__":
main()