def music_search_track_term(term, page): search_results = lastfm.search_track(term, page) tracks = search_results["trackmatches"]["track"] items_per_page = search_results["opensearch:itemsPerPage"] start_index = search_results["opensearch:startIndex"] total_results = search_results["opensearch:totalResults"] items = [] for track in tracks: large_image = track["image"][-1]["#text"] track_name = to_utf8(track["name"]) artist_name = to_utf8(track["artist"]) context_menu = [ ( _("Context player"), "PlayMedia({0})".format( plugin.url_for("music_play_audio", artist_name=artist_name, track_name=track_name, mode="context") ), ), ( _("Add to library"), "RunPlugin({0})".format( plugin.url_for("music_add_to_library", artist_name=artist_name, track_name=track_name) ), ), ( _("Musicvideo"), "RunPlugin({0})".format( plugin.url_for("music_play_video", artist_name=artist_name, track_name=track_name, mode="context") ), ), ] item = { "label": "{0} - {1}".format(artist_name, track_name), "path": plugin.url_for(music_play_audio, artist_name=artist_name, track_name=track_name), "thumbnail": large_image, "icon": "DefaultMusic.png", "poster": large_image, "info": {"artist": artist_name}, "info_type": "music", "context_menu": context_menu, } items.append(item) if start_index + items_per_page < total_results: items.append( { "label": _("Next >>"), "icon": get_icon_path("item_next"), "path": plugin.url_for(music_search_track_term, term=term, page=int(page) + 1), } ) return items
def music_search_track_term(term, page): search_results = lastfm.search_track(term, page) tracks = search_results["trackmatches"]["track"] items_per_page = search_results["opensearch:itemsPerPage"] start_index = search_results["opensearch:startIndex"] total_results = search_results["opensearch:totalResults"] items = [] for track in tracks: large_image = track["image"][-1]["#text"] track_name = to_utf8(track["name"]) artist_name = to_utf8(track["artist"]) context_menu = [ ( "{0} {1} {2}...".format(_("Select"), _("Audio").lower(), _("Stream").lower()), "PlayMedia({0})".format(plugin.url_for("music_play_audio", artist_name=artist_name, track_name=track_name, mode='context')) ), ( _("Scan item to library"), "RunPlugin({0})".format(plugin.url_for("music_add_to_library", artist_name=artist_name, track_name=track_name)) ), ( "{0} {1} {2}...".format(_("Select"), _("Video").lower(), _("Stream").lower()), "RunPlugin({0})".format(plugin.url_for("music_play_video", artist_name=artist_name, track_name=track_name, mode='context')) ) ] item = { 'label': "{0} - {1}".format(artist_name, track_name), 'path': plugin.url_for("music_play_audio", artist_name=artist_name, track_name=track_name), 'thumbnail': large_image, 'icon': "DefaultMusic.png", 'poster': large_image, 'info': { 'artist': artist_name, }, 'info_type': 'music', 'context_menu': context_menu } items.append(item) if start_index + items_per_page < total_results: items.append({ 'label': _("Next >>"), 'icon': get_icon_path("item_next"), 'path': plugin.url_for("music_search_track_term", term=term, page=int(page) + 1) }) if FORCE == True: plugin.set_view_mode(VIEW); return items else: return items