def system(self, data, cl=False): util.debug("[SC] SYSYEM CL: %s" % str(cl)); if cl is False and "setContent" in data: xbmcplugin.setContent(int(sys.argv[1]), data["setContent"]) ''' view_mode=data["setContent"].lower() skin_name=xbmc.getSkinDir() # nacitame meno skinu util.debug("[SC] skin_name='"+skin_name+"'") try: util.debug("[SC] view mode is "+view_mode) view_codes=sctop.ALL_VIEW_CODES.get(view_mode) view_code=view_codes.get(skin_name) util.debug("[SC] view code for "+view_mode+" in "+skin_name+" is "+str(view_code)) xbmc.executebuiltin("Container.SetViewMode("+str(view_code)+")") #xbmc.executebuiltin("Container.Refresh") except: util.debug("[SC] Unable to find view code for view mode "+str(view_mode)+" and skin "+skin_name) ''' if cl is False and "setPluginCategory" in data: xbmcplugin.setPluginCategory(int(sys.argv[1]), data["setPluginCategory"]) if cl is False and "addSortMethod" in data: xbmcplugin.addSortMethod(int(sys.argv[1]), sctop.sortmethod[int(data["addSortMethod"])]) if cl is False and data.get('addSortMethods'): for m in data.get("addSortMethods"): xbmcplugin.addSortMethod(int(sys.argv[1]), sctop.sortmethod[int(m)]) if cl is False and "setPluginFanart" in data: xbmcplugin.setPluginFanart(int(sys.argv[1]), data["setPluginFanart"]) if cl is False and "version" in data: util.info("[SC] kontrola verzie: %s %s" % (str(sctop.addonInfo('version')), data["version"])) if sctop.addonInfo('version') != data["version"] and sctop.getSetting('ver') != data['version']: try: sctop.dialog.ok(sctop.getString(30954), sctop.getString(30955) % str(data['version'])) except: pass xbmc.executebuiltin('UpdateAddonRepos') sctop.setSetting('ver', data['version']) if sctop.getSettingAsBool('cachemigrate') == '' or sctop.getSettingAsBool('cachemigrate') is False: self.parent.cacheMigrate() pass pass if cl is False and "focus" in data: self.parent.system = {"focus": data['focus']} if cl is True and "focus" in data: try: self.parent.endOfDirectory() util.debug("[SC] nastavujem focus na: %d" % int(data['focus'])) xel = xbmcgui.Window(xbmcgui.getCurrentWindowId()) ctr = xel.getControl(xel.getFocusId()) ctr.selectItem(int(data['focus'])) except Exception as e: util.debug("[SC] error focus :-( %s" % str(traceback.format_exc())) pass
def action(self, data): if self.scid is None: return url = "%s/Stats" % (sctop.BASE_URL) data.update({'est': self.estimateFinishTime}) data.update({'se': self.se, 'ep': self.ep}) data.update({'ver': sctop.addonInfo('version')}) try: data.update( {'state': bool(xbmc.getCondVisibility("!Player.Paused"))}) data.update({ 'ws': xbmcgui.Window(10000).getProperty('ws.ident'), 'vip': xbmcgui.Window(10000).getProperty('ws.vip') }) data.update({'vd': xbmcgui.Window(10000).getProperty('ws.days')}) data.update({'skin': xbmc.getSkinDir()}) if 'bitrate' in self.stream: util.debug("[SC] action bitrate") data.update({'bt': self.stream['bitrate']}) else: util.debug("[SC] action no bitrate") except: pass try: if self.itemDuration > 0: data.update({'dur': self.itemDuration}) except Exception: pass self.log("[SC] action: %s" % str(data)) url = self.parent.provider._url(url) sctop.post_json(url, data, {'X-UID': sctop.uid})
def _url(self, url): if url.startswith('plugin://'): return url if url.startswith('cmd://'): if '__self__' in url: url.replace('__self__', sctop.__scriptid__) return url if url.startswith('/'): url = sctop.BASE_URL + url if not url.startswith('http'): util.debug('[SC] nemame http v URL %s' % url) o = urlparse(self.base_url) else: o = urlparse(url) q = parse_qs(o.query) q.update({ 'uid': self.uid, 'ver': sctop.API_VERSION, 'lang': sctop.KODI_LANG, 'v': sctop.addonInfo('version') }) util.debug( '[SC] providers [%s] [%s]' % (str(sctop.getSetting('kruser')), str(sctop.getSetting('wsuser')))) if sctop.getSetting('kruser') != '' and sctop.getSetting( 'wsuser') != '': q.update({'pro': 'kraska,webshare'}) elif sctop.getSetting('kruser') != '': q.update({'pro': 'kraska'}) elif sctop.getSetting('wsuser') != '': q.update({'pro': 'webshare'}) if sctop.getSettingAsBool('filter_audio'): q.update({'l': sctop.getSetting('filter_lang.1')}) if not url.startswith('http'): n = [ str(o[0]), str(o[1]), str(o[2]).rstrip('./') + '/' + url.lstrip('./'), str(o[3]), '' ] else: n = [str(o[0]), str(o[1]), str(o[2]), str(o[3]), ''] n[3] = urllib.urlencode(q, True) nurl = urlunsplit(n) return nurl
def __init__(self, username=None, password=None, filter=None, uid=None): ContentProvider.__init__(self, name='czsklib', base_url=sctop.BASE_URL, username=username, password=password, filter=filter) self.tr = tracker.TrackerInfo().getSystemInfo() self.uid = uid util.UA = self.tr['useragent'] + ' ver' + str(sctop.addonInfo('version')) #util.debug("[SC] tr: %s" % str(self.tr)) self.cache = sctop.cache util.debug("[SC] init cache %s" % self.cache.__class__.__name__) util.init_urllib(self.cache) cookies = self.cache.get('cookies') #if not cookies or len(cookies) == 0: # util.request(self._url(self.base_url)) self.ws = None
def action(self, data): if self.scid is None: util.debug("[SC] nemame scid") return if data.get('action', None) is None: util.debug("[SC] nemame action") return url = "%s/Stats?action=%s" % (sctop.BASE_URL, data.get( 'action', 'None')) data.update({'est': self.estimateFinishTime}) data.update({'se': self.se, 'ep': self.ep}) data.update({'ver': sctop.addonInfo('version')}) lastAction = xbmcgui.Window(10000).getProperty('sc.lastAction') util.debug('[SC] lastAction: %s' % (str(lastAction))) if lastAction == "" or time() - float(lastAction) > 5: xbmcgui.Window(10000).setProperty('sc.lastAction', str(time())) try: data.update( {'state': bool(xbmc.getCondVisibility("!Player.Paused"))}) data.update({ 'ws': xbmcgui.Window(10000).getProperty('ws.ident'), 'vip': xbmcgui.Window(10000).getProperty('ws.vip') }) data.update( {'vd': xbmcgui.Window(10000).getProperty('ws.days')}) data.update({'skin': xbmc.getSkinDir()}) if 'bitrate' in self.stream: util.debug("[SC] action bitrate") data.update({'bt': self.stream['bitrate']}) else: util.debug("[SC] action no bitrate") except: pass try: if self.itemDuration > 0: data.update({'dur': self.itemDuration}) except Exception: pass util.debug("[SC] action: %s" % str(data)) url = self.parent.provider._url(url) try: sctop.post_json(url, data, {'X-UID': sctop.uid}) except: pass
def __init__(self, username=None, password=None, filter=None, uid=None): ContentProvider.__init__(self, name='czsklib', base_url=sctop.BASE_URL, username=username, password=password, filter=filter) self.tr = tracker.TrackerInfo().getSystemInfo() self.uid = uid util.UA = self.tr['useragent'] + ' ver' + str( sctop.addonInfo('version')) #util.debug("[SC] tr: %s" % str(self.tr)) self.cache = sctop.cache self.ws = wx(sctop.getSetting('wsuser'), sctop.getSetting('wspass'), self.cache) util.debug("[SC] init cache %s" % self.cache.__class__.__name__) util.init_urllib(self.cache) cookies = self.cache.get('cookies') hasTrakt = str(sctop.getSetting('trakt.token') != '') util.debug('[SC] has trakt: %s' % hasTrakt) sctop.win.setProperty('sc.trakt', hasTrakt)
def upNext(self): util.debug("[SC] upNext: start") try: if self.scid is None or self.upNextEnable == False: util.debug("[SC] upNext: nieje nas plugin") return playTime = xbmc.Player().getTime() totalTime = xbmc.Player().getTotalTime() if self.itemType == 'episode': util.debug("[SC] upNext: mame serial %sx%s" % (str(self.se), str(self.ep))) provider = self.parent.provider url = provider._url( '/upNext/%s/%s/%s' % (str(self.scid), str(self.se), str(self.ep))) util.debug("[SC] upNext URL: %s" % str(url)) data = provider._json(url) util.debug("[SC] upNext data: %s" % str(data)) if data and "url" in data: #$INFO[Player.TimeRemaining(ss)] nextUpPage = NextUpInfo("sc-NextUpInfo.xml", sctop.addonInfo('path'), "default", "1080i") nextUpPage.setItem(data) nextUpPage.show() while xbmc.Player().isPlaying() and ( totalTime - playTime > 1) and not nextUpPage.isCancel( ) and not nextUpPage.isWatchNow(): sctop.sleep(100) try: playTime = xbmc.Player().getTime() totalTime = xbmc.Player().getTotalTime() except: pass nextUpPage.close() shouldPlayDefault = not nextUpPage.isCancel() shouldPlayNonDefault = nextUpPage.isWatchNow() self.upNextEnable = False util.debug( "[SC] upNext: [%s] [%s] " % (str(shouldPlayDefault), str(shouldPlayNonDefault))) if shouldPlayDefault or shouldPlayNonDefault: self.stop() data.update({'play': data['url'], 'url': data['url']}) pu = sctop._create_plugin_url( { 'dtitle': data['title'], 'play': data['url'] }, 'plugin://' + sctop.__scriptid__ + '/') util.debug("[SC] upNext pluginurl: %s" % str(pu)) self.play(pu) return util.debug("[SC] upNExt smola :-(") return else: util.debug("[SC] upNext: mame film") return except Exception, e: util.error('[SC] upNext err: %s' % str(e)) pass
def action(self, data): if self.scid is None: util.debug("[SC] nemame scid") return if data.get('action', None) is None: util.debug("[SC] nemame action") return if self.stream is None: try: stream = json.loads( self.win.getProperty('%s.stream' % sctop.__scriptid__)) util.debug("[SC] stream %s" % str(stream)) self.stream = stream except: pass url = "%s/Stats?action=%s" % (sctop.BASE_URL, data.get( 'action', 'None')) data.update({'est': self.estimateFinishTime}) data.update({'se': self.se, 'ep': self.ep}) data.update({'ver': sctop.addonInfo('version')}) try: data.update( {'state': bool(xbmc.getCondVisibility("!Player.Paused"))}) data.update({ 'ws': xbmcgui.Window(10000).getProperty('ws.ident'), 'vip': xbmcgui.Window(10000).getProperty('ws.vip'), 'vt': xbmcgui.Window(10000).getProperty('ws.viptyp') }) data.update({'vd': xbmcgui.Window(10000).getProperty('ws.days')}) data.update({'skin': xbmc.getSkinDir()}) if self.stream is not None: if 'bitrate' in self.stream: util.debug("[SC] action bitrate") data.update({'bt': self.stream['bitrate']}) else: util.debug("[SC] action no bitrate") if 'sid' in self.stream: util.info( '[SC] mame sid <====================================================================================' ) data.update({'sid': self.stream['sid']}) else: util.info( '[SC] no sid in stream <==================================================================================== %s' % str(self.stream)) except Exception as e: util.info('[SC] problem s updatom dat: %s' % str(traceback.format_exc())) pass try: if self.itemDuration > 0: data.update({'dur': self.itemDuration}) except Exception: pass lastAction = xbmcgui.Window(10000).getProperty('sc.lastAction') util.debug('[SC] lastAction: %s' % (str(lastAction))) if lastAction == "" or time() - float(lastAction) > 5: xbmcgui.Window(10000).setProperty('sc.lastAction', str(time())) util.debug("[SC] action: %s" % str(data)) url = self.parent.provider._url(url) try: sctop.post_json(url, data, {'X-UID': sctop.uid}) except: pass