Exemplo n.º 1
0
def populate_playlist(song_ids, kodi_params):
    '''Create a playlist from an array of song_id'''
    print
    print "Populating the playlist... "
    for song_id in song_ids:
        kodi_api.playlist_add(SONG, song_id, kodi_params)
    print "   ... let's rock the house!"
Exemplo n.º 2
0
def populate_playlist(song_ids, kodi_params):
    '''Create a playlist from an array of song_id'''
    print
    print "Populating the playlist... "
    for song_id in song_ids:
        kodi_api.playlist_add(SONG, song_id, kodi_params)
    print "   ... let's rock the house!"
Exemplo n.º 3
0
 def do_playlist_add(self, line):
     '''
     Add an album to the playlist
     Usage: playlist_add [id]
         Add the album id to the current playlist.
         Use the albums function to find the id.
         The id is optional, an album is randomly selected without it.
     '''
     logger.debug('call function do_playlist_add')
     album_id = parse_single_int(line)
     if not album_id:
         logger.info('no album id provided')
         album_id = random.randrange(self.nb_albums)
         #TODO: disp function
         print
         print "Album %i will be added to the playlist" % album_id
         print
     kodi_api.playlist_add(ALBUM, album_id, self.kodi_params)
Exemplo n.º 4
0
 def do_playlist_add(self, line):
     '''
     Add an album to the playlist
     Usage: playlist_add [id]
         Add the album id to the current playlist.
         Use the albums function to find the id.
         The id is optional, an album is randomly selected without it.
     '''
     logger.debug('call function do_playlist_add')
     album_id = parse_single_int(line)
     if not album_id:
         logger.info('no album id provided')
         album_id = random.randrange(self.nb_albums)
         #TODO: disp function
         print
         print "Album %i will be added to the playlist" % album_id
         print
     kodi_api.playlist_add(ALBUM, album_id, self.kodi_params)
Exemplo n.º 5
0
 def do_add_song(self, line):
     '''
     Add a single song to the playlist
     Usage: add_song [id]
         Add 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_add_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_add(SONG, song_id, self.kodi_params)
     print
     fancy_disp.add_song(song_id, self.songs)
     print
Exemplo n.º 6
0
 def do_add_album(self, line):
     '''
     Add a single album to the playlist
     Usage: add_album [id]
         Add 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_add(ALBUM, album_id, self.kodi_params)
     print
     fancy_disp.add_album(album_id, self.albums)
     print
Exemplo n.º 7
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
Exemplo n.º 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)
Exemplo n.º 9
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)