diff --git a/base/api.py b/base/api.py index e5ada13..f9de217 100644 --- a/base/api.py +++ b/base/api.py @@ -308,19 +308,9 @@ def encode(s): request_url = '%s?%s' % (url, urlencode(query_params)) url_fetcher = self._authenticated_url_fetcher if authenticated \ else self._direct_url_fetcher - try: - response_text = url_fetcher.fetch( - request_url, - post_data=urlencode(post_params) if post_params else None) - except urllib2.HTTPError, e: - if e.code >= 400 and e.code < 500: - # Log 400s, since they're usually programmer error, and the response - # indicates how to fix it. - logging.error( - 'HTTP status %d when requesting %s. Error response body:\n%s', - e.code, request_url, e.read()) - raise - + response_text = url_fetcher.fetch( + request_url, + post_data=urlencode(post_params) if post_params else None) if self._cache: self._cache.set(cache_key, response_text) return response_text diff --git a/reader_archive/reader_archive.py b/reader_archive/reader_archive.py index f8d5a01..2f9f7eb 100644 --- a/reader_archive/reader_archive.py +++ b/reader_archive/reader_archive.py @@ -362,10 +362,18 @@ def work(self, stream_id): result = [] continuation_token = None while True: - item_refs, continuation_token = self._api.fetch_item_refs( - stream_id, - count=self._chunk_size, - continuation_token=continuation_token) + try: + item_refs, continuation_token = self._api.fetch_item_refs( + stream_id, + count=self._chunk_size, + continuation_token=continuation_token) + except urllib2.HTTPError, e: + if e.code == 400 and "Permission denied" in e.read(): + logging.warn(" Permission denied when getting items for the stream " + "%s, it's most likely private now.", stream_id) + return None + else: + raise result.extend(item_refs) if not continuation_token or (self._max_items_per_stream and len(result) >= self._max_items_per_stream): @@ -419,7 +427,8 @@ def fetch(hifi=True): 'high-fidelity turned off') return fetch(hifi=False) except: - logging.error(' Exception when fetching items', exc_info=True) + logging.error(' Exception when fetching items %s', + ",".join([i.compact_form() for i in item_ids]), exc_info=True) return None def _group_item_bodies(self, item_bodies):