You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

25 lines
1.1 KiB

import requests
class Fetcher:
def __init__(self, URL, token):
self.URL = URL
self.token = token
self.headers = {"Authorization": "GoogleLogin auth="+token}
self.getUnreadCounts()
self.getSubscriptions()
def getUnreadCounts(self):
response = requests.get(self.URL+"/reader/api/0/unread-count?output=json", headers=self.headers)
result = dict([(item["id"], (item["count"], item["newestItemTimestampUsec"])) for item in response.json()["unreadcounts"]])
self.unreadCounts = result
self.categories = [{"id": item, "name": item[13:], "count": self.unreadCounts[item][0]}
for item in self.unreadCounts.keys() if item[0:13] == "user/-/label/"]
def getSubscriptions(self):
response = requests.get(self.URL+"/reader/api/0/subscription/list?output=json", headers=self.headers)
self.feeds = response.json()["subscriptions"]
def feedsFromCategory(self, category):
return [item for item in self.feeds if item["categories"][0]["id"] == category]