Skip to content

Commit 6efc1c0

Browse files
committed
supported more parameters in InoreaderClient.__get_stream_contents
1 parent 349a1b2 commit 6efc1c0

File tree

1 file changed

+10
-21
lines changed

1 file changed

+10
-21
lines changed

inoreader/client.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -143,29 +143,18 @@ def get_subscription_list(self):
143143
for item in response["subscriptions"]:
144144
yield Subscription.from_json(item)
145145

146-
def get_stream_contents(self, stream_id, c="", limit=None):
147-
fetched_count = 0
148-
stop = False
149-
while not stop:
150-
articles, c = self.__get_stream_contents(stream_id, c)
151-
for a in articles:
152-
try:
153-
yield Article.from_json(a)
154-
fetched_count += 1
155-
except Exception as e:
156-
print(e)
157-
continue
158-
if limit and fetched_count >= limit:
159-
stop = True
160-
break
161-
if c is None:
162-
break
163-
164-
def __get_stream_contents(self, stream_id, continuation=""):
146+
def __get_stream_contents(
147+
self, stream_id=None, n=50, r=None, ot=None, xt=None, it=None, c=None
148+
):
149+
"""reference: https://www.inoreader.com/developers/stream-contents"""
165150
self.check_token()
166151

167-
url = urljoin(BASE_URL, self.STREAM_CONTENTS_PATH + quote_plus(stream_id))
168-
params = {"n": 50, "r": "", "c": continuation, "output": "json"} # default 20, max 1000
152+
url = urljoin(BASE_URL, self.STREAM_CONTENTS_PATH)
153+
if stream_id:
154+
url = urljoin(url, quote_plus(stream_id))
155+
156+
params = {"n": n, "r": r, "ot": ot, "xt": xt, "it": it, "c": c}
157+
params = {arg: val for arg, val in params.items() if val is not None}
169158
response = self.parse_response(self.session.post(url, params=params, proxies=self.proxies))
170159
if "continuation" in response:
171160
return response["items"], response["continuation"]

0 commit comments

Comments
 (0)