def tv_play_by_name_only(name, lang): tvdb_id = get_tvdb_id_from_name(name, lang) if tvdb_id: season = None episode = None show = tv_tvshow(tvdb_id) while season is None or episode is None: # don't exit completely if pressing back from episode selector selection = dialogs.select(_("Choose season"), [item["label"] for item in show]) if selection != -1: season = show[selection]["info"]["season"] season = int(season) else: return items = [] episodes = tv_season(tvdb_id, season) for item in episodes: label = "S{0}E{1} - {2}".format(item["info"]["season"], item["info"]["episode"], to_utf8(item["info"]["title"])) if item["info"]["plot"] is not None: label += " - {0}".format(to_utf8(item["info"]["plot"])) items.append(label) selection = dialogs.select(_("Choose episode"), items) if selection != -1: episode = episodes[selection]["info"]["episode"] episode = int(episode) tv_play(tvdb_id, season, episode, "default")
def get_video_link(players, params, mode, use_simple=False): lister = Lister() # Extend parameters for lang, lang_params in params.items(): for key, value in lang_params.items(): if isinstance(value, basestring): params[lang][key + "_+"] = value.replace(" ", "+") params[lang][key + "_-"] = value.replace(" ", "-") params[lang][key + "_escaped"] = value.replace(" ", "%2520") params[lang][key + "_escaped+"] = value.replace(" ", "%252B") pDialog = None selection = None try: if len(players) > 1 and use_simple: index = dialogs.select(_("Play using..."), [player.title for player in players]) if index == -1: return None players = [players[index]] resolve_f = lambda p : resolve_player(p, lister, params) if len(players) > 1: pool_size = plugin.get_setting(SETTING_POOL_SIZE, int) populator = lambda : execute(resolve_f, players, lister.stop_flag, pool_size) selection = dialogs.select_ext(_("Play using..."), populator, len(players)) else: result = resolve_f(players[0]) if result: title, links = result if len(links) == 1: selection = links[0] else: index = dialogs.select(_("Play using..."), [x['label'] for x in links]) if index > -1: selection = links[index] else: dialogs.ok(_("Error"), _("%s not found") % _("Video")) finally: lister.stop() return selection
def guide_tv_play_by_name_only(name, lang): tvdb_id = get_tvdb_id_from_name(name, lang) if tvdb_id: season = None episode = None show = tv_tvshow(tvdb_id) while season is None or episode is None: selection = dialogs.select(_("Choose season"), [item["label"] for item in show]) if selection != -1: season = show[selection]["info"]["season"] season = int(season) else: return items = [] episodes = tv_season(tvdb_id, season) for item in episodes: label = "S{0}E{1} - {2}".format(item["info"]["season"], item["info"]["episode"], to_utf8(item["info"]["title"])) if item["info"]["plot"] is not None: label += " - {0}".format(to_utf8(item["info"]["plot"])) items.append(label) selection = dialogs.select(_("Choose episode"), items) if selection != -1: episode = episodes[selection]["info"]["episode"] episode = int(episode) guide_tv_play(tvdb_id, season, episode, "default") if plugin.get_setting(SETTING_TV_PLAYED_BY_ADD, converter=bool) == True: tv_add_to_library(tvdb_id)
def get_video_link(players, params, mode, use_simple=False): lister = Lister() # Extend parameters for lang, lang_params in params.items(): for key, value in lang_params.items(): if isinstance(value, basestring): params[lang][key + "_+"] = value.replace(" ", "+") params[lang][key + "_-"] = value.replace(" ", "-") params[lang][key + "_escaped"] = value.replace(" ", "%2520") params[lang][key + "_escaped+"] = value.replace(" ", "%252B") pDialog = None selection = None try: if len(players) > 1 and use_simple: index = dialogs.select(_("Choose Your Channel..."), [player.title for player in players]) if index == -1: return None players = [players[index]] resolve_f = lambda p: resolve_player(p, lister, params) if len(players) > 1: pDialog = xbmcgui.DialogProgress() pDialog.create('Meta', 'Working...') dialogs.wait_for_dialog("progressdialog", 5) pool_size = plugin.get_setting(SETTING_POOL_SIZE, converter=int) populator = lambda: execute(resolve_f, players, lister.stop_flag, pool_size) selection = dialogs.select_ext(_("Choose Your Channel..."), populator, len(players)) else: result = resolve_f(players[0]) if result: title, links = result if len(links) == 1: selection = links[0] else: index = dialogs.select(_("Choose Your Channel..."), [x['label'] for x in links]) if index > -1: selection = links[index] else: dialogs.ok(_("Error"), _("Video not found :(")) finally: lister.stop() return selection
def movies_add_to_library(src, id): """ Add movie to library """ library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)) date = None if src == "tmdb": import_tmdb() movie = tmdb.Movies(id).info() date = date_to_timestamp(movie.get('release_date')) imdb_id = movie.get('imdb_id') if imdb_id: src = "imdb" id = imdb_id players = active_players("movies") if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True: player = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode) else: players.insert(0, ADDON_SELECTOR) players.insert(0, ADDON_DEFAULT) selection = dialogs.select(_("Play using..."), [p.title for p in players]) if selection == -1: return player = players[selection] # setup library folder library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER, unicode)) # add to library if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True: add_movie_to_library(library_folder, src, id, play_plugin=plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)) else: add_movie_to_library(library_folder, src, id, play_plugin=player.id) dialogs.notify(msg=player.id, title=_("%s not found").replace("%s ",""), delay=3000, image=get_icon_path("movies")) scan_library(type="video")
def tv_add_to_library(id): import_tvdb() show = tvdb[int(id)] # get active players players = active_players("tvshows", filters={'network': show.get('network')}) # add default and selector options players.insert(0, ADDON_SELECTOR) players.insert(0, ADDON_DEFAULT) # let the user select one player selection = dialogs.select(_("Play with..."), [p.title for p in players]) if selection == -1: return # get selected player player = players[selection] # setup library folder library_folder = setup_library( plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)) # add to library if add_tvshow_to_library(library_folder, show, player.id): set_property("clean_library", 1) # start scan scan_library()
def get_tvdb_id_from_name(name, lang): import_tvdb() search_results = tvdb.search(name, language=lang) if not search_results: dialogs.ok( _("Show not found"), "{0} {1} in tvdb".format(_("no show information found for"), to_utf8(name))) return items = [] for show in search_results: if "firstaired" in show: show["year"] = int(show['firstaired'].split("-")[0].strip()) else: show["year"] = 0 items.append(show) if len(items) > 1: selection = dialogs.select(_("Choose Show"), [ "{0} ({1})".format(to_utf8(s["seriesname"]), s["year"]) for s in items ]) else: selection = 0 if selection != -1: return items[selection]["id"]
def tv_add_to_library(id): import_tvdb() show = tvdb[int(id)] # get active players players = active_players("tvshows", filters = {'network': show.get('network')}) # add default and selector options players.insert(0, ADDON_SELECTOR) players.insert(0, ADDON_DEFAULT) # let the user select one player selection = dialogs.select(_("Play with..."), [p.title for p in players]) if selection == -1: return # get selected player player = players[selection] # setup library folder library_folder = setup_library(plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)) # add to library if add_tvshow_to_library(library_folder, show, player.id): set_property("clean_library", 1) # start scan scan_library()
def movies_add_to_library(src, id): """ Add movie to library """ library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER)) date = None if src == "tmdb": import_tmdb() movie = tmdb.Movies(id).info() date = date_to_timestamp(movie.get('release_date')) imdb_id = movie.get('imdb_id') if imdb_id: src = "imdb" id = imdb_id players = active_players("movies") if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True: player = plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode) else: players.insert(0, ADDON_SELECTOR) players.insert(0, ADDON_DEFAULT) selection = dialogs.select(_("Play with..."), [p.title for p in players]) if selection == -1: return player = players[selection] # setup library folder library_folder = setup_library(plugin.get_setting(SETTING_MOVIES_LIBRARY_FOLDER)) # add to library if plugin.get_setting(SETTING_MOVIES_DEFAULT_AUTO_ADD, bool) == True: add_movie_to_library(library_folder, src, id, play_plugin=plugin.get_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_LIBRARY, unicode)) else: add_movie_to_library(library_folder, src, id, play_plugin=ADDON_DEFAULT.id) scan_library(type="video")
def play_by_label(label): types = [_("Movies"), _("TV shows")] selection = dialogs.select(_("Choose season"), [item for item in types]) if selection == 0: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/play_by_name/{0}/en)".format(label)) else: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/play_by_name_only/{0}/en)".format(label))
def settings_set_default_channeler(media): channelers = active_channelers(media) channelers.insert(0, ADDON_PICKER) media = media.replace('es', 'e').replace('ws', 'w').replace('all', '').replace( 'os', 'o').replace('vs', 'v s') selection = dialogs.select( "{0}".format( _("Select %s") % "{0} {1}".format(_("Default").lower(), _("Player").lower())), [p.title for p in channelers]) if selection >= 0: selected = channelers[selection].id if media == "movies": plugin.set_setting(SETTING_MOVIES_DEFAULT_CHANNELER, selected) elif media == "tvshows": plugin.set_setting(SETTING_TV_DEFAULT_CHANNELER, selected) elif media == "music": plugin.set_setting(SETTING_MUSIC_DEFAULT_CHANNELER, selected) elif media == "musicvideos": plugin.set_setting(SETTING_MUSICVIDEOS_DEFAULT_CHANNELER, selected) elif media == "live": plugin.set_setting(SETTING_LIVE_DEFAULT_CHANNELER, selected) else: raise Exception("invalid parameter %s" % media)
def guide_movies_play_by_name(name, lang="en"): import_tmdb() from meta.utils.text import parse_year items = tmdb.Search().movie(query=name, language=lang, page=1)["results"] if not items: return dialogs.ok( _("%s not found") % _("Movie"), "{0} {1}".format(_("No movie information found on TMDB for"), name)) if len(items) > 1: selection = dialogs.select( "{0}".format( _("Choose thumbnail").replace( _("Thumbnail").lower(), _("Movie").lower())), [ "{0} ({1})".format(to_utf8(s["title"]), parse_year(s["release_date"])) for s in items ]) else: selection = 0 if selection != -1: id = items[selection]["id"] guide_movies_play("tmdb", id, "default") if plugin.get_setting(SETTING_MOVIES_PLAYED_BY_ADD, bool) == True: movies_add_to_library("tmdb", id)
def settings_set_default_player_fromcontext(media): players = active_players(media) players.insert(0, ADDON_SELECTOR) selection = dialogs.select( "{0}".format( _("Select %s") % "{0} {1}".format("context", _("Player").lower())), [p.title for p in players]) if selection >= 0: selected = players[selection].id if media == "movies": plugin.set_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_CONTEXT, selected) elif media == "tvshows": plugin.set_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, selected) elif media == "musicvideos": plugin.set_setting(SETTING_MUSICVIDEOS_DEFAULT_PLAYER_FROM_CONTEXT, selected) elif media == "music": plugin.set_setting(SETTING_MUSIC_DEFAULT_PLAYER_FROM_CONTEXT, selected) elif media == "live": plugin.set_setting(SETTING_LIVE_DEFAULT_PLAYER_FROM_CONTEXT, selected) else: raise Exception("invalid parameter %s" % media) plugin.open_settings()
def tv_add_to_library(id): import_tvdb() library_folder = setup_library(plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)) show = tvdb[int(id)] imdb = show['imdb_id'] # get active players players = active_players("tvshows", filters = {'network': show.get('network')}) # get selected player if plugin.get_setting(SETTING_TV_DEFAULT_AUTO_ADD, bool) == True: player = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode) else: players.insert(0, ADDON_SELECTOR) players.insert(0, ADDON_DEFAULT) selection = dialogs.select(_("Play with..."), [p.title for p in players]) if selection == -1: return player = players[selection] # setup library folder library_folder = setup_library(plugin.get_setting(SETTING_TV_LIBRARY_FOLDER)) # add to library if plugin.get_setting('tv_default_auto_add', bool): if add_tvshow_to_library(library_folder, show, player): set_property("clean_library", 1) else: if add_tvshow_to_library(library_folder, show, player.id): set_property("clean_library", 1) # start scan scan_library(type="video")
def movies_play_by_name(name, lang="en"): """ Activate tv search """ import_tmdb() from meta.utils.text import parse_year items = tmdb.Search().movie(query=name, language=lang, page=1)["results"] if not items: dialogs.ok( _("Movie not found"), "{0} {1}".format(_("No movie information found on TMDB for"), name)) return if len(items) > 1: selection = dialogs.select(_("Choose Movie"), [ "{0} ({1})".format(to_utf8(s["title"]), parse_year(s["release_date"])) for s in items ]) else: selection = 0 if selection != -1: id = items[selection]["id"] movies_play("tmdb", id, "default")
def play_by_label(label): types = [_("Movies"), _("TV shows")] selection = dialogs.select(_("Choose season"), [item for item in types]) if selection == 0: xbmc.executebuiltin( "RunPlugin(plugin://plugin.video.metalliq/movies/play_by_name/{0}/en)" .format(label)) else: xbmc.executebuiltin( "RunPlugin(plugin://plugin.video.metalliq/tv/play_by_name_only/{0}/en)" .format(label))
def live_add_to_library(channel, mode): if mode != None and plugin.get_setting(SETTING_LIVE_DEFAULT_AUTO_ADD, bool): player = mode else: players = active_players("live", filters = {'network': channel.get('network')}) players.insert(0, ADDON_SELECTOR) selection = dialogs.select(_("Play using..."), [p.title for p in players]) if selection == -1: return player = players[selection] library_folder = setup_library(plugin.get_setting(SETTING_LIVE_LIBRARY_FOLDER, unicode)) add_channel_to_library(library_folder, channel, player)
def get_list_selection(): trakt_lists = trakt.trakt_get_lists() my_lists = [] for list in trakt_lists: my_lists.append({ 'name': list["name"], 'user': list["user"]["username"], 'slug': list["ids"]["slug"] }) selection = dialogs.select(_("Select list"), [l["name"] for l in my_lists]) if selection >= 0: return my_lists[selection] return None
def guide_movies_play_by_name(name, lang = "en"): import_tmdb() from meta.utils.text import parse_year items = tmdb.Search().movie(query=name, language=lang, page=1)["results"] if not items: return dialogs.ok(_("Movie not found"), "{0} {1}".format(_("No movie information found on TMDB for"), name)) if len(items) > 1: selection = dialogs.select(_("Choose Movie"), ["{0} ({1})".format( to_utf8(s["title"]), parse_year(s["release_date"])) for s in items]) else: selection = 0 if selection != -1: id = items[selection]["id"] guide_movies_play("tmdb", id, "default") if plugin.get_setting(SETTING_MOVIES_PLAYED_BY_ADD, converter=bool) == True: movies_add_to_library("tmdb", id)
def get_video_link(players, params, mode, use_simple=False): lister = Lister() pDialog = None selection = None try: if len(players) > 1 and use_simple: index = dialogs.select(_("Play with..."), [player.title for player in players]) if index == -1: return None players = [players[index]] resolve_f = lambda p : resolve_player(p, lister, params) if len(players) > 1: pDialog = xbmcgui.DialogProgress() pDialog.create('Meta', 'Working...') dialogs.wait_for_dialog("progressdialog", 5) populator = lambda : execute(resolve_f, players, lister.stop_flag) selection = dialogs.select_ext(_("Play with..."), populator, len(players)) else: result = resolve_f(players[0]) if result: title, links = result if len(links) == 1: selection = links[0] else: index = dialogs.select(_("Play with..."), [x['label'] for x in links]) if index > -1: selection = links[index] else: dialogs.ok(_("Error"), _("Video not found :(")) finally: lister.stop() return selection
def settings_set_default_player_fromcontext(media): players = active_players(media) players.insert(0, ADDON_SELECTOR) selection = dialogs.select(_("Select player"), [p.title for p in players]) if selection >= 0: selected = players[selection].id if media == "movies": plugin.set_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_CONTEXT, selected) elif media == "tvshows": plugin.set_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, selected) else: raise Exception("invalid parameter %s" % media) plugin.open_settings()
def movies_play_by_name(name, lang = "en"): """ Activate tv search """ import_tmdb() from meta.utils.text import parse_year items = tmdb.Search().movie(query=name, language=LANG, page=1)["results"] if len(items) > 1: selection = dialogs.select(_("Choose Movie"), [to_utf8(s["title"]) + " (" + parse_year(s["release_date"]) + ")" for s in items]) else: selection = 0 if selection != -1: id = items[selection]["id"] movies_play("tmdb", id, "default")
def settings_set_default_player(media): players = active_players(media) players.insert(0, ADDON_SELECTOR) selection = dialogs.select(_("Select player"), [p.title for p in players]) if selection >= 0: selected = players[selection].id if media == "movies": plugin.set_setting(SETTING_MOVIES_DEFAULT_PLAYER, selected) elif media == "tvshows": plugin.set_setting(SETTING_TV_DEFAULT_PLAYER, selected) else: raise Exception("invalid parameter %s" % media) plugin.open_settings()
def movies_play_by_name(name, lang = "en"): """ Activate tv search """ import_tmdb() from meta.utils.text import parse_year items = tmdb.Search().movie(query=name, language=lang, page=1)["results"] if not items: return dialogs.ok(_("%s not found") % _("Movie"), "{0} {1}".format(_("No movie information found on TMDB for"), name)) if len(items) > 1: selection = dialogs.select("{0}".format(_("Choose thumbnail").replace(_("Thumbnail").lower(),_("Movie").lower())), ["{0} ({1})".format( to_utf8(s["title"]), parse_year(s["release_date"])) for s in items]) else: selection = 0 if selection != -1: id = items[selection]["id"] movies_play("tmdb", id, "context") if plugin.get_setting(SETTING_MOVIES_PLAYED_BY_ADD, bool) == True: movies_add_to_library("tmdb", id)
def set_movie_library_player(path): # get active players players = active_players("movies") players.insert(0, ADDON_SELECTOR) players.insert(0, ADDON_DEFAULT) # let the user select one player selection = dialogs.select("{0}".format(_("Select %s") % "{0} {1}".format(_("Default").lower(), _("Player").lower())), [p.title for p in players]) if selection == -1: return # get selected player player = players[selection] # Create play with file player_filepath = os.path.join(path, 'player.info') player_file = xbmcvfs.File(player_filepath, 'w') content = "{0}".format(player.id) player_file.write(content) player_file.close()
def play_by_label(label): types = [_("Movies"), _("TV shows"), _("Channels")] selection = dialogs.select( "{0} {1}".format(_("Choose"), _("Type").lower()), [item for item in types]) if selection == 0: xbmc.executebuiltin( "RunPlugin(plugin://plugin.video.metalliq/movies/play_by_name/{0}/en)" .format(label)) elif selection == 1: xbmc.executebuiltin( "RunPlugin(plugin://plugin.video.metalliq/tv/play_by_name_only/{0}/en)" .format(label)) elif selection == 2: xbmc.executebuiltin( "RunPlugin(plugin://plugin.video.metalliq/live/{0}/None/en/context)" .format(label))
def set_movie_library_player(path): # get active players players = active_players("movies") players.insert(0, ADDON_SELECTOR) players.insert(0, ADDON_DEFAULT) # let the user select one player selection = dialogs.select(_("Select default player"), [p.title for p in players]) if selection == -1: return # get selected player player = players[selection] # Create play with file player_filepath = os.path.join(path, 'player.info') player_file = xbmcvfs.File(player_filepath, 'w') content = "{0}".format(player.id) player_file.write(content) player_file.close()
def set_library_player(path): # get active players players = active_players("tvshows") players.insert(0, ADDON_SELECTOR) players.insert(0, ADDON_DEFAULT) # let the user select one player selection = dialogs.select(_("Select default player"), [p.title for p in players]) if selection == -1: return # get selected player player = players[selection] # Create Choose Your Channel...le player_filepath = os.path.join(path, 'player.info') player_file = xbmcvfs.File(player_filepath, 'w') content = "{0}".format(player.id) player_file.write(content) player_file.close()
def settings_set_default_channeler(media): channelers = active_channelers(media) channelers.insert(0, ADDON_PICKER) media = media.replace("es", "e").replace("ws", "w").replace("all", "").replace("os", "o").replace("vs", "v s") selection = dialogs.select(_("Select default " + media + " player for guide"), [p.title for p in channelers]) if selection >= 0: selected = channelers[selection].id if media == "movies": plugin.set_setting(SETTING_MOVIES_DEFAULT_CHANNELER, selected) elif media == "tvshows": plugin.set_setting(SETTING_TV_DEFAULT_CHANNELER, selected) elif media == "music": plugin.set_setting(SETTING_MUSIC_DEFAULT_CHANNELER, selected) elif media == "musicvideos": plugin.set_setting(SETTING_MUSICVIDEOS_DEFAULT_CHANNELER, selected) elif media == "live": plugin.set_setting(SETTING_LIVE_DEFAULT_CHANNELER, selected) else: raise Exception("invalid parameter %s" % media)
def settings_set_default_player(media): players = active_players(media) players.insert(0, ADDON_SELECTOR) selection = dialogs.select(_("Select player"), [p.title for p in players]) if selection >= 0: selected = players[selection].id if media == "movies": plugin.set_setting(SETTING_MOVIES_DEFAULT_PLAYER, selected) elif media == "tvshows": plugin.set_setting(SETTING_TV_DEFAULT_PLAYER, selected) elif media == "music": plugin.set_setting(SETTING_MUSIC_DEFAULT_PLAYER, selected) elif media == "musicvideos": plugin.set_setting(SETTING_MUSICVIDEOS_DEFAULT_PLAYER, selected) elif media == "live": plugin.set_setting(SETTING_LIVE_DEFAULT_PLAYER, selected) else: raise Exception("invalid parameter %s" % media) plugin.open_settings()
def settings_set_default_channeler(media): channelers = active_channelers(media) channelers.insert(0, ADDON_PICKER) media = media.replace('es','e').replace('ws','w').replace('all','').replace('os','o').replace('vs','v s') selection = dialogs.select("{0}".format(_("Select %s") % "{0} {1}".format(_("Default").lower(), _("Player").lower())), [p.title for p in channelers]) if selection >= 0: selected = channelers[selection].id if media == "movies": plugin.set_setting(SETTING_MOVIES_DEFAULT_CHANNELER, selected) elif media == "tvshows": plugin.set_setting(SETTING_TV_DEFAULT_CHANNELER, selected) elif media == "music": plugin.set_setting(SETTING_MUSIC_DEFAULT_CHANNELER, selected) elif media == "musicvideos": plugin.set_setting(SETTING_MUSICVIDEOS_DEFAULT_CHANNELER, selected) elif media == "live": plugin.set_setting(SETTING_LIVE_DEFAULT_CHANNELER, selected) else: raise Exception("invalid parameter %s" % media)
def settings_set_default_player_fromcontext(media): players = active_players(media) players.insert(0, ADDON_SELECTOR) selection = dialogs.select("{0}".format(_("Select %s") % "{0} {1}".format("context", _("Player").lower())), [p.title for p in players]) if selection >= 0: selected = players[selection].id if media == "movies": plugin.set_setting(SETTING_MOVIES_DEFAULT_PLAYER_FROM_CONTEXT, selected) elif media == "tvshows": plugin.set_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, selected) elif media == "musicvideos": plugin.set_setting(SETTING_MUSICVIDEOS_DEFAULT_PLAYER_FROM_CONTEXT, selected) elif media == "music": plugin.set_setting(SETTING_MUSIC_DEFAULT_PLAYER_FROM_CONTEXT, selected) elif media == "live": plugin.set_setting(SETTING_LIVE_DEFAULT_PLAYER_FROM_CONTEXT, selected) else: raise Exception("invalid parameter %s" % media) plugin.open_settings()
def movies_play_by_name(name, lang = "en"): """ Activate movie search """ import_tmdb() from meta.utils.text import parse_year items = tmdb.Search().movie(query=name, language=lang, page=1)["results"] if items == []: dialogs.ok(_("Movie not found"), "{0} {1}".format(_("No movie information found on TMDB for"),name)) return if len(items) > 1: selection = dialogs.select(_("Choose Movie"), ["{0} ({1})".format( to_utf8(s["title"]), parse_year(s["release_date"])) for s in items]) else: selection = 0 if selection != -1: id = items[selection]["id"] movies_play("tmdb", id, "default")
def get_tvdb_id_from_name(name, lang): import_tvdb() search_results = tvdb.search(name, language=lang) if search_results == []: dialogs.ok(_("Show not found"), "{0} {1} in tvdb".format(_("no show information found for"), to_utf8(name))) return items = [] for show in search_results: if "firstaired" in show: show["year"] = int(show['firstaired'].split("-")[0].strip()) else: show["year"] = 0 items.append(show) if len(items) > 1: selection = dialogs.select(_("Choose Show"), ["{0} ({1})".format( to_utf8(s["seriesname"]), s["year"]) for s in items]) else: selection = 0 if selection != -1: return items[selection]["id"]
def play_by_label(label): types = [_("Movies"), _("TV shows"), _("Channels")] selection = dialogs.select("{0} {1}".format(_("Choose"), _("Type").lower()), [item for item in types]) if selection == 0: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/movies/play_by_name/{0}/en)".format(label)) elif selection == 1: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/tv/play_by_name_only/{0}/en)".format(label)) elif selection == 2: xbmc.executebuiltin("RunPlugin(plugin://plugin.video.metalliq/live/{0}/None/en/context)".format(label))