def authenticate(self):
        """Aquire authorization token for using thetvdb apis."""
        if self.__token:
            try:
                resp = self._refresh_token()
            except exceptions.TVDBRequestException as err:
                # if a 401 is the cause try to login
                if getattr(err.response, 'status_code', 0) == 401:
                    resp = self._login()
                else:
                    raise
        else:
            resp = self._login()

        self.__token = resp.get('token')
        self._token_timer = timeutil.utcnow()
def authenticate ( self ) : if self . __token : try : resp = self . _refresh_token ( ) except exceptions . TVDBRequestException as err : if getattr ( err . response , 'status_code' , 0 ) == 401 : resp = self . _login ( ) else : raise else : resp = self . _login ( ) self . __token = resp . get ( 'token' ) self . _token_timer = timeutil . utcnow ( )
Aquire authorization token for using thetvdb apis.