Пример #1
0
    def add_playlists(self):
        pythonStart = PandoraClient("__insert_Pandora_username__", "__insert_Pandora_password__")
        pythonStart.liked_tracks()

        for station in pythonStart.station_dictionary:
            for playlist in self.session.playlist_container:
                playlist.load()
                if station in playlist.name:
                    curr_playlist = playlist 
                    break
            else:
                curr_playlist = self.session.playlist_container.add_new_playlist(station)
            for song in pythonStart.station_dictionary[station]:
                for s in curr_playlist.tracks:
                    s.load()
                    if song in s.name:
                        break
                else: 
                    try:
                        self.session.process_events()
                        search = self.session.search(song)
                        search.loaded_event.wait()
                        track = search.tracks[0]
                        curr_playlist.add_tracks(track)
                        self.session.process_events()
                        self.name_of_tracks[station] = [track.name]
                    except IndexError:
                        print song
Пример #2
0
    def update_playlists(self):
        pythonStart = PandoraClient("__insert_Pandora_username__", "__insert_Pandora_password__")
        pythonStart.liked_tracks()

        container = self.session.playlist_container
        container.load()

        for playlist in container:
            playlist.load()
            for j in pythonStart.station_dictionary:
                if (j in playlist.name):
                    count = 0
                    for track in playlist.tracks:
                        track.load()
                        if (track.name not in pythonStart.station_dictionary[j]):
                            playlist.remove_tracks(count)
                            self.session.process_events()
                        count += 1
        self.add_playlists()