コード例 #1
0
def download_spotify_playlist_and_queue_and_zip(playlist_name, playlist_id,
                                                add_to_playlist, create_zip):
    songs = get_songs_from_spotify_website(playlist_id)
    songs_absolute_location = []
    print(f"We got {len(songs)} songs from the Spotify playlist")
    for i, song_of_playlist in enumerate(songs):
        report_progress(i, len(songs))
        # song_of_playlist: string (artist - song)
        try:
            track_id = deezer_search(
                song_of_playlist,
                TYPE_TRACK)[0]['id']  #[0] can throw IndexError
            song = get_song_infos_from_deezer_website(TYPE_TRACK, track_id)
            absolute_filename = download_song_and_get_absolute_filename(
                TYPE_PLAYLIST, song, playlist_name)
            songs_absolute_location.append(absolute_filename)
        except (IndexError, Deezer403Exception, Deezer404Exception) as msg:
            print(msg)
            print(
                f"Could not find Spotify song ({song_of_playlist}) on Deezer?")
            # return
    update_mpd_db(songs_absolute_location, add_to_playlist)
    songs_with_m3u8_file = create_m3u8_file(songs_absolute_location)
    if create_zip:
        return [create_zip_file(songs_with_m3u8_file)]
    return make_song_paths_relative_to_mpd_root(songs_absolute_location)
コード例 #2
0
 def test_spotify_parser_invalid_playlist_url(self):
     playlist_url = "https://www.heise.de"
     with self.assertRaises(SpotifyWebsiteParserException):
         get_songs_from_spotify_website(playlist_url)
コード例 #3
0
 def test_spotify_parser_invalid_playlist_id(self):
     playlist_id = "thisdoesnotexist"
     with self.assertRaises(SpotifyWebsiteParserException):
         get_songs_from_spotify_website(playlist_id)
コード例 #4
0
 def _test_parse_spotify_playlist_website(self, playlist):
     songs = get_songs_from_spotify_website(playlist)
     self.assertIn("Cyndi Lauper Time After Time", songs)
コード例 #5
0
 def _test_parse_spotify_playlist_website(self, playlist):
     songs = get_songs_from_spotify_website(playlist)
     playlist = {
         'Gazebo I Like Chopin', 'Ryan Paris Dolce Vita ',
         'Ivana Spagna Call Me', 'Radiorama Desire', 'Baltimora Tarzan Boy',
         "Generazione Anni '80 Comanchero", 'Ken Laszlo Hey Hey Guy',
         'P. Lion Happy Children', 'Fancy Bolero', 'Fancy Lady Of Ice',
         'Miko Mission How Old Are You ', 'Scotch Disco Band',
         'Sabrina Boys - Summertime Love',
         'C.C. Catch Strangers by Night - Maxi-Version', 'Savage Only You',
         "Savage Don't Cry Tonight - Original Version",
         'Italove Strangers in the Night ', "Italove L'Amour",
         'Italove Follow Me to Mexico',
         'Savage Celebrate - Extended Version',
         'Alyne Over The Sky - Original Extended Version',
         "Den Harrow Don't Break My Heart", 'Savage Only You ',
         'Hypnosis Pulstar',
         'My Mine Hypnotic Tango - Original 12" Version',
         'Fun Fun Happy Station - Scratch Version',
         'Albert One Heart On Fire - Special Maxi Mix',
         'Airplay For Your Love',
         'M & G When I Let You Down - Extended Mix',
         "Bad Boys Blue You're a Woman", 'Bad Boys Blue Come Back And Stay',
         'The Eight Group Life Is Life', 'The Eight Group Vamos A La Playa',
         'The Eight Group The Final Countdown',
         "Modern Talking You're My Heart, You're My Soul '98 - New Version",
         'Modern Talking Cheri Cheri Lady', 'Modern Talking Brother Louie',
         "Modern Talking Geronimo's Cadillac",
         'Modern Talking Atlantis Is Calling ',
         'Modern Talking You Are Not Alone', 'Roxette Listen to Your Heart',
         'Roxette Joyride - Single Version', 'Eurythmics Sweet Dreams ',
         'Eurythmics There Must Be an Angel ',
         'Cyndi Lauper Girls Just Want to Have Fun',
         'Cyndi Lauper Time After Time', 'Sandra In The Heat Of The Night',
         'Limahl Never Ending Story', 'Samantha Fox Touch Me ',
         'Fancy Slice Me Nice - Original Version',
         'C.C. Catch I Can Lose My Heart Tonight - Extended Club Remix',
         'C.C. Catch Heartbreak Hotel', 'The Eighty Group Moonlight Shadow',
         'Erasure Always',
         "Modern Talking You Can Win If You Want - No 1 Mix '84",
         'Modern Talking In 100 Years', 'Modern Talking Jet Airliner',
         'Modern Talking Sexy Sexy Lover - Vocal Version',
         'Modern Talking China in Her Eyes - Video Version',
         'Modern Talking Win the Race - Radio Edit',
         "The Pointer Sisters I'm So Excited",
         'Captain Jack Captain Jack - Short Mix', 'a-ha Take on Me',
         'TOTO Africa', "Generazione Anni '80 Self Control",
         'Alphaville Big in Japan - Remaster', 'Michael Sembello Maniac',
         'Den Harrow Future Brain', 'Radiorama Chance To Desire ',
         'F.R. David Words', 'Desireless Voyage voyage',
         'Sandra Maria Magdalena - Remastered', 'Valerie Dore The Night',
         'Babys Gang Happy Song', 'Radiorama Aliens',
         'Babys Gang Challenger', 'Eddy Huntington Ussr',
         'Silent Circle Touch in the Night - Radio Version',
         'Kano Another Life - Original', 'Ken Laszlo Tonight',
         'Koto Visitors', 'Max Him Lady Fantasy',
         'Silent Circle Stop the Rain in the Night',
         'Alphaville Sounds Like a Melody',
         'Bad Boys Blue I Wanna Hear Your Heartbeat ',
         'Bad Boys Blue Lady In Black', 'Bad Boys Blue A World Without You',
         'Bad Boys Blue Pretty Young Girl'
     }
     self.assertEqual(playlist, set(songs))