Created
May 12, 2017 16:09
-
-
Save Pawka/48b7ab32903f5bdf35be12357018e484 to your computer and use it in GitHub Desktop.
Kindervibe photos downloader
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import argparse | |
import datetime | |
import json | |
import requests | |
if __name__ == "__main__": | |
parser = argparse.ArgumentParser() | |
parser.add_argument("--token", required=True, | |
help="Kindervibe auth token") | |
parser.add_argument("--pk", required=True, | |
help="Child primary key on Kindervibe") | |
parser.add_argument("--from", help="Fetch photos from the date") | |
parser.add_argument("--to", default=str(datetime.date.today()), | |
help="Fetch photos until the date. Default value is today.") | |
args = parser.parse_args() | |
url = ("http://kindervibe.com/api/photos/child/" | |
"?child_pk={!s}&date_to={!s}").format(args.pk, args.to) | |
if vars(args)['from']: | |
url += "&date_from={!s}".format(vars(args)['from']) | |
headers = { | |
'User-Agent': 'okhttp/2.7.0', | |
'Authorization': 'Token ' + args.token, | |
} | |
u = url | |
while True: | |
r = requests.get(u, headers=headers) | |
data = r.json() | |
print json.dumps(data, indent=2) | |
if not data.get('next', None): | |
break | |
u = data.get('next') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sveikas, gal gali pakomentuoti, kaip gauti "Kindervibe auth token" ir "Child primary key"? Thnx :)
Eddited:
Radau pats: https://kindervibe.com/api/docs 👍