500px to oauth to get avoid hardcoded ids; deviantart fixes, but it still needs userid
This commit is contained in:
parent
06a60e99e7
commit
54031be969
2 changed files with 28 additions and 3 deletions
8
oauth.py
8
oauth.py
|
@ -225,8 +225,13 @@ class Oauth1Flow(object):
|
||||||
return client.get(url, params=params)
|
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):
|
class FlickrOauth(Oauth1Flow):
|
||||||
|
@ -237,6 +242,7 @@ class FlickrOauth(Oauth1Flow):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(FlickrOauth, self).__init__('flickr')
|
super(FlickrOauth, self).__init__('flickr')
|
||||||
|
|
||||||
|
|
||||||
class TumblrOauth(Oauth1Flow):
|
class TumblrOauth(Oauth1Flow):
|
||||||
request_token_url = 'https://www.tumblr.com/oauth/request_token'
|
request_token_url = 'https://www.tumblr.com/oauth/request_token'
|
||||||
access_token_url = 'https://www.tumblr.com/oauth/access_token'
|
access_token_url = 'https://www.tumblr.com/oauth/access_token'
|
||||||
|
|
23
pesos.py
23
pesos.py
|
@ -363,12 +363,15 @@ class Favs(object):
|
||||||
|
|
||||||
|
|
||||||
class FlickrFavs(Favs):
|
class FlickrFavs(Favs):
|
||||||
|
url = 'https://api.flickr.com/services/rest/'
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(FlickrFavs, self).__init__('flickr')
|
super(FlickrFavs, self).__init__('flickr')
|
||||||
|
self.get_uid()
|
||||||
self.params = {
|
self.params = {
|
||||||
'method': 'flickr.favorites.getList',
|
'method': 'flickr.favorites.getList',
|
||||||
'api_key': shared.config.get('flickr', 'api_key'),
|
'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',
|
'extras': 'description,geo,tags,url_z,url_b,owner_name,date_upload',
|
||||||
'per_page': 500, # maximim
|
'per_page': 500, # maximim
|
||||||
'format': 'json',
|
'format': 'json',
|
||||||
|
@ -376,6 +379,22 @@ class FlickrFavs(Favs):
|
||||||
'min_fave_date': self.lastpulled
|
'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):
|
def getpaged(self, offset):
|
||||||
logging.info('requesting page #%d of paginated results', offset)
|
logging.info('requesting page #%d of paginated results', offset)
|
||||||
self.params.update({
|
self.params.update({
|
||||||
|
@ -619,7 +638,7 @@ class DAFavs(Favs):
|
||||||
paged = self.getpaged(offset)
|
paged = self.getpaged(offset)
|
||||||
new = paged.get('results', [])
|
new = paged.get('results', [])
|
||||||
if not len(new):
|
if not len(new):
|
||||||
logging.error('empty results from deviantART, breaking loop')
|
#logging.error('empty results from deviantART, breaking loop')
|
||||||
break
|
break
|
||||||
favs = favs + new
|
favs = favs + new
|
||||||
has_more = self.has_more(paged.get('has_more'))
|
has_more = self.has_more(paged.get('has_more'))
|
||||||
|
|
Loading…
Reference in a new issue