Created
October 12, 2011 18:43
-
-
Save petermanser/1282135 to your computer and use it in GitHub Desktop.
Import Dribbble likes to Zootool.
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
# Modify this configs with your credentials. See requirements.txt for required packages | |
DRIBBBLE_USER = 'DRIBBBLE_USERNAME' | |
ZT_USER = 'ZOOTOOL_USERNAME' | |
ZT_PASS = 'ZOOTOOL_PASSWORD' | |
ZT_TAGS = 'dribbble' | |
# Zootool API key | |
ZT_API_KEY = 'cb866ea010a668687ff92cdb4733f161' | |
from pyzootool import controller | |
import requests | |
try: | |
import json | |
except ImportError: | |
import simplejson as json | |
zoocontrol = controller.ZooControl(apikey=ZT_API_KEY, username=ZT_USER, password=ZT_PASS) | |
page = 1 | |
total_pages = 2 | |
count = 0 | |
while page <= total_pages: | |
r = requests.get('http://api.dribbble.com/players/%s/shots/likes' % DRIBBBLE_USER, params={'page':page, 'per_page':30}) | |
if r.status_code == 200: | |
content = json.loads(r.content) | |
total_pages = content['pages'] | |
page += 1 | |
for s in content['shots']: | |
count += 1 | |
print '%u: %s - %s' % (count, s['title'], s['url']) | |
try: | |
i = zoocontrol.item.add_item(url=s['url'], title=s['title'], tags=ZT_TAGS) | |
except Exception: | |
print 'Wrong zootool username/password, probably. :(' | |
exit(1) | |
else: | |
print 'Something with Dribbble API went wrong. Correct username? (%s)' % DRIBBBLE_USER | |
exit(1) | |
print '%u items imported from Dribbble' % count |
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
-e [email protected]:petermanser/pyzootool.git#egg=pyzootool-0.2-py2.7 | |
httplib2==0.7.1 | |
requests==0.6.2 | |
wsgiref==0.1.2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment