all repos — nasg @ 54031be969322494ec12aa6e63e4b618f04da3a2

500px to oauth to get avoid hardcoded ids; deviantart fixes, but it still needs userid
Peter Molnar hello@petermolnar.eu
Thu, 06 Jul 2017 19:27:53 +0000
commit

54031be969322494ec12aa6e63e4b618f04da3a2

parent

06a60e99e75d171574663da98ef6fb31bf38862e

2 files changed, 28 insertions(+), 3 deletions(-)

jump to
M oauth.pyoauth.py

@@ -225,8 +225,13 @@ )

return client.get(url, params=params) +class FivehpxOauth(Oauth1Flow): + request_token_url = 'https://api.500px.com/v1/oauth/request_token' + access_token_url = 'https://api.500px.com/v1/oauth/access_token' + authorize_url = 'https://api.500px.com/v1/oauth/authorize' - + def __init__(self): + super(FivehpxOauth, self).__init__('500px') class FlickrOauth(Oauth1Flow):

@@ -236,6 +241,7 @@ authorize_url = 'https://www.flickr.com/services/oauth/authorize'

def __init__(self): super(FlickrOauth, self).__init__('flickr') + class TumblrOauth(Oauth1Flow): request_token_url = 'https://www.tumblr.com/oauth/request_token'
M pesos.pypesos.py

@@ -363,18 +363,37 @@ return mtime

class FlickrFavs(Favs): + url = 'https://api.flickr.com/services/rest/' + def __init__(self): super(FlickrFavs, self).__init__('flickr') + self.get_uid() self.params = { 'method': 'flickr.favorites.getList', 'api_key': shared.config.get('flickr', 'api_key'), - 'user_id': shared.config.get('flickr', 'user_id'), + 'user_id': self.uid, 'extras': 'description,geo,tags,url_z,url_b,owner_name,date_upload', 'per_page': 500, # maximim 'format': 'json', 'nojsoncallback': '1', 'min_fave_date': self.lastpulled } + + def get_uid(self): + params = { + 'method': 'flickr.people.findByUsername', + 'api_key': shared.config.get('flickr', 'api_key'), + 'format': 'json', + 'nojsoncallback': '1', + 'username': shared.config.get('flickr', 'username'), + } + r = requests.get( + self.url, + params=params + ) + parsed = json.loads(r.text) + self.uid = parsed.get('user', {}).get('id') + def getpaged(self, offset): logging.info('requesting page #%d of paginated results', offset)

@@ -619,7 +638,7 @@ logging.info('iterating over DA results with offset %d', offset)

paged = self.getpaged(offset) new = paged.get('results', []) if not len(new): - logging.error('empty results from deviantART, breaking loop') + #logging.error('empty results from deviantART, breaking loop') break favs = favs + new has_more = self.has_more(paged.get('has_more'))