Skip to content

Commit

Permalink
Merge pull request #23 from cczhong11/master
Browse files Browse the repository at this point in the history
Add error handle for get_stream_contents
  • Loading branch information
Linusp authored Dec 11, 2022
2 parents 0bff781 + 98a28ed commit 1ff58ac
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
18 changes: 15 additions & 3 deletions inoreader/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,24 @@ def get_subscription_list(self):
for item in response['subscriptions']:
yield Subscription.from_json(item)

def get_stream_contents(self, stream_id, c=''):
while True:
def get_stream_contents(self, stream_id, c='', limit=None):
fetched_count = 0
stop = False
while not stop:
articles, c = self.__get_stream_contents(stream_id, c)
for a in articles:
yield Article.from_json(a)
try:
yield Article.from_json(a)
fetched_count+=1
except Exception as e:
print(e)
continue
if limit and fetched_count >= limit:
stop = True
break
if c is None:
break


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

continuation = response.get('continuation')


def fetch_unread(self, folder=None, tags=None, limit=None):
for article in self.fetch_articles(folder=folder, tags=tags, unread=True):
Expand Down
6 changes: 4 additions & 2 deletions inoreader/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ def extract_text(html_content):
continue

link.text = '[%s](%s)' % (text, url)

return content.text_content().replace('\xa0', '').strip()
try:
return content.text_content().replace("\xa0", "").strip()
except:
return ""


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

0 comments on commit 1ff58ac

Please sign in to comment.