[tiktok] fix "KeyError: 'author'" (#8189)

This commit is contained in:
Mike Fährmann
2025-09-10 09:14:55 +02:00
parent 8617c08c6c
commit eaf0591eea
2 changed files with 8 additions and 2 deletions

View File

@@ -42,8 +42,7 @@ class TiktokExtractor(Extractor):
continue
post = video_detail["itemInfo"]["itemStruct"]
author = post["author"]
post["user"] = author["uniqueId"]
post["user"] = (a := post.get("author")) and a["uniqueId"] or ""
post["date"] = text.parse_timestamp(post["createTime"])
original_title = title = post["desc"]

View File

@@ -181,6 +181,13 @@ __tests__ = (
"#class" : tiktok.TiktokPostExtractor,
},
{
"#url" : "https://www.tiktok.com/@veronicaperasso_1/video/7212008840433274118",
"#comment" : "no 'author' (#8189)",
"#class" : tiktok.TiktokPostExtractor,
"#results" : "ytdl:https://www.tiktok.com/@veronicaperasso_1/video/7212008840433274118",
},
{
"#url" : "https://vm.tiktok.com/ZGdh4WUhr/",
"#comment" : "vm.tiktok.com link: many photos",