def login(self): if not self.username and not self.password: return True # fall back to free account elif self.username and self.password and len(self.username)>0 and len(self.password)>0: #util.info('Login user=%s, pass=*****' % self.username) #sclog.logDebug("Login start...") # get salt headers,req = self._create_request('',{'username_or_email':self.username}) sclog.logDebug("Webshare login try '%s' ..."%self._url('api/salt/')) data = util.post(self._url('api/salt/'),req,headers=headers) xml = ET.fromstring(data) if not xml.find('status').text == 'OK': #sclog.logDebug("Login end salt...") #util.error('Server returned error status, response: %s' % data) return False salt = xml.find('salt').text if salt is None: salt = '' # create hashes password = hashlib.sha1(md5crypt(self.password.encode('utf-8'), salt.encode('utf-8'))).hexdigest() digest = hashlib.md5(self.username + ':Webshare:' + self.password).hexdigest() # login headers,req = self._create_request('',{'username_or_email':self.username,'password':password,'digest':digest,'keep_logged_in':1}) data = util.post(self._url('api/login/'),req,headers=headers) xml = ET.fromstring(data) #sclog.logDebug("Login end...") if not xml.find('status').text == 'OK': #util.error('Server returned error status, response: %s' % data) return False self.token = xml.find('token').text #util.info('Login successfull') return True return False
def sendStats(self, item, action, baseUrl, apiVer, deviceId): #send data to server about watching movie #sclog.logDebug('Stats start...') udata = self.userData() urlStats = baseUrl + '/Stats?ver='+apiVer+'&uid='+deviceId dur = float(item['duration']) brate = int(item['bitrate']) ep = '' se = '' if 'episode' in item: ep = str(item['episode']) if 'season' in item: se = str(item['season']) now = datetime.datetime.now() endIn = now + datetime.timedelta(seconds=int(dur)) endStr = endIn.strftime('%H:%M:%S') data = { 'vip':udata.isVip, 'vd': udata.vipDaysLeft, 'est':endStr, 'scid':str(item['id']), 'action': action, 'ws':udata.userId, 'dur':dur, 'bitrate':brate, 'ep':ep, 'se':se } #sclog.logDebug('data=%'%data) headers = {'Content-Type':'application/json', 'X-Uid':deviceId} response = util.post_json(urlStats, data, headers) sclog.logDebug('Stats(%s)=%s'%(item['id'], response)) return udata
def checkSetVIP(u, p, https): try: sclog.logDebug("StaticDataSC hit...") tmp = StaticDataSC(username=u, password=p, useHttps=https) sclog.logDebug("StaticDataSC DONE vipDays=%s"%tmp.vipDaysLeft) __sets('wsvipdays', tmp.vipDaysLeft) except: pass
def login(self): if not self.username and not self.password: return True # fall back to free account elif self.username and self.password and len( self.username) > 0 and len(self.password) > 0: #util.info('Login user=%s, pass=*****' % self.username) #sclog.logDebug("Login start...") # get salt headers, req = self._create_request( '', {'username_or_email': self.username}) sclog.logDebug("Webshare login try '%s' ..." % self._url('api/salt/')) data = util.post(self._url('api/salt/'), req, headers=headers) xml = ET.fromstring(data) if not xml.find('status').text == 'OK': #sclog.logDebug("Login end salt...") #util.error('Server returned error status, response: %s' % data) return False salt = xml.find('salt').text if salt is None: salt = '' # create hashes password = hashlib.sha1( md5crypt(self.password.encode('utf-8'), salt.encode('utf-8'))).hexdigest() digest = hashlib.md5(self.username + ':Webshare:' + self.password).hexdigest() # login headers, req = self._create_request( '', { 'username_or_email': self.username, 'password': password, 'digest': digest, 'keep_logged_in': 1 }) data = util.post(self._url('api/login/'), req, headers=headers) xml = ET.fromstring(data) #sclog.logDebug("Login end...") if not xml.find('status').text == 'OK': #util.error('Server returned error status, response: %s' % data) return False self.token = xml.find('token').text #util.info('Login successfull') return True return False
pass settings = {'quality': __addon__.getSetting('quality')} reverse_eps = __gets('order-episodes') == '0' # fix crazy entry by virtual keyboard fixXcursor() # set number of days left for VIP account checkSetVIP(__gets('wsuser'), __gets('wspass')) scinema = StreamCinemaContentProvider(username=__gets('wsuser'), password=__gets('wspass'), reverse_eps=reverse_eps) # must set again (reason: singleton) scinema.wsuser = __gets('wsuser') scinema.wspass = __gets('wspass') # must set again (reason: singleton) scinema.deviceUid = getDeviceUid() scinema.itemOrderGenre = __gets('item_order_genre') scinema.itemOrderCountry = __gets('item_order_country') scinema.itemOrderQuality = __gets('item_order_quality') #scinema.automaticSubs = __gets('auto_subs')=='true' scinema.langFilter = __gets('item_filter_lang') scinema.session = session sclog.logDebug("PARAMS=%s" % params) xbmcprovider.XBMCMultiResolverContentProvider(scinema, settings, __addon__, session).run(params)