Commits

takanao ENDOH  committed 30290d3

Add GoogleReaderClient.search_ids

  • Participants
  • Parent commits 75ae7d7

Comments (0)

Files changed (1)

File src/mekk/greader/reader_client.py

 import re
 import json
 import time
+from datetime import datetime
 from lxml import etree, objectify
 
 import logging
 SUBSCRIPTION_EDIT_URL = READER_URL + '/api/0/subscription/edit'
 TAG_EDIT_URL = READER_URL + '/api/0/edit-tag'
 TAG_DISABLE_URL = READER_URL + '/api/0/disable-tag'
+SEARCH_ITEMS_IDS_URL = READER_URL + '/api/0/search/items/ids'
 IN_STATE_URL = READER_URL + '/atom/user/-/state/com.google/%s'
 GET_FEED_URL = READER_URL + '/atom/feed/'
 READING_TAG_URL = READER_URL + '/atom/%s'
         """
         return self._get_atom(IN_STATE_URL % state, **kwargs)
 
+    ############################################################
+    # Public API - item
+
+    def search_ids(self, query, format="obj"):
+        if format == 'obj':
+            output = "json"
+        else:
+            output = format
+        url = SEARCH_ITEMS_IDS_URL + "?"\
+              + urllib.urlencode({"q": query,
+                                  "num": "1000",
+                                  "output": output,
+                                  "ck": int(time.mktime(datetime.now().timetuple())),
+                                  "client": SOURCE,
+                                 })
+        if format == 'obj':
+            return json.loads(self._make_call(url))
+        else:
+            return self._make_call(url)
+
 
     ############################################################
     # Public API - subscription info