Skip to content

Commit 1ff58ac

Browse files
authored
Merge pull request #23 from cczhong11/master
Add error handle for get_stream_contents
2 parents 0bff781 + 98a28ed commit 1ff58ac

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

inoreader/client.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,13 +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:
150-
yield Article.from_json(a)
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
151161
if c is None:
152162
break
163+
153164

154165
def __get_stream_contents(self, stream_id, continuation=''):
155166
self.check_token()
@@ -216,6 +227,7 @@ def fetch_articles(self, folder=None, tags=None, unread=True, starred=False, lim
216227
break
217228

218229
continuation = response.get('continuation')
230+
219231

220232
def fetch_unread(self, folder=None, tags=None, limit=None):
221233
for article in self.fetch_articles(folder=folder, tags=tags, unread=True):

inoreader/utils.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,10 @@ def extract_text(html_content):
3636
continue
3737

3838
link.text = '[%s](%s)' % (text, url)
39-
40-
return content.text_content().replace('\xa0', '').strip()
39+
try:
40+
return content.text_content().replace("\xa0", "").strip()
41+
except:
42+
return ""
4143

4244

4345
def download_image(url, path, filename, proxies=None):

0 commit comments

Comments
 (0)