Skip to content

Commit 7c8fbb6

Browse files
authored
[tiktok] do not exit early when rolling back cursor (#8968)
* [tiktok] do not exit account extraction early when we need to manually roll back the cursor * [tiktok] fix rehydration data error string formatting
1 parent a7cc447 commit 7c8fbb6

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

gallery_dl/extractor/tiktok.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ def _extract_rehydration_data_user(self, profile_url, additional_keys=()):
223223
data = data["webapp.user-detail"]
224224
if not self._check_status_code(data, profile_url, "profile"):
225225
raise exception.ExtractionError(
226-
"%s: could not extract rehydration data", profile_url)
226+
f"{profile_url}: could not extract rehydration data")
227227
try:
228228
for key in additional_keys:
229229
data = data[key]
@@ -1048,8 +1048,10 @@ def execute(self, extractor, url, query_parameters):
10481048
cursor_type = self.cursor_type(query_parameters)
10491049
cursor = cursor_type() if cursor_type else None
10501050
for page in itertools.count(start=1):
1051-
extractor.log.info("%s: retrieving %s page %d", url, self.endpoint,
1052-
page)
1051+
item_count = len(self.items)
1052+
extractor.log.info("%s: retrieving %s page %d (%d item%s)", url,
1053+
self.endpoint, page, item_count,
1054+
"" if item_count == 1 else "s")
10531055
tries = 0
10541056
while True:
10551057
try:
@@ -1268,7 +1270,8 @@ def __init__(self, endpoint, type_of_items, range_predicate):
12681270

12691271
def extract_items(self, data):
12701272
if "itemList" not in data:
1271-
self.exit_early_due_to_no_items = True
1273+
if not data.get("hasMorePrevious", data.get("hasMore", False)):
1274+
self.exit_early_due_to_no_items = True
12721275
return {}
12731276
return {item["id"]: item for item in data["itemList"]}
12741277

0 commit comments

Comments
 (0)