Commits

Steve Losh committed 61d0ceb

Initial commit.

Comments (0)

Files changed (4)

+syntax: glob
+
+*.pyc
+.DS_Store
+tags
+.ropeproject
+*.swo
+*.swp
+*.log
+docs/_build

Empty file added.

+import urllib2
+
+try: import simplejson as json
+except ImportError: import json
+
+
+API_URL = 'http://api.dribbble.com/'
+
+
+def _api(url, id):
+    u = urllib2.urlopen(API_URL + url % id)
+    return json.loads(u.read())
+
+class Dribbble(object):
+    def __init__(self):
+        pass
+
+    def player(self, username):
+        return Player(_api('players/%s/', username))
+
+    def shot(self, id):
+        return Shot(_api('shots/%d/', id))
+
+
+
+class Shot(object):
+    def __init__(self, data):
+        for k, v in data.items():
+            if k != u'player':
+                setattr(self, k, v)
+        self.player = Player(data[u'player'])
+
+class Player(object):
+    def __init__(self, data, username=None):
+        for k, v in data.items():
+            setattr(self, k, v)
+
+        # Srsly, Dribbble API?
+        self.username = self.url.strip('/').rsplit('/', 1)[-1]
+
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.