diff options
| author | 2025-03-15 18:05:22 -0400 | |
|---|---|---|
| committer | 2025-03-15 18:05:22 -0400 | |
| commit | 4d0259149eb03b21716dbde6174f36d65c57c66c (patch) | |
| tree | 1e314b7849c4be1683809426d563a69a8131c13d /gallery_dl/extractor/tiktok.py | |
| parent | d178d764c9cc19aef1a5cf012e3ca4c3b957879f (diff) | |
| parent | 8026a3c45446030d7af524bfc487d3462c8114ef (diff) | |
Update upstream source from tag 'upstream/1.29.2'
Update to upstream version '1.29.2'
with Debian dir a3b673d57d2a397548e1a0eb8d7a7401e09e1234
Diffstat (limited to 'gallery_dl/extractor/tiktok.py')
| -rw-r--r-- | gallery_dl/extractor/tiktok.py | 27 |
1 files changed, 25 insertions, 2 deletions
diff --git a/gallery_dl/extractor/tiktok.py b/gallery_dl/extractor/tiktok.py index 203b1ac..30f310d 100644 --- a/gallery_dl/extractor/tiktok.py +++ b/gallery_dl/extractor/tiktok.py @@ -17,7 +17,7 @@ class TiktokExtractor(Extractor): category = "tiktok" directory_fmt = ("{category}", "{user}") filename_fmt = ( - "{id}{num:?_//>02} {title[b:150]}{img_id:? [/]/}.{extension}") + "{id}{num:?_//>02} {title[b:150]}{img_id|audio_id:? [/]/}.{extension}") archive_fmt = "{id}_{num}_{img_id}" root = "https://www.tiktok.com" cookies_domain = ".tiktok.com" @@ -83,7 +83,11 @@ class TiktokExtractor(Extractor): yield Message.Url, url, post if self.audio and "music" in post: - ytdl_media = "audio" + if self.audio == "ytdl": + ytdl_media = "audio" + else: + url = self._extract_audio(post) + yield Message.Url, url, post elif self.video and "video" in post: ytdl_media = "video" @@ -146,6 +150,25 @@ class TiktokExtractor(Extractor): 'type="application/json">', '</script>') return util.json_loads(data)["__DEFAULT_SCOPE__"] + def _extract_audio(self, post): + audio = post["music"] + url = audio["playUrl"] + text.nameext_from_url(url, post) + post.update({ + "type" : "audio", + "image" : None, + "title" : post["desc"] or "TikTok audio #{}".format(post["id"]), + "duration" : audio.get("duration"), + "num" : 0, + "img_id" : "", + "audio_id" : audio.get("id"), + "width" : 0, + "height" : 0, + }) + if not post["extension"]: + post["extension"] = "mp3" + return url + def _check_status_code(self, detail, url): status = detail.get("statusCode") if not status: |
