def do_albums_recent(self, line): """ Display recently added albums Usage: albums_recent """ logger.debug('call function do_albums_recent') albumids = self.albums.keys()[-1 * DISPLAY_NB_LINES:] pkd.albums_index(albumids, self.albums) print
def do_albums_page(self, line): """ Display a given page of the albums library Usage: albums_page page """ logger.debug('call function do_albums_page') page = int(line) albumids = self.albums.keys()[(page - 1) * DISPLAY_NB_LINES:page * DISPLAY_NB_LINES] pkd.albums_index(albumids, self.albums) print
def do_albums_search(self, line): """ Search into the albums Usage: songs_search string List all albums containing the string in the title or artist. """ logger.debug('call function do_albums_search') search_string = line.lower() albumids = pk.albums_search(self.albums, search_string) pkd.albums_index(albumids, self.albums) print
def do_albums_random(self, line): """ Display a set of random albums Usage: albums_random Select random albums and display them. """ logger.debug('call function do_albums_random') indexes = random.sample(xrange(len(self.albums)), DISPLAY_NB_LINES) albumids = [self.albums.keys()[index] for index in indexes] pkd.albums_index(albumids, self.albums) print