예제 #1
0
def main():
    global playlist_name

    # spotify.test()
    tracks = parse_itunes_playlist_xml()
    print("Parsed Playlist XML")
    # print(tracks)
    spotify.add_tracks_to_playlist(tracks, playlist_name)
def run_playlist_creation():
    print("Date: " + str(datetime.datetime.today()))
    access_token = get_access_token()
    spotify.clear_playlist(access_token)
    print("Playlist cleared!")
    track_ids = get_track_ids(access_token)
    print("Retrieved " + str(len(track_ids)) + " tracks from Reddit...")
    spotify.add_tracks_to_playlist(track_ids, access_token)
    print(str(len(track_ids)) + " new tracks added to the Spotify playlist!")
    print(
        "---------------------------------------------------------------------------"
    )
    database.log_run()
def lastfm_fav_to_spotify_playlist():
    """Main method of the project that brings together other modules that are using APIs."""
    (loved_tracks, spotify_username, playlist_name) = extract_variables()

    try:
        token = spotify.generate_token()
    except spotify.TokenGenerationException:
        print('Error generating token.')  # GUI => dialog window
    else:
        sp = spotify.create_spotify_object(token)
        tracks_ids = spotify.create_spotify_tracks_ids_list_from_loved(loved_tracks, sp)
        playlist_id = spotify.create_playlist_for_user(sp, spotify_username, playlist_name)
        spotify.add_tracks_to_playlist(sp, spotify_username, playlist_id, tracks_ids)
예제 #4
0
    def test_add_tracks_to_playlist(self):
        """Method testing if adding tracks to a playlist using Spotify API was successful."""
        results = spotify.add_tracks_to_playlist(
            SpotifyTest.spotify_obj, properties.SPOTIFY_TEST_USERNAME,
            SpotifyTest.playlist_id,
            ['6NwbeybX6TDtXlpXvnUOZC', '5ahvjrjn7ymaeaWKFZrsca'])

        self.assertNotEqual(results, [])
    def test_add_tracks_to_playlist(self):
        """Method testing if adding tracks to a playlist using Spotify API was successful."""
        results = spotify.add_tracks_to_playlist(SpotifyTest.spotify_obj,
                                                 properties.SPOTIFY_TEST_USERNAME,
                                                 SpotifyTest.playlist_id,
                                                 ['6NwbeybX6TDtXlpXvnUOZC',
                                                  '5ahvjrjn7ymaeaWKFZrsca'])

        self.assertNotEqual(results, [])