def updateSettings(self):

        _username = get_string_setting("username")
        _password = sha1(get_string_setting("password")).hexdigest()

        if not ((self.__username == _username) and (self.__password == _password)):
            self.__username = _username
            self.__password = _password
            self.testAccount(force=True)
Exemplo n.º 2
0
	def __init__(self):
		self.__username = get_string_setting("username")
		self.__password = sha1(get_string_setting("password")).hexdigest()
		Debug("[traktAPI] Initializing")
		Debug("[traktAPI] Testing account '%s'" % self.__username)
		self.settings = None
		if self.testAccount():
			Debug("[traktAPI] Account '%s' is valid." % self.__username)
			Debug("[traktAPI] Getting account settings for '%s'" % self.__username)
			self.getAccountSettings()
		else:
			Debug("[traktAPI] Account '%s' is not valid." % self.__username)
def rate(rating, media):
    import kp, kinopoisk
    cookie=utils.get_string_setting('cookie')
    if cookie=='': cookie=None
    if not cookie:
        login=utils.get_string_setting('login')
        password=utils.get_string_setting('password')
        kpLogin=kp.Login(login,password,cookie)
        cookie=kpLogin.get_cookie()
        utils.set_string_setting('cookie', cookie)
    k=kinopoisk.KinoPoiskRuAgent()
    kpId,title,year=None,None,None
    if 'kinopoiskId' not in media:
        if 'titleAlt' in media: titles=(media['title'], media['titleAlt'])
        else: titles=(media['title'],)
        for i in titles:
            movies=k.search([],{'name':i,'year':media['year']},'English')
            if len(movies)>0:
                if movies[0][4]>90:
                    ret=0
                else:
                    items=[]
                    for i in movies: items.append('%s (%s)'%(i[1],str(i[2])))
                    ret=xbmcgui.Dialog().select('Movies:',items)
                if ret>-1:
                    kpId=movies[ret][0]
                    title=movies[ret][1].encode('utf-8')
                    year=str(movies[ret][2])
                    break
    else:
        kpId=str(media['kinopoiskId'])
        title=media['title'].encode('utf-8')
        year=str(media['year'])
    if kpId and kpId!='None':
        r_class=kp.Rate(str(rating),str(kpId), cookie)
        r=r_class.rateit()
        if r:
            utils.notification('Rated %s OK!' % (str(kpId)),'%s to %s (%s)!' %(str(rating), title, year))
            folderid=utils.get_string_setting('folderid')
            if folderid!="" and folderid>-1 and isinstance(int(folderid),int):
                r_class.moveit(int(folderid))
            return 1
 def __init__(self):
     try:
         self.__username = __myshows__.getSetting('username').strip()
         self.__password = __myshows__.getSetting("password").strip()
         Debug("[myshowsAPI] Initializing")
         self.settings = None
         if self.testAccount():
             Debug("[myshowsAPI] Myshows.ru account '%s' is valid." % self.__username)
     except:
         Debug("[myshowsAPI] Myshows.ru account is NOT valid.")
     login=get_string_setting('login')
     password=get_string_setting('password')
     cookie=get_string_setting('cookie')
     if cookie=='': cookie=None
     if login!='' and password!='':
         kpLogin=kp.Login(login,password,cookie)
         if kpLogin.testAcc():
             Debug("[myshowsAPI] KinoPosik.ru account '%s' is valid." % login)
         else:
             Debug('[myshowsAPI] KinoPosik.ru: can\'t logon!')
     else:
         Debug('[myshowsAPI] KinoPosik.ru: No login or password!')
    def scrobble(self):
        Debug("[Scrobbler] self.curVideo:" + unicode(self.curVideo))
        Debug("[Scrobbler] self.curVideoData" + unicode(self.curVideoData))
        if self.curVideo['type']=="episode":
            match = None
            if 'id' in self.curVideo:
            #if self.curVideo.has_key("multi_episode_count"):
            #cur_episode = self._currentEpisode((self.watchedTime / self.totalTime) * 100, self.curVideo['multi_episode_count'])
                #	cur_episode = self.curVideo['multi_episode_count'] - 1
                #	Debug("[Scrobbler] Multi-part episode, scrobbling part %d of %d." % (cur_episode + 1, self.curVideo['multi_episode_count']))
                #	match = utilities.getEpisodeDetailsFromXbmc(self.curVideo["multi_episode_data"][cur_episode], ['showtitle', 'season', 'episode', 'tvshowid', 'uniqueid'])
                #else:
                match = utilities.getEpisodeDetailsFromXbmc(self.curVideo['id'],
                                                            ['showtitle', 'season', 'episode', 'tvshowid', 'uniqueid', 'file'])
            elif 'showtitle' in self.curVideoData and 'season' in self.curVideoData and 'episode' in self.curVideoData:
                match = {}
                match['tvdb_id'] = None
                match['year'] = None
                match['showtitle'] = self.curVideoData['showtitle']
                match['season'] = self.curVideoData['season']
                match['episode'] = self.curVideoData['episode']
                match['uniqueid'] = self.curVideoData['uniqueid']['unknown']
            elif 'label' in self.curVideo and len(self.curVideo['label']) > 0:
                match = {}
                match['label'] = self.curVideo['label']

            if match == None:
                return

            duration = self.totalTime / 60
            watchedPercent = int((self.watchedTime / self.totalTime) * 100)
            Debug("[Scrobbler] Match for MyShows.ru Plugin: " + str(match))
            xbmc.executebuiltin(
                'xbmc.RunPlugin("plugin://plugin.video.myshows/?mode=70&action=check&title=' + urllib.quote_plus(
                    json.dumps(match)) + '")')
        #response = self.myshowsapi.scrobbleEpisode(match['tvdb_id'], match['showtitle'], match['year'], match['season'], match['episode'], match['uniqueid']['unknown'], duration, watchedPercent)
        #if response != None:
        #Debug("[Scrobbler] Scrobble response: "+str(response))
        elif self.curVideo['type']=="movie":
            if len(self.curVideo['title'])<1:
                Debug("[Scrobbler] No title, stop scrobbing.")
            else:
                import kp
                from rating import rateMedia
                login=get_string_setting('login')
                password=get_string_setting('password')
                cookie=get_string_setting('cookie')
                if cookie=='': cookie=None
                if login!='' and password!='':
                    kpLogin=kp.Login(login,password,cookie)
                else:
                    Debug("No login or password!")
                if not cookie or not kpLogin.testAcc():
                    try:
                        set_string_setting('cookie', kpLogin.get_cookie())
                    except:
                        rateMedia(self.curVideo['type'], self.curVideo, offline=True)
                        return
                if get_string_setting('cookie'):
                    rateMedia(self.curVideo['type'], self.curVideo)

        self.curVideo = None