def login(self):
     try:
         control.setSetting(id='login.tokenrem', value='')
         control.setSetting(id='login.tokenses', value='')
         control.setSetting(id='login.tokencfd', value='')
         payload = {
             'username': control.getSetting("9anime.username"),
             'password': control.getSetting("9anime.password"),
             'remember': 1
         }
         url = self._to_url_login("user/ajax/login")
         p = requests.post(url, data=payload)
         r = p.headers['Set-Cookie']
         remember_me = ''.join(
             re.compile('remember_web_.+?=(.+?);').findall(r))
         session = ''.join(re.compile('session=(.+?);').findall(r))
         cfduid = ''.join(re.compile('__cfduid=(.+?);').findall(r))
         control.setSetting(id='login.tokenrem', value=remember_me)
         control.setSetting(id='login.tokenses', value=session)
         control.setSetting(id='login.tokencfd', value=cfduid)
         control.setSetting(id='login.auth', value='loggedin')
         dialog = xbmcgui.Dialog()
         dialog.ok(control.lang(30200), json.loads(p.text)['message'])
         control.refresh()
     except:
         dialog = xbmcgui.Dialog()
         dialog.ok(control.lang(30200), control.lang(30201))
 def logout(self):
     control.setSetting(id='login.tokenrem', value='')
     control.setSetting(id='login.tokenses', value='')
     control.setSetting(id='login.tokencfd', value='')
     control.setSetting(id='login.auth', value='')
     control.refresh()