def HandleArtist(operation=None, **params): oc = ObjectContainer(title2=unicode(L("Artist") + " " + params['name'])) media_info = MediaInfo(**params) service.queue.handle_bookmark_operation(operation, media_info) response1 = service.get_albums(artists=params['id'], limit=1, offset=0, year__gte=util.get_start_music_year(), year__lte=util.get_end_music_year()) count1 = int(response1['meta']['total_count']) if count1 > 0: new_params = { 'title': unicode(L('Albums')) + " " + params['name'], 'artists': params['id'] } oc.add( DirectoryObject( key=Callback(HandleAlbums, **new_params), title=unicode(L('Albums') + ' (' + str(count1) + ')'), thumb=media_info['thumb'])) response2 = service.get_tracks(artists=params['id'], limit=1, offset=0, year__gte=util.get_start_music_year(), year__lte=util.get_end_music_year()) count2 = int(response2['meta']['total_count']) if count2 > 0: new_params = { 'type': 'tracks', 'artists': params['id'], 'id': params['id'], 'name': L('Audio Tracks') + " " + params['name'], 'thumb': params['thumb'] } oc.add( DirectoryObject(key=Callback(HandleTracks, **new_params), title=unicode( L('Audio Tracks') + ' (' + response2['meta']['total_count'] + ')'), thumb=params['thumb'])) service.queue.append_bookmark_controls(oc, HandleArtist, media_info) return oc
def HandleDoubleAlbum(operation=None, **params): oc = ObjectContainer(title2=unicode(params['name'])) media_info = MediaInfo(**params) service.queue.handle_bookmark_operation(operation, media_info) response = service.get_albums(limit=util.get_elements_per_page(), year__gte=util.get_start_music_year(), year__lte=util.get_end_music_year(), **service.filter_request_params(params)) for media in response['objects']: id = media['id'] name = media['title'] thumb = media['thumbnail'] new_params = { 'type': 'album', 'album': id, 'id': id, 'name': name, 'thumb': thumb } key = Callback(HandleTracks, **new_params) oc.add(DirectoryObject(key=key, title=unicode(name), thumb=thumb)) service.queue.append_bookmark_controls(oc, HandleDoubleAlbum, media_info) return oc
def HandleAlbums(title, page=1, **params): oc = ObjectContainer(title2=unicode(L(title))) page = int(page) limit = util.get_elements_per_page() offset = (page-1)*limit response = service.get_albums(limit=limit, offset=offset, year__gte=util.get_start_music_year(), year__lte=util.get_end_music_year(), **service.filter_request_params(params)) oc.title2 = unicode(L(title)) + ' (' + str(response['meta']['total_count']) + ')' for media in BuildAlbumsList(response['objects']): oc.add(media) oc.add(InputDirectoryObject( key=Callback(SearchAlbums, title=unicode(L("Albums Search")), page=page), title=unicode(L("Albums Search")), thumb=R(SEARCH_ICON) )) service.add_pagination_to_response(response, page, util.get_elements_per_page()) pagination.append_controls(oc, response['data'], callback=HandleAlbums, title=title, page=page, **params) return oc
def HandleArtist(operation=None, **params): oc = ObjectContainer(title2=unicode(L("Artist") + " " + params['name'])) media_info = MediaInfo(**params) service.queue.handle_bookmark_operation(operation, media_info) response1 = service.get_albums(artists=params['id'], limit=1, offset=0, year__gte=util.get_start_music_year(), year__lte=util.get_end_music_year()) count1 = int(response1['meta']['total_count']) if count1 > 0: new_params = { 'title': unicode(L('Albums')) + " " + params['name'], 'artists': params['id'] } oc.add(DirectoryObject( key=Callback(HandleAlbums, **new_params), title=unicode(L('Albums') + ' (' + str(count1) + ')'), thumb=media_info['thumb'] )) response2 = service.get_tracks(artists=params['id'], limit=1, offset=0, year__gte=util.get_start_music_year(), year__lte=util.get_end_music_year()) count2 = int(response2['meta']['total_count']) if count2 > 0: new_params = { 'type': 'tracks', 'artists': params['id'], 'id': params['id'], 'name': L('Audio Tracks') + " " + params['name'], 'thumb': params['thumb'] } oc.add(DirectoryObject( key=Callback(HandleTracks, **new_params), title=unicode(L('Audio Tracks') + ' (' + response2['meta']['total_count'] + ')'), thumb=params['thumb'] )) service.queue.append_bookmark_controls(oc, HandleArtist, media_info) return oc
def HandleAlbums(title, page=1, **params): oc = ObjectContainer(title2=unicode(L(title))) page = int(page) limit = util.get_elements_per_page() offset = (page - 1) * limit response = service.get_albums(limit=limit, offset=offset, year__gte=util.get_start_music_year(), year__lte=util.get_end_music_year(), **service.filter_request_params(params)) oc.title2 = unicode(L(title)) + ' (' + str( response['meta']['total_count']) + ')' for media in BuildAlbumsList(response['objects']): oc.add(media) oc.add( InputDirectoryObject(key=Callback(SearchAlbums, title=unicode(L("Albums Search")), page=page), title=unicode(L("Albums Search")), thumb=R(SEARCH_ICON))) service.add_pagination_to_response(response, page, util.get_elements_per_page()) pagination.append_controls(oc, response['data'], callback=HandleAlbums, title=title, page=page, **params) return oc