Exemplo n.º 1
0
def run():

    youtube_client = YoutubeClient('./creds/client_secret.json')
    spotify_client = SpotifyClient(os.getenv('SPOTIFY_AUTH_TOKEN'))
    playlists = youtube_client.get_playlists()

    # ask which playlist we want to get music vids from
    for index, playlist in enumerate(playlists):
        print(f'{index} : {playlist.title}')

    choice = int(
        input('Please select the playlist  want to get music vids from'))
    chosen_playlist = playlists[choice]
    print("You chose : ", chosen_playlist.title)

    # for each playlist get the songs info from youtube
    songs = youtube_client.get_vids_from_playlists(chosen_playlist.id)
    print(f'trying to add {len(songs)}')

    # search for a song in spotify if found add it to the playlist
    for song in songs:
        spotify_song_id = spotify_client.search_for_a_song(
            song.artist, song.track)
        if spotify_song_id:
            added_song = spotify_client.add_song_to_playlist(spotify_song_id)
            if added_song:
                print(f'{song.track} added successfully !! ')

            else:
                print("sorry could not add song : ( ")

        else:
            print("song not found on Spotify :( ")
Exemplo n.º 2
0
def run():
    os.environ['SPOTIFY_AUTH_TOKEN'] = 'put spotify token here '

    # Get a list of our playlists from youtube
    youtube_client = YoutubeClient('./credentials/client_secret.json')
    spotify_client = SpotifyClient(os.getenv('SPOTIFY_AUTH_TOKEN'))
    playlists = youtube_client.get_playlists()

    # Ask whcih playlists we want to get the video from
    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}")

    # For each video in the playlist, get the song information form youtube
    songs = youtube_client.get_videos_from_playlist(chosen_playlist.id)
    print(f"Attempting to add {len(songs)} ")

    # Search for the song on spotify
    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} ")

    # If we find the song add it to our Spotify liked songs

    pass
def run():
    """
    main driver code
    """
    youtube_client = YoutubeClient('./creds/client_secret.json')
    spotify_client = SpotifyClient(SPOTIFY_API_KEY)
    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}")

    collected_songs = youtube_client.get_videos_from_playlist(
        chosen_playlist.id)
    print(f"Attempting to add {len(collected_songs)} to the spotify library")

    for song in collected_songs:
        spotify_song_id = spotify_client.search_song(song.artist, song.track)

        if spotify_song_id:
            added_flag = spotify_client.add_song_to_spotify(spotify_song_id)
            if added_flag:
                print(f"Successfully added {song.artist} - {song.track}")
Exemplo n.º 4
0
def run():
    youtube_client = YoutubeClient('client_secret.json')
    spotify_client = SpotifyClient(
        'BQCZQpa6N1lnjZtdNdkSZpG-Vwxk4zAwXG_DLGN2rOa_D6Ddq7_S6jdUOwalI2J_rU4IUaZwgZ-dVrGLfEKT1_L2WsyVR6PieIxcgOBkD1OFAE6J7OeMk-mXGKdH5Njww__7eA8lkfKDZAAV7OSRjg'
    )
    playlists = youtube_client.get_playlists()

    for index, playlist in enumerate(playlists):
        print(f'{index}: {playlist.title}')

    choice = int(input('Enter a corresponding number: '))
    chosen = playlists[choice]
    print(f'You selected {chosen.title}')

    songs = youtube_client.get_videos(chosen.id)
    print(f'Attempting to read {len(songs)}')

    for song in songs:
        sid = spotify_client.search_song(song.artist, song.track)

        if sid:
            added_song = spotify_client.add_song(sid)

            if added_song():
                print('Successful')
Exemplo n.º 5
0
def run():
    #get a list of playlist from youtube 
    youtube_client = YoutubeClient('./credits/client_id.json')
    spotify_client = SpotifyClient(os.getenv('SPOTIFY_AUTH_TOKEN'))
    playlists = youtube_client.get_playlists()

# ask which playlist we want to get the music video from  
    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} ")
Exemplo n.º 6
0
def run():
    youtube_client = YoutubeClient()
    spotify_client = SpotifyClient('/secrets/secrets.spotify_token')
    playlists = youtube_client.get_playlists()

    for index, playlist in enumerate(playlists):
        print(f"{index}: {playlist.title}")
    choice = int(input("Enter your Playlist 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.track)
        if spotify_song_id:
            added_song = spotify_client.add_song_to_spotify(spotify_song_id)
            if added_song:
                print(f"Added {song.track}")
Exemplo n.º 7
0
def run():
    youtube_client = YoutubeClient('./creds/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 = 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)} 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"Successfully added {song.artist}, {song.track}")
Exemplo n.º 8
0
def run():
    # Get youtube playlists
    youtube_client = YoutubeClient('./creds/client_secret.json')
    spotify_client = SpotifyClient(os.getenv('SPOTIFY_AUTH_TOKEN'))
    playlists = youtube_client.get_playlists()

    # Add 20 random tracks to your Liked Songs playlist
    # random_tracks = spotify_client.get_random_tracks()
    # track_ids = [track['id'] for track in random_tracks]

    # was_added_to_library = spotify_client.add_tracks_to_library(track_ids)
    # if was_added_to_library:
    #   for track in random_tracks:
    #     print(f"Added {track['name']} to your library")

    # Choose video's playlist
    # iterate through playlist and print names and position for choice
    for index, playlist in enumerate(playlists):
        print(f"{index}: {playlist.title}")
    choice = int(input("Enter your choice: "))
    chosen_playlist = playlists[choice]
    print(f"Selection: {chosen_playlist.title}")

    # Get song videos from playlist user selected
    songs = youtube_client.get_videos_from_playlist(chosen_playlist.id)
    print(f"Adding {len(songs)} songs")

    # Search Songs in Spotify
    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 Like Songs Playlist"
                )