Permalink
Browse files

have something functional now. item fetching is wrapped

  • Loading branch information...
0 parents commit e636d2fa7f117d7c6f63ea63af6990139554e1fc @f4nt committed Apr 16, 2010
No changes.
0 README
No changes.
@@ -0,0 +1,2 @@
+## Globals
+ROOT_URL = "http://zootool.com"
Binary file not shown.
@@ -0,0 +1,3 @@
+
+class ZooAuth():
+ pass
Binary file not shown.
@@ -0,0 +1,16 @@
+"""
+Central point for pyzootool's control
+"""
+import httplib2
+from pyzootool import auth, items, users
+
+class ZooControl():
+
+ def __init__(self, apikey, username=None, password=None):
+ self.apikey = apikey
+ self.http = httplib2.Http()
+ if username and password:
+ ## TODO: Implement this
+ self.auth = auth.ZooAuth(self.api_key, username, password)
+ self.item = items.ZooItem(self.apikey, self.http)
+ #self.user = users.ZooUser(self.apikey, self.http)
Binary file not shown.
@@ -0,0 +1,51 @@
+import json
+import urllib
+
+from pyzootool import ROOT_URL
+
+class ZooResult():
+
+ def __init__(self, json_data):
+ self.parse_results(json_data)
+
+ def parse_results(self, json_data):
+ print json_data
+ self.uid = json_data['uid']
+ self.title = json_data['title']
+ self.url = json_data['url']
+ self.type = json_data['type']
+ self.views = json_data['views']
+ self.likes = json_data['likes']
+ self.permalink = json_data['permalink']
+ self.tinyurl = json_data['tinyurl']
+ self.thumbnail = json_data['thumbnail']
+
+class ZooItem():
+
+ def __init__(self, apikey, http):
+ self.apikey = apikey
+ self.http = http
+
+
+ def get_item(self, item_id):
+ values = {'uid': item_id, 'apikey': self.apikey}
+ url = "%s/api/items/info/?%s" % (
+ ROOT_URL, urllib.urlencode(values)
+ )
+ resp, content = self.http.request(url)
+ json_data = json.loads(content)
+ result = ZooResult(item)
+ return zoo_results
+
+ def get_popular(self, pop_type):
+ values = {'type': pop_type, 'apikey': self.apikey }
+ url = "%s/api/items/popular/?%s" % (
+ ROOT_URL, urllib.urlencode(values)
+ )
+ resp, content = self.http.request(url)
+ json_data = json.loads(content)
+ zoo_results = []
+ for item in json_data:
+ result = ZooResult(item)
+ zoo_results.append(result)
+ return zoo_results
Binary file not shown.
No changes.
Binary file not shown.
No changes.

0 comments on commit e636d2f

Please sign in to comment.