Skip to content

Commit

Permalink
[twitter] add 'warnings' option (#2258)
Browse files Browse the repository at this point in the history
disable reporting any non-fatal errors by default
  • Loading branch information
mikf committed Feb 2, 2022
1 parent a5163e4 commit 492436f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2200,6 +2200,17 @@ Description
* ``false``: Skip video Tweets


extractor.twitter.warnings
--------------------------
Type
``bool``
Default
``false``
Description
Emit `logging messages <output.log_>`_
for non-fatal errors reported by Twitter's API.


extractor.unsplash.format
-------------------------
Type
Expand Down
6 changes: 4 additions & 2 deletions gallery_dl/extractor/twitter.py
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,8 @@ def __init__(self, extractor):
"__fs_interactive_text": False,
"__fs_dont_mention_me_view_api_enabled": False,
}

self._log_warnings = extractor.config("warnings")
self._json_dumps = json.JSONEncoder(separators=(",", ":")).encode
self._user = None

Expand Down Expand Up @@ -940,7 +942,7 @@ def _guest_token(self):
endpoint = "/1.1/guest/activate.json"
return str(self._call(endpoint, None, root, "POST")["guest_token"])

def _call(self, endpoint, params, root=None, method="GET", warning=True):
def _call(self, endpoint, params, root=None, method="GET"):
if root is None:
root = self.root

Expand All @@ -965,7 +967,7 @@ def _call(self, endpoint, params, root=None, method="GET", warning=True):

if response.status_code < 400:
# success
if errors and warning:
if errors and self._log_warnings:
self.extractor.log.warning(errors)
return data

Expand Down

0 comments on commit 492436f

Please sign in to comment.