1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-25 04:02:32 +01:00

[twitter] allow disabling 'cursor' output (#5990)

This commit is contained in:
Mike Fährmann 2024-08-17 10:24:37 +02:00
parent 78ae0ba9f7
commit c0668f5106
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 33 additions and 2 deletions

View File

@ -3985,6 +3985,26 @@ Description
* ``"cookies"``: Use token given by the ``ct0`` cookie if present.
extractor.twitter.cursor
------------------------
Type
* ``bool``
* ``string``
Default
``true``
Example
``"1/DAABCgABGVKi5lE___oKAAIYbfYNcxrQLggAAwAAAAIAAA"``
Description
Controls from which position to start the extraction process from.
* ``true``: Start from the beginning.
Log the most recent ``cursor`` value when interrupted before reaching the end.
* ``false``: Start from the beginning.
* any ``string``: Start from the position defined by this value.
Note: A ``cursor`` value from one timeline cannot be used with another.
extractor.twitter.expand
------------------------
Type

View File

@ -504,7 +504,11 @@ class TwitterExtractor(Extractor):
}
def _init_cursor(self):
return self.config("cursor") or None
cursor = self.config("cursor", True)
if not cursor:
self._update_cursor = util.identity
elif isinstance(cursor, str):
return cursor
def _update_cursor(self, cursor):
self.log.debug("Cursor: %s", cursor)
@ -590,9 +594,16 @@ class TwitterTimelineExtractor(TwitterExtractor):
return cursor
def tweets(self):
self._cursor = cursor = self.config("cursor") or None
reset = False
cursor = self.config("cursor", True)
if not cursor:
self._update_cursor = util.identity
elif isinstance(cursor, str):
self._cursor = cursor
else:
cursor = None
if cursor:
state = cursor.partition("/")[0]
state, _, tweet_id = state.partition("_")