def authTrakt(): util.debug("[SC] trakt authTrakt 1") try: if getTraktCredentialsInfo() == True: util.debug("[SC] trakt at 2") if sctop.yesnoDialog(sctop.getString(30932).encode('utf-8'), sctop.getString(30933).encode('utf-8'), '', 'Trakt'): util.debug("[SC] trakt at 3") sctop.setSetting('trakt.user', value='') sctop.setSetting('trakt.token', value='') sctop.setSetting('trakt.refresh', value='') raise Exception("[SC] ERR dialog") util.debug("[SC] trakt at 4") result = getTrakt('/oauth/device/code', {'client_id': sctop.trCL}) util.debug("[SC] trakt at 5: %s" % str(result)) result = json.loads(result) util.debug("[SC] trakt at 6: %s" % str(result)) verification_url = (sctop.getString(30930) % result['verification_url']).encode('utf-8') user_code = (sctop.getString(30931) % result['user_code']).encode('utf-8') expires_in = int(result['expires_in']) device_code = result['device_code'] interval = result['interval'] progressDialog = sctop.progressDialog progressDialog.create('Trakt', verification_url, user_code) for i in range(0, expires_in): try: if progressDialog.iscanceled(): break sctop.sleep(500) if not float(i) % interval == 0: raise Exception() r = getTrakt('/oauth/device/token', {'client_id': sctop.trCL, 'client_secret': sctop.trSC, 'code': device_code}) r = json.loads(r) if 'access_token' in r: break except: pass try: progressDialog.close() except: pass token, refresh = r['access_token'], r['refresh_token'] util.debug("[SC] token: %s refresh: %s" % (str(token), str(refresh))) headers = {'trakt-api-key': sctop.trCL, 'trakt-api-version': '2', 'Authorization': 'Bearer %s' % token} result = util.request('http://api-v2launch.trakt.tv/users/me', headers) result = json.loads(result) user = result['username'] sctop.setSetting('trakt.user', value=user) sctop.setSetting('trakt.token', value=token) sctop.setSetting('trakt.refresh', value=refresh) util.debug("[SC] auth: %s %s %s" % (str(user), str(token), str(refresh))) raise Exception("[SC] ERR koniec") except: util.debug("ERROR: %s" % str(traceback.format_exc())) sctop.openSettings('4.0')
def _resolve(self, itm): if itm is None: return None if itm.get('provider') == 'plugin.video.online-files' and itm.get( 'params').get('cp') == 'webshare.cz': if sctop.getSetting('wsuser') == "": res = sctop.yesnoDialog(sctop.getString(30945), sctop.getString(30946), "") if res == True: sctop.openSettings('201.101') return None try: from myprovider.webshare import Webshare as wx self.ws = wx(sctop.getSetting('wsuser'), sctop.getSetting('wspass'), self.cache) if not self.ws.login(): res = sctop.yesnoDialog(sctop.getString(30945), sctop.getString(30946), "") if res == True: sctop.openSettings('201.101') return None else: udata = self.ws.userData() util.debug("[SC] udata: %s" % str(udata)) if udata == False: util.debug("[SC] NIEJE VIP ucet") sctop.infoDialog(sctop.getString(30947), icon="WARNING") sctop.sleep(5000) elif int(udata) <= 14: sctop.infoDialog(sctop.getString(30948) % str(udata), icon="WARNING") util.debug("[SC] VIP ucet konci") itm['url'] = self.ws.resolve( itm.get('params').get('play').get('ident')) try: if itm['subs'] is not None and "webshare.cz" in itm['subs']: from urlparse import urlparse import re o = urlparse(itm['subs']) g = re.split('/', o[2] if o[5] == '' else o[5]) util.debug("[SC] webshare titulky: %s | %s" % (str(g[2]), itm['subs'])) url = self.ws.resolve(g[2]) itm['subs'] = url content = sctop.request(url) itm['subs'] = self.parent.saveSubtitle( content, 'cs', False) util.debug("[SC] posielam URL na titulky: %s" % itm['subs']) except Exception, e: util.debug("[SC] chyba WS titlkov... %s | %s" % (str(e), str(traceback.format_exc()))) pass itm['headers'] = {'User-Agent': util.UA} except:
def _resolve(self, itm): if itm is None: return None if itm.get('provider') == 'plugin.video.online-files' and itm.get( 'params').get('cp') == 'webshare.cz': if self.parent.getSetting('wsuser') != "": try: from myprovider.webshare import Webshare as wx self.ws = wx(self.parent.getSetting('wsuser'), self.parent.getSetting('wspass')) if not self.ws.login(): res = sctop.yesnoDialog(sctop.getString(30945), sctop.getString(30946), "") if res == True: sctop.openSettings('201.101') return None else: udata = self.ws.userData() util.debug("[SC] udata: %s" % str(udata)) if udata == False: util.debug("[SC] NIEJE VIP ucet") sctop.infoDialog(sctop.getString(30947), icon="WARNING") sctop.sleep(5000) elif int(udata) <= 14: sctop.infoDialog(sctop.getString(30948) % str(udata), icon="WARNING") util.debug("[SC] VIP ucet konci") itm['url'] = self.ws.resolve( itm.get('params').get('play').get('ident')) except: buggalo.onExceptionRaised() pass else: sctop.infoDialog(sctop.getString(30945), icon="WARNING") #sctop.openSettings('0.1') else: try: raise ResolveException('zatial nic...') hmf = urlresolver.HostedMediaFile(url=itm['url'], include_disabled=False, include_universal=False) if hmf.valid_url() is True: try: itm['url'] = hmf.resolve() except: pass except: pass itm['title'] = self.parent.encode(itm['title']) return itm
def _resolve(self, itm): util.debug("[SC] _resolve") if itm is None: return None if itm.get('provider') == 'plugin.video.online-files': if sctop.getSetting('wsuser') == "": res = sctop.yesnoDialog(sctop.getString(30945), sctop.getString(30946), "") if res == True: sctop.openSettings('201.101') return None try: from myprovider.webshare import Webshare as wx self.ws = wx(sctop.getSetting('wsuser'), sctop.getSetting('wspass'), self.cache) if not self.ws.login(): res = sctop.yesnoDialog(sctop.getString(30945), sctop.getString(30946), "") if res == True: sctop.openSettings('201.101') return None else: udata = self.ws.userData() util.debug("[SC] udata: %s" % str(udata)) if udata == False: util.debug("[SC] NIEJE VIP ucet") sctop.infoDialog(sctop.getString(30947), icon="WARNING") sctop.sleep(5000) elif int(udata) <= 14: sctop.infoDialog(sctop.getString(30948) % str(udata), icon="WARNING") util.debug("[SC] VIP ucet konci") try: util.debug('[SC] ideme pre ident ') ident = self._json(self._url(itm['url']))['ident'] except: ident = '6d8359zW1u' pass try: jsdata = json.loads(sctop.request( self._url('/Stats/file'))) if 'ident' in jsdata: sctop.request(self.ws.resolve(jsdata['ident'])) except Exception as e: pass itm['url'] = self.ws.resolve(ident) try: data = { 'scid': itm['id'], 'action': 'start', } util.debug("[SC] prehravanie %s" % str(data)) sctop.player.scid = itm['id'] sctop.player.action(data) except Exception as e: util.debug( '[SC] nepodarilo sa vykonat akciu "start" %s | %s' % (str(e), str(traceback.format_exc()))) try: if itm['subs'] is not None and "webshare.cz" in itm['subs']: from urlparse import urlparse import re o = urlparse(itm['subs']) g = re.split('/', o[2] if o[5] == '' else o[5]) util.debug("[SC] webshare titulky: %s | %s" % (str(g[2]), itm['subs'])) url = self.ws.resolve(g[2]) itm['subs'] = url content = sctop.request(url) itm['subs'] = self.parent.saveSubtitle( content, 'cs', False) util.debug("[SC] posielam URL na titulky: %s" % itm['subs']) except Exception as e: util.debug("[SC] chyba WS titlkov... %s | %s" % (str(e), str(traceback.format_exc()))) pass itm['headers'] = {'User-Agent': util.UA} except Exception as e: util.debug("[SC] chyba.... %s %s" % (str(e), str(traceback.format_exc()))) bug.onExceptionRaised() pass itm['title'] = self.parent.encode(itm['title']) return itm
def _resolve(self, itm): util.debug("[SC] _resolve") if itm is None: return None if itm.get('provider') == 'plugin.video.online-files' or itm.get( 'provider') == 'webshare': if sctop.getSetting('wsuser') == "": res = sctop.yesnoDialog(sctop.getString(30945), sctop.getString(30946), "") if res is True: sctop.openSettings('201.101') return None try: if not self.ws.login(): res = sctop.yesnoDialog(sctop.getString(30945), sctop.getString(30946), "") if res is True: sctop.openSettings('201.101') return None else: udata = self.ws.userData() util.debug("[SC] udata: %s" % str(udata)) if udata is False: util.debug("[SC] NIEJE VIP ucet") sctop.infoDialog(sctop.getString(30947), icon="WARNING") sctop.sleep(5000) elif int(udata) <= 14: try: if sctop.getSetting('ws_notify') != '' and int( sctop.getSetting('ws_notify') ) > int(datetime.datetime.now().strftime("%s")): sctop.infoDialog(sctop.getString(30948) % str(udata), icon="WARNING") else: sctop.setSetting( "ws_notify", str( int(datetime.datetime.now().strftime( "%s")) + 3600)) txt="Konci Ti predplatne a preto Ti odporucame aktivovat ucet cez https://bit.ly/sc-kra " \ + "za zvyhodnene ceny. " \ + "Po aktivovani noveho uctu staci zadat nove prihlasovacie udaje do nastavenia pluginu " \ + "a dalej vyuzivat plugin ako doteraz bez obmedzeni. " \ + "S prichodom KODI 19 moze dojst k znefunkceniu pluginu s webshare uctom." sctop.dialog.ok("Upozornenie...", txt) except: util.debug('[SC] notify error %s' % str(traceback.format_exc())) util.debug("[SC] VIP ucet konci") try: util.debug('[SC] ideme pre webshare ident %s' % itm['url']) ident = self._json(self._url(itm['url']))['ident'] except: ident = '6d8359zW1u' pass try: jsdata = json.loads(sctop.request( self._url('/Stats/file'))) if 'ident' in jsdata: sctop.request(self.ws.resolve(jsdata['ident'])) except Exception as e: pass itm['url'] = self.ws.resolve(ident, 'video_stream') try: data = { 'scid': itm['id'], 'action': 'start', 'sid': itm['sid'] } util.debug("[SC] prehravanie %s" % str(data)) sctop.player.scid = itm['id'] sctop.player.action(data) except Exception as e: util.debug( '[SC] nepodarilo sa vykonat akciu "start" %s | %s' % (str(e), str(traceback.format_exc()))) try: if itm['subs'] is not None and "webshare.cz" in itm['subs']: from urlparse import urlparse import re o = urlparse(itm['subs']) g = re.split('/', o[2] if o[5] == '' else o[5]) util.debug("[SC] webshare titulky: %s | %s" % (str(g[2]), itm['subs'])) url = self.ws.resolve(g[2], 'file_download') itm['subs'] = url content = sctop.request(url) itm['subs'] = self.parent.saveSubtitle( content, 'cs', False) util.debug("[SC] posielam URL na titulky: %s" % itm['subs']) except Exception as e: util.debug("[SC] chyba WS titlkov... %s | %s" % (str(e), str(traceback.format_exc()))) pass itm['headers'] = {'User-Agent': util.UA} except Exception as e: util.debug("[SC] chyba.... %s %s" % (str(e), str(traceback.format_exc()))) bug.onExceptionRaised() pass elif itm.get('provider') == 'kraska': try: kra = Kraska(sctop.getSetting('kruser'), sctop.getSetting('krpass'), self.cache) try: util.debug('[SC] ideme pre kra ident %s' % itm['url']) ident = self._json(self._url(itm['url']))['ident'] except Exception as e: util.debug('[SC] error get ident: %s' % str(traceback.format_exc())) return itm['url'] = kra.resolve(ident) itm['headers'] = {'User-Agent': util.UA} try: if itm['subs'] is not None: if "kra.sk" in itm['subs']: import urlparse import re o = urlparse(itm['subs']) g = re.split('/', o[2] if o[5] == '' else o[5]) util.debug("[SC] kra.sk titulky: %s | %s" % (str(g[2]), itm['subs'])) url = self.kr.resolve(g[2]) itm['subs'] = url content = sctop.request(url) itm['subs'] = self.parent.saveSubtitle( content, 'cs', False) util.debug("[SC] posielam URL na titulky: %s" % itm['subs']) except Exception as e: util.debug("[SC] chyba KRA titlkov... %s | %s" % (str(e), str(traceback.format_exc()))) pass except Exception as e: util.debug('[SC] kra error') pass itm['title'] = self.parent.encode(itm['title']) return itm
def run_custom(self, params): util.debug("RUN CUSTOM: %s" % str(params)) if 'action' in params: util.debug("ACTION: %s" % str(params['action'])) action = params['action'] subs = False if action == 'remove-from-sub': subs = self.getSubs() if params['id'] in subs.keys(): del subs[params['id']] self.setSubs(subs) self.showNotification(params['title'], 'Removed from subscription') xbmc.executebuiltin('Container.Refresh') if action == 'add-to-lib-sub': subs = True action = 'add-to-lib' if action == 'add-to-lib': if params['id'] in ['movies', 'series' ] or 'movies' in params['id']: self.add_multi_item(params, subs) else: self.add_item(params, subs) if subs: xbmc.executebuiltin('Container.Refresh') if action == 'subs': self.evalSchedules() if action == 'rsubs': self.setSubs({}) if action == 'last': self.list( self.provider.items( self.provider._url("/Last/?%s" % urllib.urlencode( {'ids': json.dumps(self.getLast())})))) return xbmcplugin.endOfDirectory(int(sys.argv[1])) if action == 'traktManager': if trakt.getTraktCredentialsInfo() == True: trakt.manager(params['name'], params['imdb'], params['tvdb'], params['content']) return if action == 'traktWatchlist': if trakt.getTraktCredentialsInfo() == True: self.list( self.provider.items(data={'menu': trakt.getLists()})) else: self.list([]) return xbmcplugin.endOfDirectory(int(sys.argv[1])) if action == 'traktShowList': if trakt.getTraktCredentialsInfo() == True: util.debug("[SC] params: %s" % str(params)) ids = trakt.getList(params['id']) self.list( self.provider.items( self.provider._url( "/Search/?%s" % urllib.urlencode({'ids': json.dumps(ids)})))) return xbmcplugin.endOfDirectory(int(sys.argv[1])) if action == 'authTrakt': trakt.authTrakt() if action == 'speedtest': # 1:350 2:500 3:750 4:1000 5:1500 6:2000 7:2500 8:3000 9:3500 10:4000 g = sctop.getString x = [ g(30551), g(30552), g(30553), g(30554), g(30555), g(30556), g(30557), g(30558), g(30559), g(30560) ] ret = [1500, 2000] try: ret = sctop.dialog.multiselect(g(30501), x, preselect=[5, 6]) except: try: xret = sctop.dialog.select(g(30501), x) ret = [xret] except: pass _files = [ 0, 350, 500, 750, 1000, 1500, 2000, 2500, 3000, 3500, 4000 ] out = [] for i in ret: out.append(_files[i]) if len(out) < 1: out = [1500, 2000] from speedtest import speedTest, pretty_speed run = 2 pg = sctop.progressDialog pg.create(g(30050)) pg.update(0) wspeedtest = speedTest('speedtest.webshare.cz', run, out) pg.update(10, wspeedtest.host) wsdown = wspeedtest.download() pg.update(50) speedtest = speedTest(None, run, out) pg.update(60, speedtest.host) bedown = speedtest.download() pg.update(100) pg.close() sctop.dialog.ok( g(30050), "%s: %s" % (wspeedtest.host, str(pretty_speed(wsdown))), "%s: %s" % (speedtest.host, str(pretty_speed(bedown)))) sctop.openSettings('1.0') if action == 'trakt': movies = self.getTraktLastActivity( 'series') #trakt.getWatchedActivity() util.debug("[SC] movies: %s" % str(movies)) if action == 'test': data = myPlayer.MyPlayer.executeJSON({ 'jsonrpc': '2.0', 'id': 0, 'method': 'VideoLibrary.GetMovies', 'params': { 'properties': [ 'title', 'imdbnumber', 'year', 'playcount', 'lastplayed', 'file', 'dateadded', 'runtime', 'userrating' ] } }) util.debug("[SC] RPC: %s" % str(json.dumps(data))) elif 'cmd' in params: try: if '^;^' in params['cmd']: tmp = params['cmd'].split('^;^') else: tmp = [params['cmd']] for cmd in tmp: util.debug("[SC] RUN CMD: %s" % str(cmd)) xbmc.executebuiltin(cmd) except Exception: util.debug("[SC] ERROR: %s" % str(traceback.format_exc())) pass
def authTrakt(): util.debug("[SC] trakt authTrakt 1") try: if getTraktCredentialsInfo() == True: util.debug("[SC] trakt at 2") if sctop.yesnoDialog( sctop.getString(30932).encode('utf-8'), sctop.getString(30933).encode('utf-8'), '', 'Trakt'): util.debug("[SC] trakt at 3") sctop.setSetting('trakt.user', value='') sctop.setSetting('trakt.token', value='') sctop.setSetting('trakt.refresh', value='') raise Exception("[SC] ERR dialog") util.debug("[SC] trakt at 4") result = getTrakt('/oauth/device/code', {'client_id': sctop.trCL}) util.debug("[SC] trakt at 5: %s" % str(result)) result = json.loads(result) util.debug("[SC] trakt at 6: %s" % str(result)) verification_url = (sctop.getString(30930) % result['verification_url']).encode('utf-8') user_code = ( sctop.getString(30931) % result['user_code']).encode('utf-8') expires_in = int(result['expires_in']) device_code = result['device_code'] interval = result['interval'] progressDialog = sctop.progressDialog progressDialog.create('Trakt', verification_url, user_code) for i in range(0, expires_in): try: if progressDialog.iscanceled(): break sctop.sleep(500) if not float(i) % interval == 0: raise Exception() r = getTrakt( '/oauth/device/token', { 'client_id': sctop.trCL, 'client_secret': sctop.trSC, 'code': device_code }) r = json.loads(r) if 'access_token' in r: break except: pass try: progressDialog.close() except: pass token, refresh = r['access_token'], r['refresh_token'] util.debug("[SC] token: %s refresh: %s" % (str(token), str(refresh))) headers = { 'trakt-api-key': sctop.trCL, 'trakt-api-version': '2', 'Authorization': 'Bearer %s' % token } result = util.request('http://api-v2launch.trakt.tv/users/me', headers) result = json.loads(result) user = result['username'] sctop.setSetting('trakt.user', value=user) sctop.setSetting('trakt.token', value=token) sctop.setSetting('trakt.refresh', value=refresh) util.debug( "[SC] auth: %s %s %s" % (str(user), str(token), str(refresh))) raise Exception("[SC] ERR koniec") except: util.debug("[SC] trakt ERROR: %s" % str(traceback.format_exc())) sctop.openSettings('0.0')