Skip to content

Commit 9c4e6e6

Browse files
committed
add error handle for get_stream_contents
1 parent ca272f7 commit 9c4e6e6

File tree

1 file changed

+5
-45
lines changed

1 file changed

+5
-45
lines changed

inoreader/client.py

Lines changed: 5 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,11 @@ def get_stream_contents(self, stream_id, c=''):
147147
while True:
148148
articles, c = self.__get_stream_contents(stream_id, c)
149149
for a in articles:
150-
yield Article.from_json(a)
150+
try:
151+
yield Article.from_json(a)
152+
except Exception as e:
153+
print(e)
154+
continue
151155
if c is None:
152156
break
153157

@@ -217,50 +221,6 @@ def fetch_articles(self, folder=None, tags=None, unread=True, starred=False, lim
217221

218222
continuation = response.get('continuation')
219223

220-
def fetch_articles_by_tag(self, tag:str, limit=None):
221-
self.check_token()
222-
223-
url = urljoin(BASE_URL, self.STREAM_CONTENTS_PATH)
224-
225-
params = {'c': str(uuid4())}
226-
params['it'] = tag
227-
228-
fetched_count = 0
229-
response = self.parse_response(self.session.post(url, params=params, proxies=self.proxies))
230-
for data in response['items']:
231-
categories = set(
232-
[
233-
category.split('/')[-1]
234-
for category in data.get('categories', [])
235-
if category.find('label') > 0
236-
]
237-
)
238-
239-
yield Article.from_json(data)
240-
fetched_count += 1
241-
if limit and fetched_count >= limit:
242-
break
243-
244-
continuation = response.get('continuation')
245-
while continuation and (not limit or fetched_count < limit):
246-
params['c'] = continuation
247-
response = self.parse_response(
248-
self.session.post(url, params=params, proxies=self.proxies)
249-
)
250-
for data in response['items']:
251-
categories = set(
252-
[
253-
category.split('/')[-1]
254-
for category in data.get('categories', [])
255-
if category.find('label') > 0
256-
]
257-
)
258-
yield Article.from_json(data)
259-
fetched_count += 1
260-
if limit and fetched_count >= limit:
261-
break
262-
263-
continuation = response.get('continuation')
264224

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

0 commit comments

Comments
 (0)