Example #1
0
 def do_playlist_clear(self, line):
     '''
     Clear the playlist
     Usage: playlist_clear
         Remove all items from the current playlist.
     '''
     logger.debug('call function do_playlist_clear')
     kodi_api.playlist_clear(self.kodi_params)
 def do_playlist_clear(self, line):
     '''
     Clear the playlist
     Usage: playlist_clear
         Remove all items from the current playlist.
     '''
     logger.debug('call function do_playlist_clear')
     kodi_api.playlist_clear(self.kodi_params)
Example #3
0
 def do_play_song(self, line):
     '''
     Play a single song
     Usage: play_song [id]
         Play the song behind the id.
         Use the search functions to find the id.
         The id is optional, a song is randomly selected without it.
     '''
     logger.debug('call function do_play_song')
     song_id = parse_single_int(line)
     if not song_id:
         logger.info('no song id provided')
         song_index = random.randrange(self.nb_songs)
         logger.debug('random song index: %i', song_index)
         album_id = self.albums.keys()[album_index]
     kodi_api.playlist_clear(self.kodi_params)
     kodi_api.playlist_add(SONG, song_id, self.kodi_params)
     kodi_api.player_open(self.kodi_params)
     print
     fancy_disp.play_song(song_id, self.songs)
     print
Example #4
0
 def do_play_album(self, line):
     '''
     Play a single album
     Usage: play_album [id]
         Play the album behind the id.
         Use the albums function to find the id.
         The id is optional, an album is randomly selected without it.
     '''
     logger.debug('call function do_play_album')
     album_id = parse_single_int(line)
     if not album_id:
         logger.info('no album id provided')
         album_index = random.randrange(self.nb_albums)
         logger.debug('random album index: %i', album_index)
         album_id = self.albums.keys()[album_index]
     kodi_api.playlist_clear(self.kodi_params)
     kodi_api.playlist_add(ALBUM, album_id, self.kodi_params)
     kodi_api.player_open(self.kodi_params)
     print
     fancy_disp.play_album(album_id, self.albums)
     print
 def do_play_album(self, line):
     '''
     Play a single album
     Usage: play_album [id]
         Play the album behind the id.
         Use the albums function to find the id.
         The id is optional, an album is randomly selected without it.
     '''
     logger.debug('call function do_play_album')
     album_id = parse_single_int(line)
     if not album_id:
         logger.info('no album id provided')
         album_index = random.randrange(self.nb_albums)
         logger.debug('random album index: %i', album_index)
         album_id = self.albums.keys()[album_index]
     kodi_api.playlist_clear(self.kodi_params)
     kodi_api.playlist_add(ALBUM, album_id, self.kodi_params)
     kodi_api.player_open(self.kodi_params)
     print
     fancy_disp.play_album(album_id, self.albums)
     print
Example #6
0
 def do_playlist_tasteprofile(self, line):
     '''
     Create a playlist from echonest taste profile
     Usage: playlist_tasteprofile
         Generate and play a new playlist based on
         echonest taste profile. The current playlist
         is removed before.
     '''
     logger.debug('call function do_playlist_tasteprofile')
     profile_id = get_profile_id(self.api_key)
     while True:
         song_ids = echonest_playlist(self.api_key, profile_id)
         fancy_disp.songs_index(song_ids, self.songs)
         action = fancy_disp.validate_playlist()
         if action <> 'r':
             break
     if action == 'p':
         playback_stop(self.kodi_params)
         kodi_api.playlist_clear(self.kodi_params)
         populate_playlist(song_ids, self.kodi_params) 
         kodi_api.player_open(self.kodi_params)
     print
 def do_playlist_tasteprofile(self, line):
     '''
     Create a playlist from echonest taste profile
     Usage: playlist_tasteprofile
         Generate and play a new playlist based on
         echonest taste profile. The current playlist
         is removed before.
     '''
     logger.debug('call function do_playlist_tasteprofile')
     profile_id = get_profile_id(self.api_key)
     while True:
         song_ids = echonest_playlist(self.api_key, profile_id)
         fancy_disp.songs_index(song_ids, self.songs)
         action = fancy_disp.validate_playlist()
         if action <> 'r':
             break
     if action == 'p':
         playback_stop(self.kodi_params)
         kodi_api.playlist_clear(self.kodi_params)
         populate_playlist(song_ids, self.kodi_params)
         kodi_api.player_open(self.kodi_params)
     print
Example #8
0
 def do_play_genre(self,line):
     '''
     Start playing songs from specific genre. 
     Usage: play_genre [genre]
         The library is search for all songs with playlist is shuffled each time
     '''
     logger.debug('call function do_play_genre')
     song_ids=get_genre_search(line, self.songs)
     if len(song_ids) >= 1:
         #Listening to the same sequence is bornig, so shuffle the list each time. 
         random.shuffle(song_ids)
         #TODO check if result is empty and is really a list
         kodi_api.playlist_clear(self.kodi_params)
         #First add only one song and start playback
         kodi_api.playlist_add(SONG, song_ids[0], self.kodi_params)
         kodi_api.player_open(self.kodi_params)
         #Adding the other songs takes very long
         if len(song_ids)>=2:
             populate_playlist(song_ids[1:-1],self.kodi_params)
         else:
             logger.info("Genre %s has only one song", line)
     else:
         logger.error("Genre %s has no songs", line)
 def do_play_genre(self, line):
     '''
     Start playing songs from specific genre. 
     Usage: play_genre [genre]
         The library is search for all songs with playlist is shuffled each time
     '''
     logger.debug('call function do_play_genre')
     song_ids = get_genre_search(line, self.songs)
     if len(song_ids) >= 1:
         #Listening to the same sequence is bornig, so shuffle the list each time.
         random.shuffle(song_ids)
         #TODO check if result is empty and is really a list
         kodi_api.playlist_clear(self.kodi_params)
         #First add only one song and start playback
         kodi_api.playlist_add(SONG, song_ids[0], self.kodi_params)
         kodi_api.player_open(self.kodi_params)
         #Adding the other songs takes very long
         if len(song_ids) >= 2:
             populate_playlist(song_ids[1:-1], self.kodi_params)
         else:
             logger.info("Genre %s has only one song", line)
     else:
         logger.error("Genre %s has no songs", line)
Example #10
0
 def do_playlist_taste_seed(self, line):
     '''
     Create a playlist from echonest taste profile and seeded by a song
     Usage: playlist_tasteprofile song_id
         Generate and play a new playlist based on
         echonest taste profile. The current playlist
         is removed before.
     '''
     #TODO: function for a single logic and several pl methods
     logger.debug('call function do_playlist_tasteprofile')
     song_id = parse_single_int(line)
     profile_id = get_profile_id(self.api_key)
     while True:
         song_ids = echonest_pl_seed(self.api_key, profile_id, song_id)
         fancy_disp.songs_index(song_ids, self.songs)
         action = fancy_disp.validate_playlist()
         if action <> 'r':
             break
     if action == 'p':
         playback_stop(self.kodi_params)
         kodi_api.playlist_clear(self.kodi_params)
         populate_playlist(song_ids, self.kodi_params) 
         kodi_api.player_open(self.kodi_params)
     print
 def do_playlist_taste_seed(self, line):
     '''
     Create a playlist from echonest taste profile and seeded by a song
     Usage: playlist_tasteprofile song_id
         Generate and play a new playlist based on
         echonest taste profile. The current playlist
         is removed before.
     '''
     #TODO: function for a single logic and several pl methods
     logger.debug('call function do_playlist_tasteprofile')
     song_id = parse_single_int(line)
     profile_id = get_profile_id(self.api_key)
     while True:
         song_ids = echonest_pl_seed(self.api_key, profile_id, song_id)
         fancy_disp.songs_index(song_ids, self.songs)
         action = fancy_disp.validate_playlist()
         if action <> 'r':
             break
     if action == 'p':
         playback_stop(self.kodi_params)
         kodi_api.playlist_clear(self.kodi_params)
         populate_playlist(song_ids, self.kodi_params)
         kodi_api.player_open(self.kodi_params)
     print