Skip to content

Commit

Permalink
TikTok: Export post's creation date in JSON (ISO 8601)
Browse files Browse the repository at this point in the history
  • Loading branch information
CasualYT31 committed Jan 28, 2025
1 parent c9f409a commit d835e9c
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions gallery_dl/extractor/tiktok.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from .common import Extractor, Message
from .. import exception, text, util, ytdl
from re import compile, escape, IGNORECASE
from datetime import datetime

BASE_PATTERN = r"(?:https?://)?(?:www\.)?tiktok(?:v?)\.com"
USER_PATTERN = BASE_PATTERN + r"/+@([\w.]{0,23}\w)?"
Expand Down Expand Up @@ -92,6 +93,9 @@ def items(self):
if len(original_title) == 0:
title = "TikTok photo #{}".format(id)
title = title[:150]
date = datetime.fromtimestamp(
int(post_info["createTime"])
).isoformat()
user = post_info["author"]["uniqueId"]
# It's probably obvious but I thought it was worth noting
# because I got stuck on this for a while: make sure to emit
Expand All @@ -117,6 +121,7 @@ def items(self):
name_and_ext = text.nameext_from_url(url)
yield Message.Url, url, {
"title" : title,
"date" : date,
"id" : id,
"index" : i + 1,
"img_id" : name_and_ext["filename"].split("~")[0],
Expand All @@ -135,6 +140,7 @@ def items(self):
"filename" : "",
"extension" : "",
"title" : title,
"date" : date,
"id" : id,
"index" : "",
"img_id" : ""
Expand Down

0 comments on commit d835e9c

Please sign in to comment.