re-adding since epoch to most silos, raising offset for deviantart, moving Flickr extra photo info into a property to avoid premature fetching
This commit is contained in:
parent
5547d2944e
commit
e121a01bc2
4 changed files with 40 additions and 16 deletions
|
@ -30,7 +30,8 @@ class DAFavs(common.Favs):
|
||||||
try:
|
try:
|
||||||
following = self.client.get_friends(
|
following = self.client.get_friends(
|
||||||
username=keys.deviantart.get('username'),
|
username=keys.deviantart.get('username'),
|
||||||
offset=offset
|
offset=offset,
|
||||||
|
limit=24
|
||||||
)
|
)
|
||||||
offset = following.get('next_offset')
|
offset = following.get('next_offset')
|
||||||
for follow in following.get('results'):
|
for follow in following.get('results'):
|
||||||
|
@ -53,7 +54,8 @@ class DAFavs(common.Favs):
|
||||||
try:
|
try:
|
||||||
folders = self.client.get_collections(
|
folders = self.client.get_collections(
|
||||||
username=keys.deviantart.get('username'),
|
username=keys.deviantart.get('username'),
|
||||||
offset=offset
|
offset=offset,
|
||||||
|
limit=24
|
||||||
)
|
)
|
||||||
offset = folders.get('next_offset')
|
offset = folders.get('next_offset')
|
||||||
for r in folders.get('results'):
|
for r in folders.get('results'):
|
||||||
|
@ -73,6 +75,8 @@ class DAFavs(common.Favs):
|
||||||
self.favfolder,
|
self.favfolder,
|
||||||
username=keys.deviantart.get('username'),
|
username=keys.deviantart.get('username'),
|
||||||
offset=offset,
|
offset=offset,
|
||||||
|
limit=24,
|
||||||
|
#mature_content=True
|
||||||
)
|
)
|
||||||
for r in fetched.get('results'):
|
for r in fetched.get('results'):
|
||||||
fav = DAFav(r)
|
fav = DAFav(r)
|
||||||
|
|
15
Flickr.py
15
Flickr.py
|
@ -50,7 +50,8 @@ class FlickrFavs(common.Favs):
|
||||||
logging.info('fetching for Flickr: page %d' % page)
|
logging.info('fetching for Flickr: page %d' % page)
|
||||||
fetched = self.user.getFavorites(
|
fetched = self.user.getFavorites(
|
||||||
user_id=self.user.id,
|
user_id=self.user.id,
|
||||||
page=page
|
page=page,
|
||||||
|
min_fave_date=self.since
|
||||||
)
|
)
|
||||||
for p in fetched:
|
for p in fetched:
|
||||||
photo = FlickrFav(p)
|
photo = FlickrFav(p)
|
||||||
|
@ -62,12 +63,20 @@ class FlickrFavs(common.Favs):
|
||||||
class FlickrFav(common.ImgFav):
|
class FlickrFav(common.ImgFav):
|
||||||
def __init__(self, flickrphoto):
|
def __init__(self, flickrphoto):
|
||||||
self.flickrphoto = flickrphoto
|
self.flickrphoto = flickrphoto
|
||||||
self.info = flickrphoto.getInfo()
|
|
||||||
self.owner = self.info.get('owner')
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "fav-of %s" % (self.url)
|
return "fav-of %s" % (self.url)
|
||||||
|
|
||||||
|
@property
|
||||||
|
@common.cached_property
|
||||||
|
def owner(self):
|
||||||
|
return self.info.get('owner')
|
||||||
|
|
||||||
|
@property
|
||||||
|
@common.cached_property
|
||||||
|
def info(self):
|
||||||
|
return flickrphoto.getInfo()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def author(self):
|
def author(self):
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -43,7 +43,7 @@ class TumblrFavs(common.Favs):
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
has_more = True
|
has_more = True
|
||||||
after = 0
|
after = self.since
|
||||||
while has_more:
|
while has_more:
|
||||||
logging.info('fetching for Tumblr: after %d' % after)
|
logging.info('fetching for Tumblr: after %d' % after)
|
||||||
fetched = self.client.likes(after=after)
|
fetched = self.client.likes(after=after)
|
||||||
|
|
31
common.py
31
common.py
|
@ -21,6 +21,22 @@ def slugfname(url):
|
||||||
lower=True
|
lower=True
|
||||||
)[:200]
|
)[:200]
|
||||||
|
|
||||||
|
class cached_property(object):
|
||||||
|
""" extermely simple cached_property decorator:
|
||||||
|
whenever something is called as @cached_property, on first run, the
|
||||||
|
result is calculated, then the class method is overwritten to be
|
||||||
|
a property, contaning the result from the method
|
||||||
|
"""
|
||||||
|
def __init__(self, method, name=None):
|
||||||
|
self.method = method
|
||||||
|
self.name = name or method.__name__
|
||||||
|
def __get__(self, inst, cls):
|
||||||
|
if inst is None:
|
||||||
|
return self
|
||||||
|
result = self.method(inst)
|
||||||
|
setattr(inst, self.name, result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
|
||||||
class Follows(object):
|
class Follows(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
@ -66,21 +82,16 @@ class Favs(object):
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def since(self):
|
def since(self):
|
||||||
mtime = 0
|
|
||||||
d = os.path.join(
|
d = os.path.join(
|
||||||
settings.paths.get('archive'),
|
settings.paths.get('archive'),
|
||||||
'favorite',
|
'favorite',
|
||||||
"%s-*" % self.silo
|
"%s*" % self.silo
|
||||||
)
|
)
|
||||||
files = glob.glob(d)
|
files = glob.glob(d)
|
||||||
|
if len(files):
|
||||||
if (len(files)):
|
mtime = max([int(os.path.getmtime(f)) for f in files])
|
||||||
for f in files:
|
else:
|
||||||
ftime = int(os.path.getmtime(f))
|
mtime = 0
|
||||||
if ftime > mtime:
|
|
||||||
mtime = ftime
|
|
||||||
# TODO why is this here?
|
|
||||||
mtime = mtime + 1
|
|
||||||
return mtime
|
return mtime
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue