def search(search_func, term = None): """ Search wrapper """ external = False if plugin.id == xbmc.getInfoLabel('Container.PluginName'): # Skip if search item isn't currently selected label = xbmc.getInfoLabel('ListItem.label') if label and not equals(label, _("Search")): return else: external = True if term is None: # Get search keyword search_entered = plugin.keyboard(heading=_("search for")) if not search_entered: return else: search_entered = term # Perform search url = plugin.url_for(search_func, term=search_entered, page='1') if external: xbmc.executebuiltin('ActivateWindow(10025,"plugin://%s/",return)' % plugin.id) xbmc.executebuiltin('Container.Update("%s")' % url) else: plugin.redirect(url)
def search(search_func, term=None): """ Search wrapper """ external = False if plugin.id == xbmc.getInfoLabel('Container.PluginName'): # Skip if search item isn't currently selected label = xbmc.getInfoLabel('ListItem.label') if label and not equals(label, _("Search")): return else: external = True if term is None: # Get search keyword search_entered = plugin.keyboard(heading=_("search for")) if not search_entered: return else: search_entered = term # Perform search url = plugin.url_for(search_func, term=search_entered, page='1') if external: xbmc.executebuiltin('ActivateWindow(10025,"plugin://%s/",return)' % plugin.id) xbmc.executebuiltin('Container.Update("%s")' % url) else: plugin.redirect(url)
def show_root(): if 'audio' in xbmc.getInfoLabel('Container.FolderPath'): content_type = 'audio' else: content_type = 'video' items = ( { 'label': _('browse_by_genre'), 'path': plugin.url_for(endpoint='show_genres', content_type=content_type) }, { 'label': _('show_my_podcasts'), 'path': plugin.url_for(endpoint='show_my_podcasts', content_type=content_type) }, { 'label': _('search_podcast'), 'path': plugin.url_for(endpoint='search', content_type=content_type) }, ) return plugin.finish(items)
def get_tvshow_metadata_tvdb(tvdb_show, banners=True): info = {} if tvdb_show is None: return info if tvdb_show['genre']: if '|' in tvdb_show['genre']: genres = tvdb_show['genre'].replace('|', ' / ') info['genre'] = genres[3:-3] info['tvdb_id'] = str(tvdb_show['id']) info['name'] = tvdb_show['seriesname'] info['title'] = tvdb_show['seriesname'] info['tvshowtitle'] = tvdb_show['seriesname'] info['originaltitle'] = tvdb_show['seriesname'] info['plot'] = tvdb_show.get('overview', '') if banners: info['poster'] = tvdb_show.get_poster(language=LANG) info['fanart'] = tvdb_show.get('fanart', '') info['rating'] = tvdb_show.get('rating') info['votes'] = tvdb_show.get('ratingcount') info['year'] = tvdb_show.get('year', 0) info['studio'] = tvdb_show.get('network', '') info['imdb_id'] = tvdb_show.get('imdb_id', '') if xbmc.getInfoLabel('System.BuildVersion')[:2] == "14": info['duration'] = int(tvdb_show.get('runtime') or 0) else: info['duration'] = int(tvdb_show.get('runtime') or 0) * 60 return info
def show_root(): # If we are on Eden get the content_type from the FolderPath # On Frodo we get the content_type from the request args if not 'content_type' in plugin.request.args: folder_path = xbmc.getInfoLabel('Container.FolderPath') if 'video' in folder_path: content_type = ('video', ) elif 'audio' in folder_path: content_type = ('audio', ) else: content_type = plugin.request.args['content_type'] if isinstance(content_type, (list, tuple)): content_type = content_type[0] items = ( {'label': _('browse_by_genre'), 'path': plugin.url_for( endpoint='show_genres', content_type=content_type )}, {'label': _('show_my_podcasts'), 'path': plugin.url_for( endpoint='show_my_podcasts', content_type=content_type )}, {'label': _('search_podcast'), 'path': plugin.url_for( endpoint='search', content_type=content_type )}, ) return plugin.finish(items)
def get_trakt_movie_metadata(movie, genres_dict=None): info = {} info['title'] = movie['title'] info['year'] = movie['year'] info['name'] = u'%s (%s)' % (info['title'], info['year']) info['premiered'] = movie.get('released') info['rating'] = movie.get('rating') info['votes'] = movie.get('votes') info['tagline'] = movie.get('tagline') info['plot'] = movie.get('overview') if xbmc.getInfoLabel('System.BuildVersion')[:2] == "14": info['duration'] = int(movie.get('runtime') or 0) else: info['duration'] = (movie.get('runtime') or 0) * 60 info['mpaa'] = movie.get('certification') info['playcount'] = movie.get('plays') if not info['playcount'] and movie.get('watched'): info['playcount'] = 1 info['tmdb'] = movie['ids'].get('tmdb') info['trakt_id'] = movie['ids'].get('trakt_id') info['imdb_id'] = movie['ids'].get('imdb') if info['tmdb'] == None: info['tmdb'] = "" if info['trakt_id'] == None: info['trakt_id'] = "" if info['imdb_id'] == None: info['imdb_id'] = "" images = item_images("movie", tmdb_id=info['tmdb'], imdb_id=info['imdb_id'], name=info['title']) info['poster'] = images[0] info['fanart'] = images[1] if 'genres' in movie: if genres_dict: info['genre'] = u' / '.join([genres_dict[x] for x in movie['genres']]) else: info['genre'] = "" if movie.get('trailer'): info['trailer'] = make_trailer(movie['trailer']) if not info['playcount'] and movie.get('watched'): info['playcount'] = 1 return info
def __init__(self): control_background = xbmcgui.ControlImage(0, 0, 1280, 720, plugin.addon.getAddonInfo('fanart')) self.addControl(control_background) fanart = xbmc.getInfoLabel('ListItem.Property(Fanart_Image)') if fanart and fanart != "Fanart_Image": control_fanart = xbmcgui.ControlImage(0, 0, 1280, 720, fanart) self.addControl(control_fanart)
def action_prerun(link): # xbmc.executebuiltin('ActivateWindow(10025,addons://user/xbmc.addon.video/plugin.video.zen/,return)') if link.startswith("plugin://"): id = link.split("/") xbmc.executebuiltin('RunAddon(%s)' % id[2]) while xbmc.getInfoLabel('Container.PluginName') != id[2] or xbmc.getCondVisibility('Window.IsActive(busydialog)'): xbmc.sleep(250) xbmc.sleep(250) xbmc.executebuiltin('Container.Update("%s")' % link)
def __init__(self): control_background = xbmcgui.ControlImage( 0, 0, 1280, 720, plugin.addon.getAddonInfo('fanart')) self.addControl(control_background) fanart = xbmc.getInfoLabel('ListItem.Property(Fanart_Image)') if fanart and fanart != "Fanart_Image": control_fanart = xbmcgui.ControlImage(0, 0, 1280, 720, fanart) self.addControl(control_fanart)
def action_prerun(link): # xbmc.executebuiltin('ActivateWindow(10025,addons://user/xbmc.addon.video/plugin.video.zen/,return)') if link.startswith("plugin://"): id = link.split("/") xbmc.executebuiltin('RunAddon(%s)' % id[2]) while xbmc.getInfoLabel('Container.PluginName') != id[ 2] or xbmc.getCondVisibility('Window.IsActive(busydialog)'): xbmc.sleep(250) xbmc.sleep(250) xbmc.executebuiltin('Container.Update("%s")' % link)
def __getitem__(self, key): if key in self: # Key is an episode, return it return dict.__getitem__(self, key) if key in self.data: # Non-numeric request is for show-data return dict.__getitem__(self.data, key) if int(xbmc.getInfoLabel('System.BuildVersion')[:2]) > 17: message = _("{0:s} not found").format(key) else: message = _("%s not found") % key raise Exception("%s not found" % key)
def flat_extract(z, extract_to, members=None): if members is None: members = z.namelist() if not os.path.exists(extract_to): os.makedirs(extract_to) else: if xbmc.getInfoLabel('Window(home).Property(running)') == 'totalchappaai': empty_folder(extract_to) else: if dialogs.yesno(_("Update players"), _("Do you want to remove your existing players first?")): empty_folder(extract_to) for member in members: with contextlib.closing(z.open(member)) as source: target_path = os.path.join(extract_to, os.path.basename(member)) with open(target_path, "wb") as target: shutil.copyfileobj(source, target)
def flat_extract(z, extract_to, members=None): if members is None: members = z.namelist() if not os.path.exists(extract_to): os.makedirs(extract_to) else: if xbmc.getInfoLabel('Window(home).Property(running)') == 'totalmeta': empty_folder(extract_to) else: if dialogs.yesno(_("Update players"), _("Do you want to remove your existing players first?")): empty_folder(extract_to) for member in members: with contextlib.closing(z.open(member)) as source: target_path = os.path.join(extract_to, os.path.basename(member)) with open(target_path, "wb") as target: shutil.copyfileobj(source, target)
def action_prerun(self, link): # xbmc.executebuiltin('ActivateWindow(10025,addons://user/xbmc.addon.video/plugin.video.zen/,return)') if link.startswith("plugin://"): id = link.split("/") xbmc.executebuiltin('RunAddon(%s)' % id[2]) while xbmc.getInfoLabel( 'Container.PluginName') != id[2] or xbmc.getCondVisibility( 'Window.IsActive(busydialog)'): xbmc.sleep(250) xbmc.sleep(250) self.play(link) while xbmc.getInfoLabel( 'Container.PluginName') == id[2] and xbmc.getInfoLabel( 'Container.FolderPath') != "plugin://%s/" % id[2] and id[ 2] in xbmc.getInfoLabel('Container.FolderPath'): xbmc.sleep(250) if xbmc.getInfoLabel( 'Container.FolderPath') == "plugin://%s/" % id[2] or id[ 2] not in xbmc.getInfoLabel('Container.FolderPath'): break xbmc.executebuiltin('Container.Update("%s", replace)' % self.returnlink)
def play_episode_from_guide(id, season, episode, mode): import_tvdb() id = int(id) season = int(season) episode = int(episode) dbid = xbmc.getInfoLabel("ListItem.DBID") try: dbid = int(dbid) except: dbid = None show = tvdb[id] show_info = get_tvshow_metadata_tvdb(show, banners=False) if mode == 'select': play_plugin = ADDON_PICKER.id elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_CHANNELER, unicode) else: play_plugin = mode channelers = active_channelers("tvshows", filters = {'network': show.get('network')}) channelers = [p for p in channelers if p.id == play_plugin] or channelers if not channelers: xbmc.executebuiltin( "Action(Info)") action_cancel() return trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'], "show", show.get('year', 0)) params = {} for lang in get_needed_langs(channelers): if lang == LANG: tvdb_data = show else: tvdb_data = create_tvdb(lang)[id] if tvdb_data['seriesname'] is None: continue episode_parameters = get_episode_parameters(tvdb_data, season, episode) if episode_parameters is not None: params[lang] = episode_parameters else: msg = "{0} {1} - S{1}E{2}".format(_("No tvdb information found for"), show['seriesname'], season, episode) dialogs.ok(_("%s not found") % _("Episode information"), msg) return if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = to_unicode(params[lang]) link = on_play_video(mode, channelers, params, trakt_ids) if link: set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 'season': season, 'episode': episode})) season_info = get_season_metadata_tvdb(show_info, show[season], banners=False) episode_info = get_episode_metadata_tvdb(season_info, show[season][episode]) action_play({ 'label': episode_info['title'], 'path': link, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'properties' : {'fanart_image' : episode_info['fanart']}, })
def tvmaze_play_episode(id, season, episode, mode, title=None): title = "" try: id = int(id) except: title = id if title and title != "": url = "http://api.tvmaze.com/search/shows?q=%s" % id response = urllib.urlopen(url) shows = json.loads(response.read()) if len(shows) > 0: show = shows[0] id = show['show']['id'] url = "http://api.tvmaze.com/shows/%d?embed[]=seasons&embed[]=episodes" % int(id) response = urllib.urlopen(url) show = json.loads(response.read()) season = int(season) episode = int(episode) dbid = xbmc.getInfoLabel("ListItem.DBID") try: dbid = int(dbid) except: dbid = None if show['externals']: if show['externals']['thetvdb']: trakt_ids = get_trakt_ids("tvdb", show['externals']['thetvdb'], show['name'], "show", show['premiered'][:4]) elif show['externals']['imdb']: trakt_ids = get_trakt_ids("imdb", show['externals']['imdb'], show['name'], "show", show['premiered'][:4]) else: trakt_ids = get_trakt_ids(query=show['name'], type="show", year=show['premiered'][:4]) else: trakt_ids = get_trakt_ids(query=show['name'], type="show", year=show['premiered'][:4]) show_info = get_tvshow_metadata_tvmaze(show) preasons = show['_embedded']['seasons'] for item in preasons: if item['number'] == season: preason = item season = preasons.index(item) + 1 elif item['premiereDate'] and item['endDate']: if int(item['premiereDate'][:4]) <= season and int(item['endDate'][:4]) >= season: preason = item season = preasons.index(item) + 1 prepisodes = show['_embedded']['episodes'] for item in prepisodes: if item['number'] == episode: prepisode = item season_info = get_season_metadata_tvmaze(show_info, preason) episode_info = get_episode_metadata_tvmaze(season_info, prepisode) if show_info['poster'] != None and show_info['poster'] != "": show_poster = show_info['poster'] else: show_poster = "" if show_info['fanart'] != None and show_info['fanart'] != "": show_fanart = show_info['fanart'] else: show_fanart = "" items = [] if mode == 'select': play_plugin = ADDON_SELECTOR.id elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode) elif mode == 'library': play_plugin = get_tv_player_plugin_from_library(id) if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode) elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode) else: play_plugin = mode if mode == 'default' or mode == 'select': players = active_players("tvshows") else: players = get_players("tvshows") players = [p for p in players if p.id == play_plugin] or players if not players: return xbmc.executebuiltin( "Action(Info)") params = {} for lang in get_needed_langs(players): if show['name'] is None: continue episode_parameters = get_tvmaze_episode_parameters(show, preason, prepisode) if episode_parameters is not None: params[lang] = episode_parameters else: if trakt_ids["tmdb"] != None and trakt_ids["tmdb"] != "" and tried != "tmdb": tried = "tmdb" return tvdb_play_episode(trakt_ids["tvdb"], season, episode, mode) elif tried == "tmdb": msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode) dialogs.ok(_("%s not found") % _("Episode information"), msg) return else: msg = "{0} {1} - S{2}E{3}".format(_("No TMDb information found for"), show_info['name'], season, episode) dialogs.ok(_("%s not found") % _("Episode information"), msg) return if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = to_unicode(params[lang]) link = on_play_video(mode, players, params, trakt_ids) if link: set_property("data", json.dumps({'dbid': dbid, 'tvdb': trakt_ids['tvdb'], 'season': season, 'episode': episode})) episode_metadata = get_episode_metadata_tvmaze(season_info, prepisode) action_play({ 'label': episode_info['title'], 'path': link, 'info': [], 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'properties' : {'fanart_image' : str(show_info['fanart'])}, })
def trakt_play_episode(id, season, episode, mode): from trakt import trakt id = int(id) season = int(season) episode = int(episode) show = None preason = None prepisode = None dbid = xbmc.getInfoLabel("ListItem.DBID") try: dbid = int(dbid) except: dbid = None show = trakt.get_show(id) if 'name' in show: show_title = show['name'] elif 'title' in show: show_title = show['title'] if show: if show['first_aired']: year = show['first_aired'][:4] else: year = None trakt_ids = get_trakt_ids("trakt", id, show_title, "show", year) preason = trakt.get_season(id, season) if preason: prepisode = trakt.get_episode(id, season, episode) elif not preason and season > 1900: seasons = trakt.get_seasons(id) for item in seasons: if item['first_aired'] != None: if int(item['first_aired'][:4]) == season: season_number = item['number'] preason = trakt.get_season(id, season_number) if not prepisode or not preason or not show: return tvmaze_play_episode(show_title, season, episode, mode) show_info = get_tvshow_metadata_trakt(show) season_info = get_season_metadata_trakt(show_info, preason) episode_info = get_episode_metadata_trakt(season_info, prepisode) title = show_info['name'] if show_info['poster'] != None and show_info['poster'] != "": show_poster = show_info['poster'] else: show_poster = "" if show_info['fanart'] != None and show_info['fanart'] != "": show_fanart = show_info['fanart'] else: show_fanart = "" items = [] if mode == 'select': play_plugin = ADDON_SELECTOR.id elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode) elif mode == 'library': play_plugin = get_tv_player_plugin_from_library(id) if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode) elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode) else: play_plugin = mode if mode == 'default' or mode == 'select': players = active_players("tvshows") else: players = get_players("tvshows") players = [p for p in players if p.id == play_plugin] or players if not players: return xbmc.executebuiltin( "Action(Info)") params = {} for lang in get_needed_langs(players): if show['name'] is None: continue episode_parameters = get_trakt_episode_parameters(show, preason, prepisode) if episode_parameters is not None: params[lang] = episode_parameters else: if trakt_ids["tmdb"] != None and trakt_ids["tmdb"] != "" and tried != "tmdb": tried = "tmdb" return tvdb_play_episode(trakt_ids["tvdb"], season, episode, mode) elif tried == "tmdb": msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode) dialogs.ok(_("%s not found") % _("Episode information"), msg) return else: msg = "{0} {1} - S{2}E{3}".format(_("No TMDb information found for"), show_info['name'], season, episode) dialogs.ok(_("%s not found") % _("Episode information"), msg) return if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = to_unicode(params[lang]) link = on_play_video(mode, players, params, trakt_ids) if link: set_property("data", json.dumps({'dbid': dbid, 'trakt': id, 'season': season, 'episode': episode})) episode_metadata = get_episode_metadata_trakt(season_info, prepisode) action_play({ 'label': episode_info['title'], 'path': link, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'properties' : {'fanart_image' : str(show_info['fanart'])}, })
def play_episode(id, season, episode, mode): import_tvdb() id = int(id) season = int(season) episode = int(episode) # Get database id dbid = xbmc.getInfoLabel("ListItem.DBID") try: dbid = int(dbid) except: dbid = None # Get show data from TVDB show = tvdb[id] show_info = get_tvshow_metadata_tvdb(show, banners=False) # Get players to use if mode == 'select': play_plugin = ADDON_SELECTOR.id elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode) elif mode == 'library': play_plugin = get_tv_player_plugin_from_library(id) if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode) elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode) else: play_plugin = mode if mode == 'default' or mode == 'select': players = active_players("tvshows", filters = {'network': show.get('network')}) else: players = get_players("tvshows", filters = {'network': show.get('network')}) players = [p for p in players if p.id == play_plugin] or players if not players: return xbmc.executebuiltin( "Action(Info)") # Get show ids from Trakt trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'], "show", show.get('year', 0)) # Get parameters params = {} for lang in get_needed_langs(players): if lang == LANG: tvdb_data = show else: tvdb_data = create_tvdb(lang)[id] if tvdb_data['seriesname'] is None: continue episode_parameters = get_episode_parameters(tvdb_data, season, episode) if episode_parameters is not None: params[lang] = episode_parameters else: if trakt_ids["tmdb"] != None and trakt_ids["tmdb"] != "": return tmdb_play_episode(trakt_ids["tmdb"], season, episode, mode) elif trakt_ids["tvdb"] == None or trakt_ids["tvdb"] == "": msg = "{0} {1} - S{2}E{3}".format(_("No TVDb information found for"), show_info['name'], season, episode) return dialogs.ok(_("%s not found") % _("Episode information"), msg) else: msg = "{0} {1} - S{2}E{3}".format(_("No TVDb or TMDb information found for"), show_info['name'], season, episode) return dialogs.ok(_("%s not found") % _("Episode information"), msg) if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = to_unicode(params[lang]) # Go for it link = on_play_video(mode, players, params, trakt_ids) if link: # set properties set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 'season': season, 'episode': episode})) # Play season_info = get_season_metadata_tvdb(show_info, show[season], banners=False) episode_info = get_episode_metadata_tvdb(season_info, show[season][episode]) action_play({ 'label': episode_info['title'], 'path': link, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'properties' : {'fanart_image' : episode_info['fanart']}, })
def tmdb_play_episode(id, season, episode, mode): tried = "tvdb" import_tmdb() id = int(id) season = int(season) episode = int(episode) dbid = xbmc.getInfoLabel("ListItem.DBID") try: dbid = int(dbid) except: dbid = None show = tmdb.TV(id).info(language=LANG, append_to_response="external_ids,images,similar,videos") if 'first_air_date' in show and show['first_air_date'] != None: year = show['first_air_date'][:4] else: year = None trakt_ids = get_trakt_ids("tmdb", id) if "status_code" in show: return trakt_play_episode(trakt_ids["trakt"], season, episode, mode) if 'name' in show: title = show['name'] else: title = None show_info = get_tvshow_metadata_tmdb(show) title = show_info['name'] preason = tmdb.TV_Seasons(id, season).info(language=LANG, append_to_response="external_ids,images,similar,videos") if "The resource you requested could not be found" in str(preason): return trakt_play_episode(trakt_ids["trakt"], season, episode, mode) season_info = get_season_metadata_tmdb(show_info, preason) prepisode = tmdb.TV_Episodes(id, season, episode).info(language=LANG, append_to_response="external_ids,images,similar,videos") if prepisode == "{u'status_code': 34, u'status_message': u'The resource you requested could not be found.'}": return trakt_play_episode(trakt_ids["tmdb"], season, episode, mode) episode_info = get_episode_metadata_tmdb(season_info, prepisode) if show_info['poster'] != None and show_info['poster'] != "": show_poster = show_info['poster'] else: show_poster = "" if show_info['fanart'] != None and show_info['fanart'] != "": show_fanart = show_info['fanart'] else: show_fanart = "" episodes = preason['episodes'] items = [] if mode == 'select': play_plugin = ADDON_SELECTOR.id elif mode == 'context': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_CONTEXT, unicode) elif mode == 'library': play_plugin = get_tv_player_plugin_from_library(id) if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY, unicode) elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER, unicode) else: play_plugin = mode if mode == 'default' or mode == 'select': players = active_players("tvshows") else: players = get_players("tvshows") players = [p for p in players if p.id == play_plugin] or players if not players: return xbmc.executebuiltin( "Action(Info)") trakt_ids = get_trakt_ids("tmdb", id, show_info['name'], "show", show['first_air_date'][:4]) params = {} for lang in get_needed_langs(players): if show['name'] is None: continue episode_parameters = get_tmdb_episode_parameters(show, preason, prepisode) if episode_parameters is not None: params[lang] = episode_parameters else: if trakt_ids["trakt"] != None and trakt_ids["trakt"] != "": return trakt_play_episode(trakt_ids["trakt"], season, episode, mode) else: msg = "{0} {1} - S{2}E{3}".format(_("No TMDb information found for"), show_info['name'], season, episode) dialogs.ok(_("%s not found") % _("Episode information"), msg) return if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = to_unicode(params[lang]) link = on_play_video(mode, players, params, trakt_ids) if link: set_property("data", json.dumps({'dbid': dbid, 'tmdb': id, 'season': season, 'episode': episode})) episode_metadata = get_episode_metadata_tmdb(season_info, prepisode) action_play({ 'label': episode_info['title'], 'path': link, 'info': [], 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'properties' : {'fanart_image' : str(show_info['fanart'])}, })
def get_xbmc_version(self): try: from xbmcswift2 import xbmc return xbmc.getInfoLabel( "System.BuildVersion" ) except: return 'Unknown'
def __init__(self): xbmc.Player.__init__(self) self.returnlink = xbmc.getInfoLabel('Container.FolderPath') xbmc.log("returnlink: " + repr(self.returnlink), xbmc.LOGNOTICE)
def play_episode(id, season, episode, mode): import_tvdb() id = int(id) season = int(season) episode = int(episode) # Get database id dbid = xbmc.getInfoLabel("ListItem.DBID") try: dbid = int(dbid) except: dbid = None # Get show data from TVDB show = tvdb[id] show_info = get_tvshow_metadata_tvdb(show, banners=False) # Get active players players = active_players("tvshows", filters = {'network': show.get('network')}) if not players: xbmc.executebuiltin( "Action(Info)") action_cancel() return # Get player to use if mode == 'select': play_plugin = ADDON_SELECTOR.id elif mode == 'library': play_plugin = get_player_plugin_from_library(id) if not play_plugin: play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY) else: play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER) # Use just selected player if exists (selectors excluded) players = [p for p in players if p.id == play_plugin] or players # Get show ids from Trakt trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'], "show", show.get('year', 0)) # Preload params params = {} for lang in get_needed_langs(players): if lang == LANG: tvdb_data = show else: tvdb_data = create_tvdb(lang)[id] if tvdb_data['seriesname'] is None: continue params[lang] = get_episode_parameters(tvdb_data, season, episode) params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = to_unicode(params[lang]) # BETA action_cancel() # Get single video selection use_simple_selector = plugin.get_setting(SETTING_USE_SIMPLE_SELECTOR, converter=bool) selection = get_video_link(players, params, mode, use_simple_selector) if not selection: #action_cancel() return # Get selection details link = selection['path'] action = selection.get('action', '') plugin.log.info('Playing url: %s' % link.encode('utf-8')) # Activate link if action == "ACTIVATE": action_activate(link) else: # Build list item (needed just for playback from widgets) season_info = get_season_metadata_tvdb(show_info, show[season], banners=False) episode_info = get_episode_metadata_tvdb(season_info, show[season][episode]) listitem = { 'label': episode_info['title'], 'path': link, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'properties' : {'fanart_image' : episode_info['fanart']}, } # set properties if trakt_ids: set_property('script.trakt.ids', json.dumps(trakt_ids)) set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 'season': season, 'episode': episode})) # Play if action == "PLAY": action_play(listitem) else: action_resolve(listitem)
def play_episode_from_guide(id, season, episode, mode): import_tvdb() id = int(id) season = int(season) episode = int(episode) dbid = xbmc.getInfoLabel("ListItem.DBID") try: dbid = int(dbid) except: dbid = None show = tvdb[id] show_info = get_tvshow_metadata_tvdb(show, banners=False) if mode == 'select': play_plugin = ADDON_PICKER.id elif mode == 'default': play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_CHANNELER) else: play_plugin = mode channelers = active_channelers("tvshows", filters = {'network': show.get('network')}) channelers = [p for p in channelers if p.id == play_plugin] or channelers if not channelers: xbmc.executebuiltin( "Action(Info)") action_cancel() return trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'], "show", show.get('year', 0)) params = {} for lang in get_needed_langs(channelers): if lang == LANG: tvdb_data = show else: tvdb_data = create_tvdb(lang)[id] if tvdb_data['seriesname'] is None: continue episode_parameters = get_episode_parameters(tvdb_data, season, episode) if episode_parameters is not None: params[lang] = episode_parameters else: msg = "{0} {1} - S{1}E{2}".format(_("No tvdb information found for"), show['seriesname'], season, episode) dialogs.ok(_("Episode info not found"), msg) return if trakt_ids != None: params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = to_unicode(params[lang]) link = on_play_video(mode, channelers, params, trakt_ids) if link: set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 'season': season, 'episode': episode})) season_info = get_season_metadata_tvdb(show_info, show[season], banners=False) episode_info = get_episode_metadata_tvdb(season_info, show[season][episode]) action_play({ 'label': episode_info['title'], 'path': link, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'properties' : {'fanart_image' : episode_info['fanart']}, })
def play_episode(id, season, episode, mode): import_tvdb() id = int(id) season = int(season) episode = int(episode) # Get database id dbid = xbmc.getInfoLabel("ListItem.DBID") try: dbid = int(dbid) except: dbid = None # Get show data from TVDB show = tvdb[id] show_info = get_tvshow_metadata_tvdb(show, banners=False) # Get players to use if mode == 'select': play_plugin = ADDON_SELECTOR.id elif mode == 'library': play_plugin = get_player_plugin_from_library(id) if not play_plugin: play_plugin = plugin.get_setting( SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY) else: play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER) players = active_players("tvshows", filters={'network': show.get('network')}) players = [p for p in players if p.id == play_plugin] or players if not players: xbmc.executebuiltin("Action(Info)") action_cancel() return # Get show ids from Trakt trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'], "show", show.get('year', 0)) # Get parameters params = {} for lang in get_needed_langs(players): if lang == LANG: tvdb_data = show else: tvdb_data = create_tvdb(lang)[id] if tvdb_data['seriesname'] is None: continue params[lang] = get_episode_parameters(tvdb_data, season, episode) params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = to_unicode(params[lang]) # Go for it link = on_play_video(mode, players, params, trakt_ids) if link: # set properties set_property( "data", json.dumps({ 'dbid': dbid, 'tvdb': id, 'season': season, 'episode': episode })) # Play season_info = get_season_metadata_tvdb(show_info, show[season], banners=False) episode_info = get_episode_metadata_tvdb(season_info, show[season][episode]) action_play({ 'label': episode_info['title'], 'path': link, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'properties': { 'fanart_image': episode_info['fanart'] }, })
def play_episode(id, season, episode, mode): import_tvdb() id = int(id) season = int(season) episode = int(episode) # Get database id dbid = xbmc.getInfoLabel("ListItem.DBID") try: dbid = int(dbid) except: dbid = None # Get show data from TVDB show = tvdb[id] show_info = get_tvshow_metadata_tvdb(show, banners=False) # Get players to use if mode == 'select': play_plugin = ADDON_SELECTOR.id elif mode == 'library': play_plugin = get_player_plugin_from_library(id) if not play_plugin or play_plugin == "default": play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER_FROM_LIBRARY) else: play_plugin = plugin.get_setting(SETTING_TV_DEFAULT_PLAYER) players = active_players("tvshows", filters = {'network': show.get('network')}) players = [p for p in players if p.id == play_plugin] or players if not players: xbmc.executebuiltin( "Action(Info)") action_cancel() return # Get show ids from Trakt trakt_ids = get_trakt_ids("tvdb", id, show['seriesname'], "show", show.get('year', 0)) # Get parameters params = {} for lang in get_needed_langs(players): if lang == LANG: tvdb_data = show else: tvdb_data = create_tvdb(lang)[id] if tvdb_data['seriesname'] is None: continue episode_parameters = get_episode_parameters(tvdb_data, season, episode) if episode_parameters is not None: params[lang] = episode_parameters else: msg = "{0} {1} - S{1}E{2}".format(_("No tvdb information found for"), show['seriesname'], season, episode) dialogs.ok(_("Episode info not found"), msg) return params[lang].update(trakt_ids) params[lang]['info'] = show_info params[lang] = to_unicode(params[lang]) # Go for it link = on_play_video(mode, players, params, trakt_ids) if link: # set properties set_property("data", json.dumps({'dbid': dbid, 'tvdb': id, 'season': season, 'episode': episode})) # Play season_info = get_season_metadata_tvdb(show_info, show[season], banners=False) episode_info = get_episode_metadata_tvdb(season_info, show[season][episode]) action_play({ 'label': episode_info['title'], 'path': link, 'info': episode_info, 'is_playable': True, 'info_type': 'video', 'thumbnail': episode_info['poster'], 'poster': episode_info['poster'], 'properties' : {'fanart_image' : episode_info['fanart']}, })