Example #1
0
 def __get_request_token(self):
     url = self.__gen_oauth_url('request_token')
     res = requests.post(url,{'oauth_callback':self.callback_url},hooks={'pre_request':self._consumer})
     qs = Utils.parse_qs(res.text)
     request_token = qs['oauth_token'][0]
     request_secret = qs['oauth_token_secret'][0]
     return request_token, request_secret
Example #2
0
 def get_access_token(self,verifier):
     url = self.__gen_oauth_url('access_token')
     self._consumer.token = Token(self.__request_tokens[0],self.__request_tokens[1])
     res = requests.post(url,{'oauth_verifier':verifier},hooks={'pre_request':self._consumer})
     qs = Utils.parse_qs(res.content)
     access_token = qs['oauth_token'][0]
     access_token_secret = qs['oauth_token_secret'][0]
     self.__access_tokens = [access_token,access_token_secret]
     return self.__access_tokens
Example #3
0
 def parse(cls, api, json):
     user = cls(api)
     for k,v in json.items():
         if k == 'updated':
             if v == 0:
                 v = None
             else:
                 v = Utils.unixtime2datetime(v)
         setattr(user,k,v)
     return user
Example #4
0
 def parse(cls, api, json):
     bloginfo = cls(api)
     for k,v in json.get('blog', json).items():
         if k == 'updated':
             if v == 0:
                 v = None
             else:
                 v = Utils.unixtime2datetime(v)
         setattr(bloginfo, k, v)
     return bloginfo
Example #5
0
 def parse(cls, api, json):
     post = cls(api)
     for k,v in json.items():
         if k == 'timestamp': # Unnecessary value
             pass
         elif k == 'date':
             setattr(post,'date',Utils.gmtstring2datetime(v))
         else:
             setattr(post,k,v)
     return post
Example #6
0
 def next(self):
     api_parameters = self._api.last_api_parameters
     path_endpoint = Utils.urlparse(self._api.last_api_url).path.split('/')[-1]
     if path_endpoint == self._api.POST_TYPE_TEXT:
         post_type = path_endpoint
     elif path_endpoint == self._api.POST_TYPE_QUOTE:
         post_type = path_endpoint
     elif path_endpoint == self._api.POST_TYPE_LINK:
         post_type = path_endpoint
     elif path_endpoint == self._api.POST_TYPE_ANSWER:
         post_type = path_endpoint
     elif path_endpoint == self._api.POST_TYPE_VIDEO:
         post_type = path_endpoint
     elif path_endpoint == self._api.POST_TYPE_AUDIO:
         post_type = path_endpoint
     elif path_endpoint == self._api.POST_TYPE_PHOTO:
         post_type = path_endpoint
     elif path_endpoint == self._api.POST_TYPE_CHAT:
         post_type = path_endpoint
     else:
         post_type=None
     return self._api.get_posts(self._api.blog_hostname
         ,post_type=post_type,reblog_info=api_parameters['reblog_info'],
         notes_info=api_parameters['notes_info'],post_filter=api_parameters['filter'],offset=self.TOTAL,limit=20)
Example #7
0
 def __init__(self):
     self.model_factory = ModelFactory
     self.json_lib = Utils.import_simplejson()