def add_movie_to_library(self): if not xbmc.getCondVisibility('System.HasAddon(plugin.video.openmeta)'): xbmc.executebuiltin('RunPlugin(plugin://plugin.video.openmeta/setup/total)') if xbmcgui.Dialog().yesno('OpenInfo', 'Add [B]%s[/B] to library?' % self.info['title']): xbmc.executebuiltin('RunPlugin(plugin://plugin.video.openmeta/movies/add_to_library/tmdb/%s)' % self.info.get('id', '')) Utils.after_add(type='movie') Utils.notify(header='[B]%s[/B] added to library' % self.info['title'], message='Exit & re-enter to refresh', icon=self.info['poster'], time=5000, sound=False)
def __init__(self): utils.WINDOW.clearProperty("SkinHelperShutdownRequested") KodiMonitor = Kodi_Monitor() listItemMonitor = ListItemMonitor() backgroundsUpdater = BackgroundsUpdater() webService = WebService() lastSkin = None #start the extra threads listItemMonitor.start() backgroundsUpdater.start() webService.start() while not (KodiMonitor.abortRequested() or utils.WINDOW.getProperty("SkinHelperShutdownRequested")): self.checkSkinVersion() KodiMonitor.waitForAbort(10) else: # Abort was requested while waiting. We should exit utils.WINDOW.setProperty("SkinHelperShutdownRequested", "shutdown") utils.logMsg('Shutdown requested !', 0) #stop the extra threads backgroundsUpdater.stop() listItemMonitor.stop() webService.stop()
def __init__(self): KodiMonitor = Kodi_Monitor() listItemMonitor = ListItemMonitor() backgroundsUpdater = BackgroundsUpdater() webService = WebService() lastSkin = None #start the extra threads listItemMonitor.start() backgroundsUpdater.start() webService.start() while not KodiMonitor.abortRequested(): #set skin info currentSkin = xbmc.getSkinDir() if lastSkin != currentSkin: utils.setSkinVersion() lastSkin = currentSkin KodiMonitor.waitForAbort(10) else: # Abort was requested while waiting. We should exit utils.logMsg('Shutdown requested !', 0) #stop the extra threads backgroundsUpdater.stop() listItemMonitor.stop() webService.stop()
def onInit(self): self.get_youtube_vids(self.info['name']) super(DialogActorInfo, self).onInit() Utils.pass_dict_to_skin(data=self.info, prefix='actor.', window_id=self.window_id) self.fill_lists()
def __init__(self): utils.WINDOW.clearProperty("SkinHelperShutdownRequested") KodiMonitor = Kodi_Monitor() listItemMonitor = ListItemMonitor() backgroundsUpdater = BackgroundsUpdater() webService = WebService() lastSkin = None # start the extra threads listItemMonitor.start() backgroundsUpdater.start() webService.start() while not (KodiMonitor.abortRequested() or utils.WINDOW.getProperty("SkinHelperShutdownRequested")): self.checkSkinVersion() KodiMonitor.waitForAbort(10) else: # Abort was requested while waiting. We should exit utils.WINDOW.setProperty("SkinHelperShutdownRequested", "shutdown") utils.logMsg("Shutdown requested !", 0) # stop the extra threads backgroundsUpdater.stop() listItemMonitor.stop() webService.stop()
def stream(): item_id = args.get('file', '0') Utils.log('Getting stream URL for file id: '+item_id[0]) content = Api.getStreamUrl(item_id[0]) if content and content['result'] == True: player = xbmc.Player() Utils.log('Stream URL is: '+content['url']) content['url'] = content['url'] + '|User-Agent='+urllib.quote(Utils.getUserAgent())+'&' # Sending cookies with the query cookies = Api.getCookies() if len(cookies) > 0: content['url'] = content['url'] + 'Cookie=' for i in cookies: content['url'] = content['url'] + urllib.quote(i + '=' + cookies[i]+';') # Starting the playback player.play(content['url']) # If video doesn't work, raising an error time.sleep(3) if not player.isPlayingVideo(): xbmc.executebuiltin('Notification('+language(30019)+', '+language(30020)+',3000,' + addon_path + '/resources/images/error.png)') else: xbmc.executebuiltin('Notification('+language(30019)+', '+language(30020)+',3000,' + addon_path + '/resources/images/error.png)')
def open_tvshow_info(self, prev_window=None, tmdb_id=None, dbid=None, tvdb_id=None, imdb_id=None, name=None): Utils.show_busy() dbid = int(dbid) if dbid and int(dbid) > 0 else None from resources.lib.TheMovieDB import get_show_tmdb_id, search_media, play_tv_trailer from resources.lib.DialogTVShowInfo import get_tvshow_window from resources.lib.local_db import get_imdb_id_from_db if tmdb_id: pass elif tvdb_id: tmdb_id = get_show_tmdb_id(tvdb_id) elif imdb_id: tmdb_id = get_show_tmdb_id(tvdb_id=imdb_id, source='imdb_id') elif dbid: tvdb_id = get_imdb_id_from_db(media_type='tvshow', dbid=dbid) if tvdb_id: tmdb_id = get_show_tmdb_id(tvdb_id) elif name: tmdb_id = search_media(media_name=name, year='', media_type='tv') tvshow_class = get_tvshow_window(DialogXML) if Utils.NETFLIX_VIEW == 'true': dialog = tvshow_class(u'script.extendedinfo-DialogVideoInfo-Netflix.xml', Utils.ADDON_PATH, tmdb_id=tmdb_id, dbid=dbid) if Utils.AUTOPLAY_TRAILER == 'true' and not xbmc.getCondVisibility('VideoPlayer.IsFullscreen') and not xbmc.Player().isPlayingAudio(): play_tv_trailer(tmdb_id) else: if Utils.SKIN_DIR == 'skin.estuary': dialog = tvshow_class(u'script.extendedinfo-DialogVideoInfo-Estuary.xml', Utils.ADDON_PATH, tmdb_id=tmdb_id, dbid=dbid) elif Utils.SKIN_DIR == 'skin.aura' or 'skin.auramod': dialog = tvshow_class(u'script.extendedinfo-DialogVideoInfo-Aura.xml', Utils.ADDON_PATH, tmdb_id=tmdb_id, dbid=dbid) else: dialog = tvshow_class(u'script.extendedinfo-DialogVideoInfo.xml', Utils.ADDON_PATH, tmdb_id=tmdb_id, dbid=dbid) Utils.hide_busy() self.open_dialog(dialog, prev_window)
def __init__(self): KodiMonitor = Kodi_Monitor() listItemMonitor = ListItemMonitor() backgroundsUpdater = BackgroundsUpdater() webService = WebService() lastSkin = None #start the extra threads listItemMonitor.start() backgroundsUpdater.start() webService.start() while not KodiMonitor.abortRequested(): #set skin info currentSkin = xbmc.getSkinDir() if lastSkin != currentSkin: utils.setSkinVersion() lastSkin = currentSkin KodiMonitor.waitForAbort(10) else: # Abort was requested while waiting. We should exit utils.logMsg('Shutdown requested !',0) #stop the extra threads backgroundsUpdater.stop() listItemMonitor.stop() webService.stop()
def search_youtube(search_str='', hd='', limit=10, extended=True, page='', filter_str=''): if page: page = '&pageToken=' + page if hd and not hd == 'false': hd = '&hd=true' else: hd = '' search_str = '&q=' + Utils.url_quote(search_str.replace('"', '')) url = 'https://www.googleapis.com/youtube/v3/search?part=id%%2Csnippet&type=video%s%s&order=relevance&%skey=%s%s&maxResults=%i' % ( page, search_str, filter_str, API_key, hd, int(limit)) results = Utils.get_JSON_response(url=url, cache_days=0.5, folder='YouTube') videos = handle_youtube_videos(results['items'], extended=extended) if videos: info = { 'listitems': videos, 'results_per_page': results['pageInfo']['resultsPerPage'], 'total_results': results['pageInfo']['totalResults'], 'next_page_token': results.get('nextPageToken', ''), 'prev_page_token': results.get('prevPageToken', '') } return info else: return {}
def onInit(self): self.get_youtube_vids('%s tv' % self.info['title']) super(DialogTVShowInfo, self).onInit() Utils.pass_dict_to_skin(data=self.info, prefix='movie.', window_id=self.window_id) self.fill_lists()
def get_movie_tmdb_id(imdb_id=None, name=None, dbid=None): if dbid and (int(dbid) > 0): movie_id = local_db.get_imdb_id_from_db('movie', dbid) Utils.log('IMDB Id from local DB: ' + movie_id) response = get_tmdb_data( 'find/%s?external_source=imdb_id&language=%s&' % (movie_id, xbmcaddon.Addon().getSetting('LanguageID')), 30) if response['movie_results']: return response['movie_results'][0]['id'] else: Utils.notify('Could not find TMDb-id 1') return None elif imdb_id: response = get_tmdb_data( 'find/%s?external_source=imdb_id&language=%s&' % (imdb_id, xbmcaddon.Addon().getSetting('LanguageID')), 30) if 'movie_results' in response: if response['movie_results'] != None and len( response['movie_results']) > 0: try: return response['movie_results'][0]['id'] except: Utils.notify('Could not find TMDb-id 2') return None else: Utils.notify('Could not find TMDb-id 3') return None elif name: return search_media(name) else: Utils.notify('Could not find TMDb-id 4') return None
def tokenGenerator(videosource): base64string = base64.encodestring( '%s:%s' % (Utils.getUserName(), Utils.getUserPassword())).replace( '\n', '') url = 'http://gui.saan.tv/DynamicTokenGenerator.aspx?Composite=rtsp://localhost/' + videosource + '|0s|0.5147328531052358' req = urllib2.Request(url) req.add_header( 'User-Agent', 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:42.0) Gecko/20100101 Firefox/42.0' ) req.add_header('Host', 'gui.saan.tv') req.add_header( 'Accept', 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8') req.add_header('Accept-Language', 'en-GB,en;q=0.5') req.add_header('Accept-Charset', 'iso-8859-1, utf-8, utf-16, *;q=0.1') req.add_header('Accept-Encoding', 'gzip, deflate') req.add_header('Referer', 'http://gui.saan.tv/') req.add_header('Connection', 'Keep-Alive') req.add_header('Authorization', 'Basic %s' % base64string) try: handle = urllib2.urlopen(req) except IOError, e: Utils.log('IOError' + e)
def __init__(self, *args, **kwargs): if Utils.NETFLIX_VIEW == 'true': super(DialogSeasonInfo, self).__init__(*args, **kwargs) self.type = 'Season' self.tvshow_id = kwargs.get('tvshow_id') data = TheMovieDB.extended_season_info(tvshow_id=self.tvshow_id, season_number=kwargs.get('season')) if not data: return None self.info, self.data = data if 'dbid' not in self.info: self.info['poster'] = Utils.get_file(url=self.info.get('poster', '')) self.listitems = [ (2000, self.data['episodes']), (1000, self.data['actors']), (750, self.data['crew']), (1250, self.data['images']) ] else: super(DialogSeasonInfo, self).__init__(*args, **kwargs) self.type = 'Season' self.tvshow_id = kwargs.get('tvshow_id') data = TheMovieDB.extended_season_info(tvshow_id=self.tvshow_id, season_number=kwargs.get('season')) if not data: return None self.info, self.data = data if 'dbid' not in self.info: self.info['poster'] = Utils.get_file(url=self.info.get('poster', '')) self.info['ImageFilter'], self.info['ImageColor'] = ImageTools.filter_image(input_img=self.info.get('poster', ''), radius=25) self.listitems = [ (2000, self.data['episodes']), (1150, self.data['videos']), (1000, self.data['actors']), (750, self.data['crew']), (1250, self.data['images']) ]
def run(self): try: self.image, self.imagecolor = filter_image(self.filterimage, self.radius) except: self.image = '' self.imagecolor = '' Utils.log('exception. probably android PIL issue.')
def __init__(self, *args, **kwargs): if Utils.NETFLIX_VIEW == 'true': super(DialogVideoInfo, self).__init__(*args, **kwargs) self.type = 'Movie' data = TheMovieDB.extended_movie_info(movie_id=kwargs.get('id'), dbid=self.dbid) if not data: return None self.info, self.data = data sets_thread = SetItemsThread(self.info['SetId']) sets_thread.start() if 'dbid' not in self.info: self.info['poster'] = Utils.get_file(self.info.get('poster', '')) sets_thread.join() self.setinfo = sets_thread.setinfo self.data['similar'] = [i for i in self.data['similar'] if i['id'] not in sets_thread.id_list] self.listitems = [ (250, sets_thread.listitems), (1000, self.data['actors']), (750, Utils.merge_dict_lists(self.data['crew'])), (150, self.data['similar']), (550, self.data['studios']), (850, self.data['genres']), (1050, self.data['reviews']), (1250, self.data['images']), (1350, self.data['backdrops']) ] else: super(DialogVideoInfo, self).__init__(*args, **kwargs) self.type = 'Movie' data = TheMovieDB.extended_movie_info(movie_id=kwargs.get('id'), dbid=self.dbid) if not data: return None self.info, self.data = data sets_thread = SetItemsThread(self.info['SetId']) filter_thread = ImageTools.FilterImageThread(self.info.get('thumb', ''), 25) for thread in [sets_thread, filter_thread]: thread.start() if 'dbid' not in self.info: self.info['poster'] = Utils.get_file(self.info.get('poster', '')) sets_thread.join() self.setinfo = sets_thread.setinfo self.data['similar'] = [i for i in self.data['similar'] if i['id'] not in sets_thread.id_list] filter_thread.join() self.info['ImageFilter'] = filter_thread.image self.info['ImageColor'] = filter_thread.imagecolor self.listitems = [ (250, sets_thread.listitems), (150, self.data['similar']), (1150, self.data['videos']), (1000, self.data['actors']), (750, Utils.merge_dict_lists(self.data['crew'])), (550, self.data['studios']), (650, TheMovieDB.merge_with_cert_desc(self.data['releases'], 'movie')), (850, self.data['genres']), (1050, self.data['reviews']), (1250, self.data['images']), (1350, self.data['backdrops']) ]
def get_tvtrailer(tvshow_id): response = get_tmdb_data( 'tv/%s?append_to_response=videos,null,%s&language=%s&' % (tvshow_id, xbmcaddon.Addon().getSetting('LanguageID'), xbmcaddon.Addon().getSetting('LanguageID')), 30) if response and 'videos' in response and response['videos']['results']: return response['videos']['results'][0]['key'] Utils.notify('TV Show trailer not found', sound=False) return ''
def fill_lists(self): for container_id, listitems in self.listitems: try: self.getControl(container_id).reset() self.getControl(container_id).addItems( Utils.create_listitems(listitems)) except: Utils.log('Notice: No container with id %i available' % container_id)
def get_set_name_from_db(dbid): params = '{"properties": ["setid"], "movieid": %s}' % dbid json_response = Utils.get_kodi_json(method='VideoLibrary.GetMovieDetails', params=params) if 'result' in json_response and 'moviedetails' in json_response['result']: set_dbid = json_response['result']['moviedetails'].get('setid', '') if set_dbid: params = '{"setid": %s}' % set_dbid json_response = Utils.get_kodi_json(method='VideoLibrary.GetMovieSetDetails', params=params) return json_response['result']['setdetails'].get('label', '') return ''
def filter_image(input_img, radius=25): if not xbmcvfs.exists(os.path.join(Utils.IMAGES_DATA_PATH)): xbmcvfs.mkdir(os.path.join(Utils.IMAGES_DATA_PATH)) input_img = xbmc.translatePath(urllib.unquote( input_img.encode('utf-8'))).replace('image://', '') if input_img.endswith('/'): input_img = input_img[:-1] cachedthumb = xbmc.getCacheThumbName(input_img) filename = '%s-radius_%i.png' % (cachedthumb, radius) targetfile = os.path.join(Utils.IMAGES_DATA_PATH, filename) xbmc_vid_cache_file = os.path.join('special://profile/Thumbnails/Video', cachedthumb[0], cachedthumb) xbmc_cache_file = os.path.join('special://profile/Thumbnails', cachedthumb[0], cachedthumb[:-4] + '.jpg') if input_img == '': return '', '' if not xbmcvfs.exists(targetfile): img = None for i in range(1, 4): try: if xbmcvfs.exists(xbmc_cache_file): Utils.log('image already in Kodi cache: ' + xbmc_cache_file) img = Image.open(xbmc.translatePath(xbmc_cache_file)) break elif xbmcvfs.exists(xbmc_vid_cache_file): Utils.log('image already in Kodi video cache: ' + xbmc_vid_cache_file) img = Image.open(xbmc.translatePath(xbmc_vid_cache_file)) break else: xbmcvfs.copy(unicode(input_img, 'utf-8', errors='ignore'), targetfile) img = Image.open(targetfile) break except: Utils.log('Could not get image for %s (try %i)' % (input_img, i)) xbmc.sleep(200) if not img: return '', '' try: img.thumbnail((200, 200), Image.ANTIALIAS) img = img.convert('RGB') imgfilter = MyGaussianBlur(radius=radius) img = img.filter(imgfilter) img.save(targetfile) except: Utils.log('PIL problem probably....') return '', '' else: Utils.log('blurred img already created: ' + targetfile) img = Image.open(targetfile) imagecolor = get_colors(img) return targetfile, imagecolor
def onInit(self): super(DialogVideoInfo, self).onInit() Utils.pass_dict_to_skin(data=self.info, prefix='movie.', window_id=self.window_id) Utils.pass_dict_to_skin(data=self.setinfo, prefix='movie.set.', window_id=self.window_id) self.get_youtube_vids('%s %s, movie' % (self.info['Label'], self.info['year'])) self.fill_lists()
def _StartInfoActions(self): for info in self.infos: if info == 'randomcolor': HOME.setProperty(self.prefix + "ImageColor", Utils.Random_Color()) HOME.setProperty( self.prefix + "ImageCColor", Utils.Complementary_Color( HOME.getProperty(self.prefix + "ImageColor"))) elif info == 'percentage': Utils.Show_Percentage()
def handle_tmdb_images(results): images = [] for item in results: artwork = get_image_urls(poster=item.get('file_path')) image = { 'aspectratio': item['aspect_ratio'], 'vote_average': Utils.fetch(item, 'vote_average'), 'iso_639_1': Utils.fetch(item, 'iso_639_1') } image.update(artwork) images.append(image) return images
def fanart_options(self): if not self.info.get('dbid'): return None selection = xbmcgui.Dialog().select(heading='Fanart', list=['Use as fanart']) if selection == 0: path = self.listitem.getProperty('original') media_type = self.window.getProperty('type') params = '"art": {"fanart": "%s"}' % path Utils.get_kodi_json( method='VideoLibrary.Set%sDetails' % media_type, params='{ %s, "%sid":%s }' % (params, media_type.lower(), self.info['dbid']))
def __init__(self): self.allowed_domains = ["ananoos.com", ".ananoos.com"] self.api_url = sys.modules['__main__'].API_URL self.cookiejar_dir = default.addon.getSetting('cookiejar') self.cookies = {} if not os.path.isdir(self.cookiejar_dir): self.cookiejar_dir = tempfile.mkdtemp() Utils.log('Creating a new Cookiejar in '+self.cookiejar_dir) default.addon.setSetting('cookiejar', self.cookiejar_dir) self.cookiejar = self.cookiejar_dir+'/cookies.lwp' Utils.log('Using cookiejar: '+self.cookiejar)
def play_from_button(self, url, listitem, window=False, type='', dbid=0): if dbid != 0: item = '{"%s": %s}' % (type, dbid) else: item = '{"file": "%s"}' % url Utils.get_kodi_json(method='Player.Open', params='{"item": %s}' % item) for i in range(90): if xbmc.getCondVisibility('VideoPlayer.IsFullscreen'): if window and window.window_type == 'dialog': wm.add_to_stack(window) window.close() self.wait_for_video_end() return wm.pop_stack() xbmc.sleep(1000)
def get_imdb_id_from_db(media_type, dbid): if not dbid: return None if media_type == 'movie': params = '{"properties": ["imdbnumber", "title", "year"], "movieid": %s}' % dbid json_response = Utils.get_kodi_json(method='VideoLibrary.GetMovieDetails', params=params) if 'result' in json_response and 'moviedetails' in json_response['result']: return json_response['result']['moviedetails']['imdbnumber'] elif media_type == 'tvshow': params = '{"properties": ["imdbnumber", "title", "year"], "tvshowid": %s}' % dbid json_response = Utils.get_kodi_json(method='VideoLibrary.GetTVShowDetails', params=params) if 'result' in json_response and 'tvshowdetails' in json_response['result']: return json_response['result']['tvshowdetails']['imdbnumber'] return None
def _parse_argv(self): args = sys.argv self.infos = [] self.ColorBox_multis = [] for arg in args: arg = arg.replace('"', "") if arg == 'script.colorbox': continue elif arg.startswith('multis='): self.multim = Utils.Remove_Quotes(arg[7:]) self.ColorBox_multis = self.multim.split("|") elif arg.startswith('daemon='): self.daemon = True Utils.log("daemon started")
def getParams(self): #extract the params from the called script path params = {} for arg in sys.argv: if arg == 'script.skin.helper.service' or arg == 'default.py': continue arg = arg.replace('"', '').replace("'", " ").replace("?", "") if "=" in arg: paramname = arg.split('=')[0].upper() paramvalue = arg.split('=')[1] params[paramname] = paramvalue utils.logMsg("Parameter string: " + str(params)) return params
def __init__(self): xbmcgui.Window(10000).setProperty('extendedinfo_running', 'True') self._parse_argv() for info in self.infos: listitems = process.start_info_actions(self.infos, self.params) xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_TITLE) xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_VIDEO_YEAR) xbmcplugin.addSortMethod(self.handle, xbmcplugin.SORT_METHOD_DURATION) if info.endswith('shows'): xbmcplugin.setContent(self.handle, 'tvshows') elif info.endswith('movies'): xbmcplugin.setContent(self.handle, 'movies') else: xbmcplugin.setContent(self.handle, 'addons') Utils.pass_list_to_skin(name=info, data=listitems, prefix=self.params.get('prefix', ''), handle=self.handle, limit=self.params.get('limit', 20)) else: items = [ ('popularmovies', 'Popular Movies'), ('topratedmovies', 'Top Rated Movies'), ('incinemamovies', 'In Theaters Movies'), ('upcomingmovies', 'Upcoming Movies'), ('libraryallmovies', 'My Movies (Library)'), ('populartvshows', 'Popular TV Shows'), ('topratedtvshows', 'Top Rated TV Shows'), ('onairtvshows', 'Currently Airing TV Shows'), ('airingtodaytvshows', 'Airing Today TV Shows'), ('libraryalltvshows', 'My TV Shows (Library)') ] NoFolder_items = [ ('allmovies', 'All Movies'), ('alltvshows', 'All TV Shows'), ('search_menu', 'Search...') ] xbmcplugin.setContent(self.handle, 'addons') for key, value in items: thumb_path = 'special://home/addons/script.extendedinfo/resources/skins/Default/media/tmdb/thumb.png' fanart_path = 'special://home/addons/script.extendedinfo/resources/skins/Default/media/tmdb/fanart.jpg' url = 'plugin://script.extendedinfo?info=%s&limit=0' % key li = xbmcgui.ListItem(label=value) li.setArt({'thumb': thumb_path, 'fanart': fanart_path}) xbmcplugin.addDirectoryItem(handle=self.handle, url=url, listitem=li, isFolder=True) for key, value in NoFolder_items: thumb_path = 'special://home/addons/script.extendedinfo/resources/skins/Default/media/tmdb/thumb.png' fanart_path = 'special://home/addons/script.extendedinfo/resources/skins/Default/media/tmdb/fanart.jpg' url = 'plugin://script.extendedinfo?info=%s' % key li = xbmcgui.ListItem(label=value) li.setArt({'thumb': thumb_path, 'fanart': fanart_path}) xbmcplugin.addDirectoryItem(handle=self.handle, url=url, listitem=li, isFolder=False) xbmcplugin.endOfDirectory(self.handle) xbmcgui.Window(10000).clearProperty('extendedinfo_running')
def __init__(self, *args, **kwargs): if Utils.NETFLIX_VIEW == 'true': super(DialogTVShowInfo, self).__init__(*args, **kwargs) self.type = 'TVShow' data = TheMovieDB.extended_tvshow_info(tvshow_id=kwargs.get( 'tmdb_id', False), dbid=self.dbid) if not data: return None self.info, self.data = data if 'dbid' not in self.info: self.info['poster'] = Utils.get_file( self.info.get('poster', '')) self.listitems = [(250, self.data['seasons']), (150, self.data['similar']), (1000, self.data['actors']), (750, self.data['crew']), (550, self.data['studios']), (1450, self.data['networks']), (850, self.data['genres']), (1250, self.data['images']), (1350, self.data['backdrops'])] else: super(DialogTVShowInfo, self).__init__(*args, **kwargs) self.type = 'TVShow' data = TheMovieDB.extended_tvshow_info(tvshow_id=kwargs.get( 'tmdb_id', False), dbid=self.dbid) if not data: return None self.info, self.data = data if 'dbid' not in self.info: self.info['poster'] = Utils.get_file( self.info.get('poster', '')) self.info['ImageFilter'], self.info[ 'ImageColor'] = ImageTools.filter_image( input_img=self.info.get('poster', ''), radius=25) self.listitems = [(250, self.data['seasons']), (150, self.data['similar']), (1150, self.data['videos']), (1000, self.data['actors']), (750, self.data['crew']), (550, self.data['studios']), (1450, self.data['networks']), (650, TheMovieDB.merge_with_cert_desc( self.data['certifications'], 'tv')), (850, self.data['genres']), (1250, self.data['images']), (1350, self.data['backdrops'])]
def checkSkinVersion(self): try: skin = xbmc.getSkinDir() skinLabel = xbmcaddon.Addon(id=skin).getAddonInfo('name').decode("utf-8") skinVersion = xbmcaddon.Addon(id=skin).getAddonInfo('version').decode("utf-8") if self.lastSkin != skinLabel+skinVersion: #auto correct skin settings self.lastSkin = skinLabel+skinVersion utils.WINDOW.setProperty("SkinHelper.skinTitle",skinLabel + " - " + xbmc.getLocalizedString(19114) + ": " + skinVersion) utils.WINDOW.setProperty("SkinHelper.skinVersion",xbmc.getLocalizedString(19114) + ": " + skinVersion) utils.WINDOW.setProperty("SkinHelper.Version",utils.ADDON_VERSION.replace(".","")) mainmodule.correctSkinSettings() except Exception as e: utils.logMsg("Error in setSkinVersion --> " + str(e), 0)
def getParams(self): # extract the params from the called script path params = {} for arg in sys.argv: arg = arg.decode("utf-8") if arg == "script.skin.helper.service" or arg == "default.py": continue elif "=" in arg: paramname = arg.split("=")[0] paramvalue = arg.replace(paramname + "=", "") params[paramname] = paramvalue params[paramname.upper()] = paramvalue utils.logMsg("Parameter string: " + str(params)) return params
def get_show_tmdb_id(tvdb_id=None, db=None, imdb_id=None): if tvdb_id: id = tvdb_id db = 'tvdb_id' elif imdb_id: id = 'tt' + imdb_id db = 'imdb_id' response = get_tmdb_data( 'find/%s?external_source=%s&language=%s&' % (id, db, xbmcaddon.Addon().getSetting('LanguageID')), 30) if response: return response['tv_results'][0]['id'] else: Utils.notify('TV Show info not found', time=5000, sound=False) return None
def play_episode_choose_player(self): Utils.show_busy() # window_id = xbmcgui.getCurrentWindowDialogId() # xbmc.log(str(window_id)+'===>OPENINFO', level=xbmc.LOGNOTICE) url = 'plugin://plugin.video.openmeta/tv/play_choose_player/%s/%s/%s/False' % (Utils.fetch(TheMovieDB.get_tvshow_ids(self.tvshow_id), 'tvdb_id'), self.info['season'], self.info['episode']) # PLAYER.play_from_button(url, listitem=None, window=self, type='episodeid', dbid=dbid) # xbmc.executebuiltin('Dialog.Close(%s, true)' % window_id) # xbmc.executebuiltin('RunPlugin(%s)' % url) if self.dbid and int(self.dbid) > 0: dbid = self.dbid # url = '' PLAYER.play_from_button(url, listitem=None, window=self, type='episodeid', dbid=dbid) # else: # url = 'plugin://plugin.video.openmeta/tv/play_choose_player/%s/%s/%s/False' % (Utils.fetch(TheMovieDB.get_tvshow_ids(self.tvshow_id), 'tvdb_id'), self.info['season'], self.info['episode']) PLAYER.play_from_button(url, listitem=None, window=self, type='episodeid', dbid=0)
def onInit(self): super(SlideShow, self).onInit() if not self.images: return None self.getControl(10001).addItems(Utils.create_listitems(self.images)) self.getControl(10001).selectItem(self.index) self.setFocusId(10001)
def open_dialog(self, dialog, prev_window): if dialog.data: self.active_dialog = dialog if xbmc.getCondVisibility('Window.IsVisible(movieinformation)'): self.reopen_window = True self.last_control = xbmc.getInfoLabel('System.CurrentControlId').decode('utf-8') xbmc.executebuiltin('Dialog.Close(movieinformation)') if prev_window: if xbmc.Player().isPlayingVideo() and not xbmc.getCondVisibility('VideoPlayer.IsFullscreen'): xbmc.Player().stop() self.add_to_stack(prev_window) prev_window.close() dialog.doModal() else: self.active_dialog = None Utils.notify('Could not find item at MovieDB')
def browse(): xbmcplugin.setContent(addon_handle, 'movies') xbmcplugin.addSortMethod(addon_handle, 1) # Get current folder UID parent = args.get('parent', None) if parent is None: parent = '0' else: parent = str(parent[0]) # Building API URL Utils.log('Getting items from API') try: content = Api.Browse(parent=parent) if content and content['list']: # Adding items to the listing for item in content['list']: # Item is a folder if item['type'] == 'dir': # Building URL url = base_url + '?' + urllib.urlencode({ 'mode' : 'browse', 'parent': item['id'] }) Utils.log('Adding folder to list: '+url) li = xbmcgui.ListItem(item['name'], iconImage='DefaultFolder.png') xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li, isFolder=True) else: # Item is a regular file url = base_url + '?' + urllib.urlencode({ 'mode' : 'stream', 'file': item['id'] }) li = xbmcgui.ListItem(item['name'], iconImage='DefaultVideo.png') Utils.log('Adding file to list: '+url) xbmcplugin.addDirectoryItem(handle=addon_handle, url=url, listitem=li) xbmcplugin.endOfDirectory(addon_handle) except: Utils.log('Error when listing items') xbmc.executebuiltin('Notification('+language(30021)+', '+language(30022)+',3000,' + addon_path + '/resources/images/error.png)')
def __Call(self, url, params = {}): #xbmc.executebuiltin('Notification('+default.language(30015)+', '+language(30016)+',3000,' + default.addon_path +'/resources/images/success.png)') # Matching URL if not re.search('http(s)?://', url): url = self.api_url + '/' + url Utils.log('Requesting URL : '+url+'?'+urllib.urlencode(params)) # Running request try: # Setting cookies default policy policy = DefaultCookiePolicy(rfc2965=False, allowed_domains=self.allowed_domains) cj = cookielib.LWPCookieJar(policy=policy) # Starting the CookieJar handler opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj)) urllib2.install_opener(opener) # Starting the request req = urllib2.Request(url) req.add_header('User-Agent', Utils.getUserAgent()) # Loading existing cookie(s) if applicable # Ignoring_discard = True otherwise session cookies aren't sent if os.path.isfile(self.cookiejar): Utils.log('Loading existing cookies') cj.load(self.cookiejar, ignore_discard=True) # Running query response = urllib2.urlopen(req, urllib.urlencode(params)) # Getting response content = response.read() # Getting response informations infos = response.info() # Checking the response content-type if infos['content-type']: # If response is a JSON, decoding JSON automatically if re.search('application/json', infos['content-type']): content = json.loads(content) # Saving private_key for later use for cookie in cj: self.cookies[cookie.name] = cookie.value # If unable to save the cookie jar file # Aborting execution, otherwise going into # An infinite loop if not os.path.isdir(self.cookiejar_dir): Utils.log('Warning: Cookiejar DIR does not exist') xbmcgui.Dialog().ok(default.language(30023), '', default.language(30024)) sys.exit() # Saving any cookie sent with the response # Ignoring_discard = True otherwise session cookies aren't saved cj.save(self.cookiejar, ignore_discard=True) response.close() return content except urllib2.HTTPError, e: # Authentication issue, resetting the private key if e.code == 403: Utils.log('Got a 403 Forbidden, trying to login now') if default.Auth.Login(): default.browse()
Utils.log('Warning: Cookiejar DIR does not exist') xbmcgui.Dialog().ok(default.language(30023), '', default.language(30024)) sys.exit() # Saving any cookie sent with the response # Ignoring_discard = True otherwise session cookies aren't saved cj.save(self.cookiejar, ignore_discard=True) response.close() return content except urllib2.HTTPError, e: # Authentication issue, resetting the private key if e.code == 403: Utils.log('Got a 403 Forbidden, trying to login now') if default.Auth.Login(): default.browse() #Utils.log('API Call error: ' + str(e)) #xbmc.executebuiltin('Notification(An error occurred, Something nasty happened. Sorry...,3000,' + default.addon_path + '/resources/images/error.png)') except urllib2.URLError, e: Utils.log('Could not request the API (' + str(e) + ')') xbmc.executebuiltin('Notification(An error occurred, Something nasty happened. Sorry...,3000,' + default.addon_path + '/resources/images/error.png)') except: Utils.log('Something nasty happened during API Call (' + str(sys.exc_info()[0]) + ')') xbmc.executebuiltin('Notification(An error occurred, Something nasty happened. Sorry...,3000,' + default.addon_path + '/resources/images/error.png)') return False
def Login(self, username = None, password = None): Utils.log('Checking login now') modal = 0 # Checking whether arguments were sent if username is not None: self.username = username if password is not None: self.password = password # If username OR password are NOT available, opening modal box if self.username is None or self.password is None: Utils.log('Never logged in before, displaying modal') self.window = Utils.AuthForm(default.language(30006)) self.window.doModal() return try: content = default.Api.Login(username=self.username, password=self.password) if not content or content == False: return False if content['result'] and content['result'] == 'success': #xbmc.executebuiltin('Notification('+default.language(30015)+', '+language(30016)+',3000,' + default.addon_path +'/resources/images/success.png)') Utils.log('Login is successful.') # If modal is opened, closing it if self.window: Utils.log('Trying to close login modal') self.window.close() # Saving username and password into the XBMC settings self.addon.setSetting('username', str(self.username)) self.addon.setSetting('password', str(self.password)) return True else: Utils.log('Login failed') xbmcgui.Dialog().ok(default.language(30015), '', default.language(30017), default.language(30018)) if not self.window: self.window = AuthForm(default.language(30006)) self.window.doModal() return False except: Utils.log('Something nasty happened during login (' + str(sys.exc_info()[0]) + ')') xbmc.executebuiltin('Notification(An error occurred, Something nasty happened. Sorry...,3000,' + addon_path + '/resources/images/error.png)') return False
def __init__(self): utils.logMsg('started loading pluginentry') #get params action = None params = urlparse.parse_qs(sys.argv[2][1:].decode("utf-8")) utils.logMsg("Parameter string: %s" % sys.argv[2]) if params: path=params.get("path",None) if path: path = path[0] limit=params.get("limit",None) if limit: limit = int(limit[0]) else: limit = 25 action=params.get("action",None) if action: action = action[0].upper() if action: if action == "LAUNCHPVR": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", "params": { "item": {"channelid": %d} } }' %int(path)) if action == "PLAYRECORDING": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) #retrieve the recording and play as listitem to get resume working json_result = utils.getJSON('PVR.GetRecordingDetails', '{"recordingid": %d, "properties": [ %s ]}' %(int(path),plugincontent.fields_pvrrecordings)) if json_result: xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recordingid": %d } }, "id": 1 }' % int(path)) if json_result["resume"].get("position"): for i in range(25): if xbmc.getCondVisibility("Player.HasVideo"): break xbmc.sleep(250) xbmc.Player().seekTime(json_result["resume"].get("position")) elif action == "LAUNCH": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) path = sys.argv[2].split("&path=")[1] xbmc.executebuiltin("Action(Close)") xbmc.executebuiltin(path) elif action == "PLAYALBUM": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "albumid": %d } }, "id": 1 }' % int(path)) elif action == "SMARTSHORTCUTS": skinshortcuts.getSmartShortcuts(path) elif action == "BACKGROUNDS": skinshortcuts.getBackgrounds() elif action == "WIDGETS": skinshortcuts.getWidgets(path) elif action == "GETTHUMB": plugincontent.getThumb(path) elif action == "EXTRAFANART": plugincontent.getExtraFanArt(path) elif action == "GETCAST": movie=params.get("movie",None) if movie: movie = movie[0] tvshow=params.get("tvshow",None) if tvshow: tvshow = tvshow[0] movieset=params.get("movieset",None) if movieset: movieset = movieset[0] episode=params.get("episode",None) if episode: episode = episode[0] downloadthumbs=params.get("downloadthumbs",False) if downloadthumbs: downloadthumbs = downloadthumbs[0]=="true" plugincontent.getCast(movie,tvshow,movieset,episode,downloadthumbs) else: #get a widget listing refresh=params.get("reload",None) if refresh: refresh = refresh[0].upper() optionalParam = None imdbid=params.get("imdbid","") if imdbid: optionalParam = imdbid[0] genre=params.get("genre","") if genre: optionalParam = genre[0] browse=params.get("browse","") if browse: optionalParam = browse[0] reversed=params.get("reversed","") if reversed: optionalParam = reversed[0] type=params.get("type","") if type: optionalParam = type[0] name=params.get("name","") if name: optionalParam = name[0] randomize=params.get("randomize","") if randomize: randomize = randomize[0] randomize = randomize == "true" plugincontent.getPluginListing(action,limit,refresh,optionalParam,randomize) else: #do plugin main listing... plugincontent.doMainListing(params.get("content_type",[""])[0])
if randomize: randomize = randomize[0] randomize = randomize == "true" plugincontent.getPluginListing(action,limit,refresh,optionalParam,randomize) else: #do plugin main listing... plugincontent.doMainListing(params.get("content_type",[""])[0]) if (__name__ == "__main__"): try: if not utils.WINDOW.getProperty("SkinHelperShutdownRequested"): if enableProfiling: import cProfile import pstats import random from time import gmtime, strftime filename = os.path.join( ADDON_DATA_PATH, strftime( "%Y%m%d%H%M%S",gmtime() ) + "-" + str( random.randrange(0,100000) ) + ".log" ) cProfile.run( 'Main()', filename ) stream = open( filename + ".txt", 'w') stream.write(sys.argv[2]) p = pstats.Stats( filename, stream = stream ) p.sort_stats( "cumulative" ) p.print_stats() else: Main() else: utils.logMsg("plugin.py --> Not forfilling request: Kodi is exiting" ,0) except Exception as e: utils.logMsg("Error in plugin.py --> " + str(e),0) utils.logMsg('finished loading pluginentry')
def __init__(self): utils.logMsg('started loading script entry') params = self.getParams() if params: action = params.get("ACTION","").upper() if action =="ADDSHORTCUT": mainmodule.addShortcutWorkAround() elif action == "MUSICSEARCH": mainmodule.musicSearch() elif action == "SETVIEW": mainmodule.setView() elif action == "SEARCHYOUTUBE": title = params.get("TITLE",None) windowHeader = params.get("HEADER","") autoplay = params.get("AUTOPLAY","") windowed = params.get("WINDOWED","") mainmodule.searchYouTube(title,windowHeader,autoplay,windowed) elif action == "SETFOCUS": control = params.get("CONTROL",None) xbmc.sleep(50) xbmc.executebuiltin("Control.SetFocus(%s)"%control) elif action == "SETFORCEDVIEW": contenttype = params.get("CONTENTTYPE",None) mainmodule.setForcedView(contenttype) elif action == "SETSKINSETTING": setting = params.get("SETTING","") windowHeader = params.get("HEADER","") mainmodule.setSkinSetting(setting,windowHeader) elif action == "SETSKINCONSTANT": setting = params.get("SETTING","") windowHeader = params.get("HEADER","") mainmodule.setSkinConstant(setting,windowHeader) elif action == "SETSKINSHORTCUTSPROPERTY": setting = params.get("SETTING","") windowHeader = params.get("HEADER","") property = params.get("PROPERTY","") mainmodule.setSkinShortCutsProperty(setting,windowHeader,property) elif action == "TOGGLEKODISETTING": kodisetting = params.get("SETTING") mainmodule.toggleKodiSetting(kodisetting) elif action == "ENABLEVIEWS": mainmodule.enableViews() elif action == "SPLASHSCREEN": file = params.get("FILE","") duration = params.get("DURATION","") if duration: mainmodule.show_splash(file,int(duration)) else: mainmodule.show_splash(file) elif action == "VIDEOSEARCH": from resources.lib.SearchDialog import SearchDialog searchDialog = SearchDialog("script-skin_helper_service-CustomSearch.xml", utils.ADDON_PATH, "Default", "1080i") searchDialog.doModal() resultAction = searchDialog.action del searchDialog if resultAction: if "jsonrpc" in resultAction: xbmc.executeJSONRPC(resultAction) else: xbmc.executebuiltin(resultAction) elif action == "SHOWINFO": xbmc.executebuiltin( "ActivateWindow(busydialog)" ) from resources.lib.InfoDialog import GUI item = None if params.get("MOVIEID"): item = utils.getJSON('VideoLibrary.GetMovieDetails', '{ "movieid": %s, "properties": [ %s ] }' %(params.get("MOVIEID"),utils.fields_movies)) content = "movies" elif params.get("EPISODEID"): item = utils.getJSON('VideoLibrary.GetEpisodeDetails', '{ "episodeid": %s, "properties": [ %s ] }' %(params.get("EPISODEID"),utils.fields_episodes)) content = "episodes" elif params.get("TVSHOWID"): item = utils.getJSON('VideoLibrary.GetTVShowDetails', '{ "tvshowid": %s, "properties": [ %s ] }' %(params.get("TVSHOWID"),utils.fields_tvshows)) content = "tvshows" if item: liz = utils.prepareListItem(item) liz = utils.createListItem(item) liz.setProperty("json",repr(item)) info_dialog = GUI( "script-skin_helper_service-CustomInfo.xml" , utils.ADDON_PATH, "Default", "1080i", listitem=liz, content=content ) info_dialog.doModal() resultAction = info_dialog.action del info_dialog if resultAction: if "jsonrpc" in resultAction: xbmc.executeJSONRPC(resultAction) else: xbmc.executebuiltin(resultAction) xbmc.executebuiltin( "Dialog.Close(busydialog)" ) elif action == "COLORPICKER": from resources.lib.ColorPicker import ColorPicker colorPicker = ColorPicker("script-skin_helper_service-ColorPicker.xml", utils.ADDON_PATH, "Default", "1080i") colorPicker.skinString = params.get("SKINSTRING","") colorPicker.winProperty = params.get("WINPROPERTY","") colorPicker.activePalette = params.get("PALETTE","") colorPicker.headerLabel = params.get("HEADER","") propname = params.get("SHORTCUTPROPERTY","") colorPicker.shortcutProperty = propname colorPicker.doModal() if propname and not isinstance(colorPicker.result, int): mainmodule.waitForSkinShortcutsWindow() xbmc.sleep(400) currentWindow = xbmcgui.Window( xbmcgui.getCurrentWindowDialogId() ) currentWindow.setProperty("customProperty",propname) currentWindow.setProperty("customValue",colorPicker.result[0]) xbmc.executebuiltin("SendClick(404)") xbmc.sleep(250) currentWindow.setProperty("customProperty",propname+".name") currentWindow.setProperty("customValue",colorPicker.result[1]) xbmc.executebuiltin("SendClick(404)") del colorPicker elif action == "COLORTHEMES": from resources.lib.ColorThemes import ColorThemes colorThemes = ColorThemes("DialogSelect.xml", utils.ADDON_PATH) colorThemes.daynight = params.get("DAYNIGHT",None) colorThemes.doModal() del colorThemes elif action == "CONDITIONALBACKGROUNDS": from resources.lib.ConditionalBackgrounds import ConditionalBackgrounds conditionalBackgrounds = ConditionalBackgrounds("DialogSelect.xml", utils.ADDON_PATH) conditionalBackgrounds.doModal() del conditionalBackgrounds elif action == "CREATECOLORTHEME": import resources.lib.ColorThemes as colorThemes colorThemes.createColorTheme() elif action == "RESTORECOLORTHEME": import resources.lib.ColorThemes as colorThemes colorThemes.restoreColorTheme() elif action == "OVERLAYTEXTURE": mainmodule.selectOverlayTexture() elif action == "BUSYTEXTURE": mainmodule.selectBusyTexture() elif action == "CACHEALLMUSICART": import resources.lib.ArtworkUtils as artworkutils artworkutils.preCacheAllMusicArt() elif action == "RESETCACHE": path = params.get("PATH") if path == "pvr": path = utils.WINDOW.getProperty("SkinHelper.pvrthumbspath").decode("utf-8") utils.WINDOW.setProperty("resetPvrArtCache","reset") elif path == "music": path = "special://profile/addon_data/script.skin.helper.service/musicart/" utils.WINDOW.setProperty("resetMusicArtCache","reset") elif path == "wallbackgrounds": path = "special://profile/addon_data/script.skin.helper.service/wallbackgrounds/" utils.WINDOW.setProperty("resetWallArtCache","reset") else: path = None if path: success = True ret = xbmcgui.Dialog().yesno(heading=utils.ADDON.getLocalizedString(32089), line1=utils.ADDON.getLocalizedString(32090)+path) if ret: success = utils.recursiveDelete(path) if success: xbmcgui.Dialog().ok(heading=utils.ADDON.getLocalizedString(32089), line1=utils.ADDON.getLocalizedString(32091)) else: xbmcgui.Dialog().ok(heading=utils.ADDON.getLocalizedString(32089), line1=utils.ADDON.getLocalizedString(32092)) elif action == "BACKUP": import resources.lib.BackupRestore as backup filter = params.get("FILTER","") silent = params.get("SILENT",None) promptfilename = params.get("PROMPTFILENAME","false") backup.backup(filter,silent,promptfilename.lower()) elif action == "RESTORE": import resources.lib.BackupRestore as backup silent = params.get("SILENT",None) backup.restore(silent) elif action == "RESET": import resources.lib.BackupRestore as backup filter = params.get("FILTER","") silent = params.get("SILENT","") == "true" backup.reset(filter,silent) xbmc.Monitor().waitForAbort(2) mainmodule.correctSkinSettings() elif action == "DIALOGOK": headerMsg = params.get("HEADER") bodyMsg = params.get("MESSAGE") if bodyMsg.startswith(" "): bodyMsg = bodyMsg[1:] if headerMsg.startswith(" "): headerMsg = headerMsg[1:] xbmcgui.Dialog().ok(heading=headerMsg, line1=bodyMsg) elif action == "DIALOGYESNO": headerMsg = params.get("HEADER") bodyMsg = params.get("MESSAGE") yesactions = params.get("YESACTION","").split("|") noactions = params.get("NOACTION","").split("|") if bodyMsg.startswith(" "): bodyMsg = bodyMsg[1:] if headerMsg.startswith(" "): headerMsg = headerMsg[1:] if xbmcgui.Dialog().yesno(heading=headerMsg, line1=bodyMsg): for action in yesactions: xbmc.executebuiltin(action.encode("utf-8")) else: for action in noactions: xbmc.executebuiltin(action.encode("utf-8")) elif action == "TEXTVIEWER": headerMsg = params.get("HEADER","") bodyMsg = params.get("MESSAGE","") if bodyMsg.startswith(" "): bodyMsg = bodyMsg[1:] if headerMsg.startswith(" "): headerMsg = headerMsg[1:] xbmcgui.Dialog().textviewer(headerMsg, bodyMsg) elif action == "FILEEXISTS": filename = params.get("FILE") skinstring = params.get("SKINSTRING") windowprop = params.get("WINDOWPROP") if xbmcvfs.exists(filename): if windowprop: utils.WINDOW.setProperty(windowprop,"exists") if skinstring: xbmc.executebuiltin("Skin.SetString(%s,exists)" %skinstring) else: if windowprop: utils.WINDOW.clearProperty(windowprop) if skinstring: xbmc.executebuiltin("Skin.Reset(%s)" %skinstring) elif action == "STRIPSTRING": splitchar = params.get("SPLITCHAR") string = params.get("STRING") output = params.get("OUTPUT") index = params.get("INDEX",0) string = string.split(splitchar)[int(index)] utils.WINDOW.setProperty(output, string) elif action == "GETPLAYERFILENAME": output = params.get("OUTPUT") filename = xbmc.getInfoLabel("Player.FileNameAndPath") if not filename: filename = xbmc.getInfoLabel("Player.FileName") if "filename=" in filename: url_params = dict(urlparse.parse_qsl(filename)) filename = url_params.get("filename") utils.WINDOW.setProperty(output, filename) elif action == "GETFILENAME": output = params.get("OUTPUT") filename = xbmc.getInfoLabel("ListItem.FileNameAndPath") if not filename: filename = xbmc.getInfoLabel("ListItem.FileName") if not filename: filename = xbmc.getInfoLabel("Container(999).ListItem.FileName") if not filename: filename = xbmc.getInfoLabel("Container(999).ListItem.FileNameAndPath") if "filename=" in filename: url_params = dict(urlparse.parse_qsl(filename)) filename = url_params.get("filename") utils.WINDOW.setProperty(output, filename) elif action == "CHECKRESOURCEADDONS": ADDONSLIST = params.get("ADDONSLIST") mainmodule.checkResourceAddons(ADDONSLIST)
filename = xbmc.getInfoLabel("Player.FileNameAndPath") if not filename: filename = xbmc.getInfoLabel("Player.FileName") if "filename=" in filename: url_params = dict(urlparse.parse_qsl(filename)) filename = url_params.get("filename") utils.WINDOW.setProperty(output, filename) elif action == "GETFILENAME": output = params.get("OUTPUT") filename = xbmc.getInfoLabel("ListItem.FileNameAndPath") if not filename: filename = xbmc.getInfoLabel("ListItem.FileName") if not filename: filename = xbmc.getInfoLabel("Container(999).ListItem.FileName") if not filename: filename = xbmc.getInfoLabel("Container(999).ListItem.FileNameAndPath") if "filename=" in filename: url_params = dict(urlparse.parse_qsl(filename)) filename = url_params.get("filename") utils.WINDOW.setProperty(output, filename) elif action == "CHECKRESOURCEADDONS": ADDONSLIST = params.get("ADDONSLIST") mainmodule.checkResourceAddons(ADDONSLIST) if (__name__ == "__main__"): xbmc.executebuiltin( "Dialog.Close(busydialog)" ) if not utils.WINDOW.getProperty("SkinHelperShutdownRequested"): Main() utils.logMsg('finished loading script entry')
def __init__(self): utils.logMsg('started loading pluginentry') #get params action = None params = urlparse.parse_qs(sys.argv[2][1:].decode("utf-8")) utils.logMsg("Parameter string: %s" % sys.argv[2]) if params: path=params.get("path",None) if path: path = path[0] limit=params.get("limit",None) if limit: limit = int(limit[0]) else: limit = 25 action=params.get("action",None) if action: action = action[0].upper() if action: if action == "LAUNCHPVR": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", "params": { "item": {"channelid": %d} } }' %int(path)) if action == "PLAYRECORDING": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) #retrieve the recording and play as listitem to get resume working json_result = utils.getJSON('PVR.GetRecordingDetails', '{"recordingid": %d, "properties": [ %s ]}' %(int(path),plugincontent.fields_pvrrecordings)) if json_result: xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recordingid": %d } }, "id": 1 }' % int(path)) if json_result["resume"].get("position"): for i in range(25): if xbmc.getCondVisibility("Player.HasVideo"): break xbmc.sleep(250) xbmc.Player().seekTime(json_result["resume"].get("position")) elif action == "LAUNCH": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) path = sys.argv[2].split("&path=")[1] xbmc.sleep(150) xbmc.executebuiltin(path) elif action == "PLAYALBUM": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) xbmc.sleep(150) xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "albumid": %d } }, "id": 1 }' % int(path)) elif action == "SMARTSHORTCUTS": skinshortcuts.getSmartShortcuts(path) elif action == "BACKGROUNDS": skinshortcuts.getBackgrounds() elif action == "WIDGETS": skinshortcuts.getWidgets(path) elif action == "GETTHUMB": plugincontent.getThumb(path) elif action == "EXTRAFANART": plugincontent.getExtraFanArt(path) elif action == "GETCAST": movie=params.get("movie",None) if movie: movie = movie[0] tvshow=params.get("tvshow",None) if tvshow: tvshow = tvshow[0] movieset=params.get("movieset",None) if movieset: movieset = movieset[0] episode=params.get("episode",None) if episode: episode = episode[0] downloadthumbs=params.get("downloadthumbs",False) if downloadthumbs: downloadthumbs = downloadthumbs[0]=="true" plugincontent.getCast(movie,tvshow,movieset,episode,downloadthumbs) elif action == "ALPHABET": allLetters = [] if xbmc.getInfoLabel("Container.NumItems"): for i in range(int(xbmc.getInfoLabel("Container.NumItems"))): allLetters.append(xbmc.getInfoLabel("Listitem(%s).SortLetter"%i).upper()) startNumber = "" for number in ["2","3","4","5","6","7","8","9"]: if number in allLetters: startNumber = number break for letter in [startNumber,"A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]: if letter == startNumber: label = "#" else: label = letter li = xbmcgui.ListItem(label=label) if not letter in allLetters: path = "noop" li.setProperty("NotAvailable","true") else: path = "plugin://script.skin.helper.service/?action=alphabetletter&letter=%s" %letter xbmcplugin.addDirectoryItem(int(sys.argv[1]), path, li) xbmcplugin.endOfDirectory(handle=int(sys.argv[1])) elif action == "ALPHABETLETTER": letter=params.get("letter",None) if letter: letter = letter[0] if letter in ["A", "B", "C", "2"]: jumpcmd = "2" elif letter in ["D", "E", "F", "3"]: jumpcmd = "3" elif letter in ["G", "H", "I", "4"]: jumpcmd = "4" elif letter in ["J", "K", "L", "5"]: jumpcmd = "5" elif letter in ["M", "N", "O", "6"]: jumpcmd = "6" elif letter in ["P", "Q", "R", "S", "7"]: jumpcmd = "7" elif letter in ["T", "U", "V", "8"]: jumpcmd = "8" elif letter in ["W", "X", "Y", "Z", "9"]: jumpcmd = "9" else: return xbmc.executebuiltin("SetFocus(50)") for i in range(6): xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Input.ExecuteAction", "params": { "action": "jumpsms%s" }, "id": 1 }' % (jumpcmd)) xbmc.sleep(50) if xbmc.getInfoLabel("ListItem.Sortletter").upper() == letter: break else: #get a widget listing refresh=params.get("reload",None) if refresh: refresh = refresh[0].upper() optionalParam = None imdbid=params.get("imdbid","") if imdbid: optionalParam = imdbid[0] genre=params.get("genre","") if genre: optionalParam = genre[0] browse=params.get("browse","") if browse: optionalParam = browse[0] reversed=params.get("reversed","") if reversed: optionalParam = reversed[0] type=params.get("type","") if type: optionalParam = type[0] name=params.get("name","") if name: optionalParam = name[0] randomize=params.get("randomize","") if randomize: randomize = randomize[0] randomize = randomize == "true" plugincontent.getPluginListing(action,limit,refresh,optionalParam,randomize) else: #do plugin main listing... plugincontent.doMainListing()
def __init__(self): utils.WINDOW.clearProperty("SkinHelperShutdownRequested") KodiMonitor = Kodi_Monitor() listItemMonitor = ListItemMonitor() backgroundsUpdater = BackgroundsUpdater() webService = WebService() lastSkin = None # start the extra threads listItemMonitor.start() backgroundsUpdater.start() webService.start() while not (KodiMonitor.abortRequested() or utils.WINDOW.getProperty("SkinHelperShutdownRequested")): self.checkSkinVersion() KodiMonitor.waitForAbort(10) else: # Abort was requested while waiting. We should exit utils.WINDOW.setProperty("SkinHelperShutdownRequested", "shutdown") utils.logMsg("Shutdown requested !", 0) # stop the extra threads backgroundsUpdater.stop() listItemMonitor.stop() webService.stop() utils.logMsg("skin helper service version %s started" % utils.ADDON_VERSION, 0) Main() utils.logMsg("skin helper service version %s stopped" % utils.ADDON_VERSION, 0)
def __init__(self): utils.logMsg("started loading script entry") params = self.getParams() if params: action = params.get("ACTION", "").upper() if action == "ADDSHORTCUT": mainmodule.addShortcutWorkAround() elif action == "MUSICSEARCH": mainmodule.musicSearch() elif action == "SETVIEW": mainmodule.setView() elif action == "SEARCHYOUTUBE": title = params.get("TITLE", None) windowHeader = params.get("HEADER", "") autoplay = params.get("AUTOPLAY", "") windowed = params.get("WINDOWED", "") mainmodule.searchYouTube(title, windowHeader, autoplay, windowed) elif action == "SETFOCUS": control = params.get("CONTROL", None) fallback = params.get("FALLBACK", None) count = 0 while not xbmc.getCondVisibility("Control.HasFocus(%s)" % control): if count == 20 or ( fallback and xbmc.getCondVisibility( "Control.IsVisible(%s) + !IntegerGreaterThan(Container(%s).NumItems,0)" % (control, control) ) ): if fallback: xbmc.executebuiltin("Control.SetFocus(%s)" % fallback) break else: xbmc.executebuiltin("Control.SetFocus(%s)" % control) xbmc.sleep(50) count += 1 elif action == "SETFORCEDVIEW": contenttype = params.get("CONTENTTYPE", None) mainmodule.setForcedView(contenttype) elif action == "SAVESKINIMAGE": skinstring = params.get("SKINSTRING", "") windowHeader = params.get("HEADER", "") multi = params.get("MULTI", "") == "true" mainmodule.saveSkinImage(skinstring, multi, windowHeader) elif action == "SETSKINSETTING": setting = params.get("SETTING", "") windowHeader = params.get("HEADER", "") originalId = params.get("ID", "") mainmodule.setSkinSetting(setting=setting, windowHeader=windowHeader, originalId=originalId) elif action == "SETSKINCONSTANT": setting = params.get("SETTING", "") windowHeader = params.get("HEADER", "") value = params.get("VALUE", "") mainmodule.setSkinConstant(setting, windowHeader, value) elif action == "SETSKINCONSTANTS": settings = params.get("SETTINGS", "").split("|") values = params.get("VALUES", "").split("|") mainmodule.setSkinConstant(settings, values) elif action == "SETSKINSHORTCUTSPROPERTY": setting = params.get("SETTING", "") windowHeader = params.get("HEADER", "") property = params.get("PROPERTY", "") mainmodule.setSkinShortCutsProperty(setting, windowHeader, property) elif action == "TOGGLEKODISETTING": kodisetting = params.get("SETTING") mainmodule.toggleKodiSetting(kodisetting) elif action == "SETKODISETTING": kodisetting = params.get("SETTING") value = params.get("VALUE") mainmodule.setKodiSetting(kodisetting, value) elif action == "ENABLEVIEWS": mainmodule.enableViews() elif action == "SPLASHSCREEN": file = params.get("FILE", "") duration = params.get("DURATION", "") if duration: mainmodule.show_splash(file, int(duration)) else: mainmodule.show_splash(file) elif action == "VIDEOSEARCH": from resources.lib.SearchDialog import SearchDialog searchDialog = SearchDialog( "script-skin_helper_service-CustomSearch.xml", utils.ADDON_PATH, "Default", "1080i" ) searchDialog.doModal() resultAction = searchDialog.action del searchDialog if resultAction: if "jsonrpc" in resultAction: xbmc.executeJSONRPC(resultAction) else: xbmc.executebuiltin(resultAction) elif action == "SHOWINFO": xbmc.executebuiltin("ActivateWindow(busydialog)") # try to figure out the params automatically if no ID provided... if not (params.get("MOVIEID") or params.get("EPISODEID") or params.get("TVSHOWID")): widgetContainer = utils.WINDOW.getProperty("SkinHelper.WidgetContainer").decode("utf-8") if widgetContainer: widgetContainerPrefix = "Container(%s)." % widgetContainer else: widgetContainerPrefix = "" dbid = xbmc.getInfoLabel("%sListItem.DBID" % widgetContainerPrefix).decode("utf-8") if not dbid or dbid == "-1": dbid = xbmc.getInfoLabel("%sListItem.Property(DBID)" % widgetContainerPrefix).decode("utf-8") if dbid == "-1": dbid = "" dbtype = xbmc.getInfoLabel("%sListItem.DBTYPE" % widgetContainerPrefix).decode("utf-8") utils.logMsg("dbtype: %s - dbid: %s" % (dbtype, dbid)) if not dbtype: dbtype = xbmc.getInfoLabel("%sListItem.Property(DBTYPE)" % widgetContainerPrefix).decode( "utf-8" ) if not dbtype: db_type = xbmc.getInfoLabel("%sListItem.Property(type)" % widgetContainerPrefix).decode("utf-8") if "episode" in db_type.lower() or xbmc.getLocalizedString(20360).lower() in db_type.lower(): dbtype = "episode" elif "movie" in db_type.lower() or xbmc.getLocalizedString(342).lower() in db_type.lower(): dbtype = "movie" elif "tvshow" in db_type.lower() or xbmc.getLocalizedString(36903).lower() in db_type.lower(): dbtype = "tvshow" elif "album" in db_type.lower() or xbmc.getLocalizedString(558).lower() in db_type.lower(): dbtype = "album" elif "song" in db_type.lower() or xbmc.getLocalizedString(36920).lower() in db_type.lower(): dbtype = "song" if dbid and dbtype: params["%sID" % dbtype.upper()] = dbid params["lastwidgetcontainer"] = widgetContainer # open info dialog... from resources.lib.InfoDialog import GUI info_dialog = GUI( "script-skin_helper_service-CustomInfo.xml", utils.ADDON_PATH, "Default", "1080i", params=params ) xbmc.executebuiltin("Dialog.Close(busydialog)") if info_dialog.listitem: info_dialog.doModal() resultAction = info_dialog.action if resultAction: while xbmc.getCondVisibility( "System.HasModalDialog | Window.IsActive(script-ExtendedInfo Script-DialogVideoInfo.xml) | Window.IsActive(script-ExtendedInfo Script-DialogInfo.xml) | Window.IsActive(script-skin_helper_service-CustomInfo.xml) | Window.IsActive(script-skin_helper_service-CustomSearch.xml)" ): xbmc.executebuiltin("Action(Back)") xbmc.sleep(500) if "jsonrpc" in resultAction: xbmc.executeJSONRPC(resultAction) else: xbmc.executebuiltin(resultAction) elif action == "COLORPICKER": from resources.lib.ColorPicker import ColorPicker colorPicker = ColorPicker( "script-skin_helper_service-ColorPicker.xml", utils.ADDON_PATH, "Default", "1080i" ) colorPicker.skinString = params.get("SKINSTRING", "") colorPicker.winProperty = params.get("WINPROPERTY", "") colorPicker.activePalette = params.get("PALETTE", "") colorPicker.headerLabel = params.get("HEADER", "") propname = params.get("SHORTCUTPROPERTY", "") colorPicker.shortcutProperty = propname colorPicker.doModal() if propname and not isinstance(colorPicker.result, int): mainmodule.waitForSkinShortcutsWindow() xbmc.sleep(400) currentWindow = xbmcgui.Window(xbmcgui.getCurrentWindowDialogId()) currentWindow.setProperty("customProperty", propname) currentWindow.setProperty("customValue", colorPicker.result[0]) xbmc.executebuiltin("SendClick(404)") xbmc.sleep(250) currentWindow.setProperty("customProperty", propname + ".name") currentWindow.setProperty("customValue", colorPicker.result[1]) xbmc.executebuiltin("SendClick(404)") del colorPicker elif action == "COLORTHEMES": from resources.lib.ColorThemes import ColorThemes colorThemes = ColorThemes("DialogSelect.xml", utils.ADDON_PATH) colorThemes.daynight = params.get("DAYNIGHT", None) colorThemes.doModal() del colorThemes elif action == "CONDITIONALBACKGROUNDS": from resources.lib.ConditionalBackgrounds import ConditionalBackgrounds conditionalBackgrounds = ConditionalBackgrounds("DialogSelect.xml", utils.ADDON_PATH) conditionalBackgrounds.doModal() del conditionalBackgrounds elif action == "CREATECOLORTHEME": import resources.lib.ColorThemes as colorThemes colorThemes.createColorTheme() elif action == "RESTORECOLORTHEME": import resources.lib.ColorThemes as colorThemes colorThemes.restoreColorTheme() elif action == "OVERLAYTEXTURE": mainmodule.selectOverlayTexture() elif action == "BUSYTEXTURE": mainmodule.selectBusyTexture() elif action == "CACHEALLMUSICART": import resources.lib.ArtworkUtils as artworkutils artworkutils.preCacheAllMusicArt() elif action == "RESETCACHE": path = params.get("PATH") if path == "pvr": path = utils.WINDOW.getProperty("SkinHelper.pvrthumbspath").decode("utf-8") utils.WINDOW.setProperty("resetPvrArtCache", "reset") elif path == "music": path = "special://profile/addon_data/script.skin.helper.service/musicartcache/" utils.WINDOW.setProperty("resetMusicArtCache", "reset") elif path == "wallbackgrounds": path = "special://profile/addon_data/script.skin.helper.service/wallbackgrounds/" utils.WINDOW.setProperty("resetWallArtCache", "reset") else: path = None if path: success = True ret = xbmcgui.Dialog().yesno( heading=utils.ADDON.getLocalizedString(32089), line1=utils.ADDON.getLocalizedString(32090) + path, ) if ret: utils.WINDOW.setProperty("SkinHelper.IgnoreCache", "ignore") success = utils.recursiveDelete(path) if success: utils.checkFolders() xbmcgui.Dialog().ok( heading=utils.ADDON.getLocalizedString(32089), line1=utils.ADDON.getLocalizedString(32091), ) else: xbmcgui.Dialog().ok( heading=utils.ADDON.getLocalizedString(32089), line1=utils.ADDON.getLocalizedString(32092), ) elif action == "BACKUP": import resources.lib.BackupRestore as backup filter = params.get("FILTER", "") silent = params.get("SILENT", None) promptfilename = params.get("PROMPTFILENAME", "false") backup.backup(filter, silent, promptfilename.lower()) elif action == "RESTORE": import resources.lib.BackupRestore as backup silent = params.get("SILENT", None) backup.restore(silent) elif action == "RESET": import resources.lib.BackupRestore as backup filter = params.get("FILTER", "") silent = params.get("SILENT", "") == "true" backup.reset(filter, silent) xbmc.Monitor().waitForAbort(2) mainmodule.correctSkinSettings() elif action == "DIALOGOK": headerMsg = params.get("HEADER") bodyMsg = params.get("MESSAGE") if bodyMsg.startswith(" "): bodyMsg = bodyMsg[1:] if headerMsg.startswith(" "): headerMsg = headerMsg[1:] xbmcgui.Dialog().ok(heading=headerMsg, line1=bodyMsg) elif action == "DIALOGYESNO": headerMsg = params.get("HEADER") bodyMsg = params.get("MESSAGE") yesactions = params.get("YESACTION", "").split("|") noactions = params.get("NOACTION", "").split("|") if bodyMsg.startswith(" "): bodyMsg = bodyMsg[1:] if headerMsg.startswith(" "): headerMsg = headerMsg[1:] if xbmcgui.Dialog().yesno(heading=headerMsg, line1=bodyMsg): for action in yesactions: xbmc.executebuiltin(action.encode("utf-8")) else: for action in noactions: xbmc.executebuiltin(action.encode("utf-8")) elif action == "TEXTVIEWER": headerMsg = params.get("HEADER", "") bodyMsg = params.get("MESSAGE", "") if bodyMsg.startswith(" "): bodyMsg = bodyMsg[1:] if headerMsg.startswith(" "): headerMsg = headerMsg[1:] xbmcgui.Dialog().textviewer(headerMsg, bodyMsg) elif action == "FILEEXISTS": filename = params.get("FILE") skinstring = params.get("SKINSTRING") windowprop = params.get("WINDOWPROP") if xbmcvfs.exists(filename): if windowprop: utils.WINDOW.setProperty(windowprop, "exists") if skinstring: xbmc.executebuiltin("Skin.SetString(%s,exists)" % skinstring) else: if windowprop: utils.WINDOW.clearProperty(windowprop) if skinstring: xbmc.executebuiltin("Skin.Reset(%s)" % skinstring) elif action == "STRIPSTRING": splitchar = params.get("SPLITCHAR") string = params.get("STRING") output = params.get("OUTPUT") index = params.get("INDEX", 0) string = string.split(splitchar)[int(index)] utils.WINDOW.setProperty(output, string) elif action == "GETPLAYERFILENAME": output = params.get("OUTPUT") filename = xbmc.getInfoLabel("Player.FileNameAndPath") if not filename: filename = xbmc.getInfoLabel("Player.FileName") if "filename=" in filename: url_params = dict(urlparse.parse_qsl(filename)) filename = url_params.get("filename") utils.WINDOW.setProperty(output, filename) elif action == "GETFILENAME": output = params.get("OUTPUT") filename = xbmc.getInfoLabel("ListItem.FileNameAndPath") if not filename: filename = xbmc.getInfoLabel("ListItem.FileName") if not filename: filename = xbmc.getInfoLabel("Container(999).ListItem.FileName") if not filename: filename = xbmc.getInfoLabel("Container(999).ListItem.FileNameAndPath") if "filename=" in filename: url_params = dict(urlparse.parse_qsl(filename)) filename = url_params.get("filename") utils.WINDOW.setProperty(output, filename) elif action == "CHECKRESOURCEADDONS": ADDONSLIST = params.get("ADDONSLIST") mainmodule.checkResourceAddons(ADDONSLIST) elif action == "GETPERCENTAGE": total = int(params.get("TOTAL")) count = int(params.get("COUNT")) roundsteps = params.get("ROUNDSTEPS") skinstring = params.get("SKINSTRING") percentage = int(round((1.0 * count / total) * 100)) if roundsteps: roundsteps = int(roundsteps) percentage = percentage + (roundsteps - percentage) % roundsteps xbmc.executebuiltin("Skin.SetString(%s,%s)" % (skinstring, percentage))
def __init__(self): utils.logMsg('started loading pluginentry') #get params action = None params = urlparse.parse_qs(sys.argv[2][1:].decode("utf-8")) utils.logMsg("Parameter string: %s" % sys.argv[2]) if params: path=params.get("path",None) if path: path = path[0] limit=params.get("limit",None) if limit: limit = int(limit[0]) else: limit = 25 action=params.get("action",None) if action: action = action[0].upper() if action: if action == "LAUNCHPVR": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "id": 0, "method": "Player.Open", "params": { "item": {"channelid": %d} } }' %int(path)) if action == "PLAYRECORDING": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) #retrieve the recording and play as listitem to get resume working json_result = utils.getJSON('PVR.GetRecordingDetails', '{"recordingid": %d, "properties": [ %s ]}' %(int(path),plugincontent.fields_pvrrecordings)) if json_result: xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "recordingid": %d } }, "id": 1 }' % int(path)) if json_result["resume"].get("position"): for i in range(25): if xbmc.getCondVisibility("Player.HasVideo"): break xbmc.sleep(250) xbmc.Player().seekTime(json_result["resume"].get("position")) elif action == "LAUNCH": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) path = sys.argv[2].split("&path=")[1] xbmc.executebuiltin(path) elif action == "FOCUSANDCLICK": #used as workaround to display local media in extendedinfo actorinfo xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) control=params.get("control")[0] title=params.get("title")[0] totalItems = int(xbmc.getInfoLabel("Container(%s).NumItems" %control)) curItem = 0 itemFound = False xbmc.executebuiltin("Control.SetFocus(%s,0)" %control) while totalItems > curItem: curTitle = xbmc.getInfoLabel("Container(%s).ListItemAbsolute(%s).Title" %(control,curItem)).decode("utf-8") if curTitle == title: itemFound = True xbmc.executebuiltin("Control.SetFocus(%s, %s)" %(control,curItem)) xbmc.executebuiltin("Action(select)") break else: curItem += 1 xbmc.sleep(10) #focus castinfo again after closing videoinfo if itemFound: while not xbmc.getCondVisibility("Window.IsActive(script-ExtendedInfo Script-DialogVideoInfo.xml)"): xbmc.sleep(500) while xbmc.getCondVisibility("Window.IsActive(script-ExtendedInfo Script-DialogVideoInfo.xml)"): xbmc.sleep(500) xbmc.sleep(300) xbmc.executebuiltin("Control.SetFocus(140)") elif action == "PLAYALBUM": xbmcplugin.setResolvedUrl(handle=int(sys.argv[1]), succeeded=False, listitem=xbmcgui.ListItem()) xbmc.executeJSONRPC('{ "jsonrpc": "2.0", "method": "Player.Open", "params": { "item": { "albumid": %d } }, "id": 1 }' % int(path)) elif action == "SMARTSHORTCUTS": skinshortcuts.getSmartShortcuts(path) elif action == "BACKGROUNDS": skinshortcuts.getBackgrounds() elif action == "WIDGETS": skinshortcuts.getWidgets(path) elif action == "GETTHUMB": plugincontent.getThumb(path) elif action == "EXTRAFANART": plugincontent.getExtraFanArt(path) elif action == "GETCAST": movie=params.get("movie",None) if movie: movie = movie[0] tvshow=params.get("tvshow",None) if tvshow: tvshow = tvshow[0] movieset=params.get("movieset",None) if movieset: movieset = movieset[0] episode=params.get("episode",None) if episode: episode = episode[0] downloadthumbs=params.get("downloadthumbs",False) if downloadthumbs: downloadthumbs = downloadthumbs[0]=="true" plugincontent.getCast(movie,tvshow,movieset,episode,downloadthumbs) else: #get a widget listing refresh=params.get("reload",None) if refresh: refresh = refresh[0].upper() optionalParam = None imdbid=params.get("imdbid","") if imdbid: optionalParam = imdbid[0] genre=params.get("genre","") if genre: optionalParam = genre[0] browse=params.get("browse","") if browse: optionalParam = browse[0] reversed=params.get("reversed","") if reversed: optionalParam = reversed[0] type=params.get("type","") if type: optionalParam = type[0] name=params.get("name","") if name: optionalParam = name[0] randomize=params.get("randomize","") if randomize: randomize = randomize[0] randomize = randomize == "true" plugincontent.getPluginListing(action,limit,refresh,optionalParam,randomize) else: #do plugin main listing... plugincontent.doMainListing()
filename = xbmc.getInfoLabel("Container(999).ListItem.FileNameAndPath") if "filename=" in filename: url_params = dict(urlparse.parse_qsl(filename)) filename = url_params.get("filename") utils.WINDOW.setProperty(output, filename) elif action == "CHECKRESOURCEADDONS": ADDONSLIST = params.get("ADDONSLIST") mainmodule.checkResourceAddons(ADDONSLIST) elif action == "GETPERCENTAGE": total = int(params.get("TOTAL")) count = int(params.get("COUNT")) roundsteps = params.get("ROUNDSTEPS") skinstring = params.get("SKINSTRING") percentage = int(round((1.0 * count / total) * 100)) if roundsteps: roundsteps = int(roundsteps) percentage = percentage + (roundsteps - percentage) % roundsteps xbmc.executebuiltin("Skin.SetString(%s,%s)" % (skinstring, percentage)) if __name__ == "__main__": xbmc.executebuiltin("Dialog.Close(busydialog)") if not utils.WINDOW.getProperty("SkinHelperShutdownRequested"): Main() utils.logMsg("finished loading script entry")