mirror of
https://github.com/instaloader/instaloader.git
synced 2024-09-17 11:02:23 +02:00
Do not repeat errors that were fixed by retrying
This commit is contained in:
parent
2dbd510486
commit
fbbbfdf53c
@ -387,9 +387,12 @@ class Instaloader:
|
|||||||
if not self.quiet:
|
if not self.quiet:
|
||||||
print(*msg, sep=sep, end=end, flush=flush)
|
print(*msg, sep=sep, end=end, flush=flush)
|
||||||
|
|
||||||
def error(self, msg):
|
def error(self, msg, repeat_at_end = True):
|
||||||
"""Log a non-fatal error message to stderr, which is repeated at program termination."""
|
"""Log a non-fatal error message to stderr, which is repeated at program termination.
|
||||||
|
|
||||||
|
:param repeat_at_end: Set to false if the message should be printed, but not repeated at program termination."""
|
||||||
print(msg, file=sys.stderr)
|
print(msg, file=sys.stderr)
|
||||||
|
if repeat_at_end:
|
||||||
self.error_log.append(msg)
|
self.error_log.append(msg)
|
||||||
|
|
||||||
@contextmanager
|
@contextmanager
|
||||||
@ -433,7 +436,7 @@ class Instaloader:
|
|||||||
if tries <= 1:
|
if tries <= 1:
|
||||||
raise ConnectionException(error_string)
|
raise ConnectionException(error_string)
|
||||||
else:
|
else:
|
||||||
self.error(error_string + " [retrying]")
|
self.error(error_string + " [retrying]", repeat_at_end=False)
|
||||||
self._sleep()
|
self._sleep()
|
||||||
self._get_and_write_raw(url, filename, tries - 1)
|
self._get_and_write_raw(url, filename, tries - 1)
|
||||||
|
|
||||||
@ -494,7 +497,7 @@ class Instaloader:
|
|||||||
error_string = "JSON Query to {}: {}".format(url, err)
|
error_string = "JSON Query to {}: {}".format(url, err)
|
||||||
if tries <= 1:
|
if tries <= 1:
|
||||||
raise ConnectionException(error_string)
|
raise ConnectionException(error_string)
|
||||||
self.error(error_string + " [retrying]")
|
self.error(error_string + " [retrying]", repeat_at_end=False)
|
||||||
if isinstance(err, TooManyRequests):
|
if isinstance(err, TooManyRequests):
|
||||||
text_for_429 = ("HTTP error code 429 was returned because too many queries occured in the last time. "
|
text_for_429 = ("HTTP error code 429 was returned because too many queries occured in the last time. "
|
||||||
"Please do not use Instagram in your browser or run multiple instances of Instaloader "
|
"Please do not use Instagram in your browser or run multiple instances of Instaloader "
|
||||||
@ -1249,7 +1252,7 @@ class Instaloader:
|
|||||||
followees = self.get_followees(pentry[1:])
|
followees = self.get_followees(pentry[1:])
|
||||||
targets.update([followee['username'] for followee in followees])
|
targets.update([followee['username'] for followee in followees])
|
||||||
else:
|
else:
|
||||||
print("--login=USERNAME required to download {}.".format(pentry), file=sys.stderr)
|
self.error("--login=USERNAME required to download {}.".format(pentry))
|
||||||
elif pentry == ":feed":
|
elif pentry == ":feed":
|
||||||
if username is not None:
|
if username is not None:
|
||||||
self._log("Retrieving pictures from your feed...")
|
self._log("Retrieving pictures from your feed...")
|
||||||
@ -1257,13 +1260,13 @@ class Instaloader:
|
|||||||
self.download_feed_posts(fast_update=fast_update, max_count=max_count,
|
self.download_feed_posts(fast_update=fast_update, max_count=max_count,
|
||||||
filter_func=filter_func)
|
filter_func=filter_func)
|
||||||
else:
|
else:
|
||||||
print("--login=USERNAME required to download {}.".format(pentry), file=sys.stderr)
|
self.error("--login=USERNAME required to download {}.".format(pentry))
|
||||||
elif pentry == ":stories":
|
elif pentry == ":stories":
|
||||||
if username is not None:
|
if username is not None:
|
||||||
with self._error_catcher():
|
with self._error_catcher():
|
||||||
self.download_stories(fast_update=fast_update)
|
self.download_stories(fast_update=fast_update)
|
||||||
else:
|
else:
|
||||||
print("--login=USERNAME required to download {}.".format(pentry), file=sys.stderr)
|
self.error("--login=USERNAME required to download {}.".format(pentry))
|
||||||
else:
|
else:
|
||||||
targets.add(pentry)
|
targets.add(pentry)
|
||||||
if len(targets) > 1:
|
if len(targets) > 1:
|
||||||
|
Loading…
Reference in New Issue
Block a user