Skip to content

Commit 98a28ed

Browse files
committed
limit the contents to fetch
1 parent 9c4e6e6 commit 98a28ed

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

inoreader/client.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,17 +143,24 @@ 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=''):
147-
while True:
146+
def get_stream_contents(self, stream_id, c='', limit=None):
147+
fetched_count = 0
148+
stop = False
149+
while not stop:
148150
articles, c = self.__get_stream_contents(stream_id, c)
149151
for a in articles:
150152
try:
151153
yield Article.from_json(a)
154+
fetched_count+=1
152155
except Exception as e:
153156
print(e)
154157
continue
158+
if limit and fetched_count >= limit:
159+
stop = True
160+
break
155161
if c is None:
156162
break
163+
157164

158165
def __get_stream_contents(self, stream_id, continuation=''):
159166
self.check_token()

0 commit comments

Comments
 (0)