diff --git a/gallery_dl/extractor/civitai.py b/gallery_dl/extractor/civitai.py index a0038ac6..813915e0 100644 --- a/gallery_dl/extractor/civitai.py +++ b/gallery_dl/extractor/civitai.py @@ -181,6 +181,9 @@ class CivitaiExtractor(Extractor): self._image_ext) if "id" not in file and data["filename"].isdecimal(): file["id"] = text.parse_int(data["filename"]) + if "date" not in file: + file["date"] = text.parse_datetime( + file["createdAt"], "%Y-%m-%dT%H:%M:%S.%fZ") if self._meta_generation: file["generation"] = self._extract_meta_generation(file) yield data @@ -214,7 +217,10 @@ class CivitaiExtractor(Extractor): def _extract_meta_post(self, image): try: - return self.api.post(image["postId"]) + post = self.api.post(image["postId"]) + post["date"] = text.parse_datetime( + post["publishedAt"], "%Y-%m-%dT%H:%M:%S.%fZ") + return post except Exception as exc: return self.log.debug("", exc_info=exc) @@ -635,7 +641,7 @@ class CivitaiTrpcAPI(): self.root = extractor.root + "/api/trpc/" self.headers = { "content-type" : "application/json", - "x-client-version": "5.0.882", + "x-client-version": "5.0.920", "x-client-date" : "", "x-client" : "web", "x-fingerprint" : "undefined", diff --git a/test/results/civitai.py b/test/results/civitai.py index c6083c91..cd898f0a 100644 --- a/test/results/civitai.py +++ b/test/results/civitai.py @@ -225,6 +225,7 @@ __tests__ = ( "post": { "availability": "Public", "collectionId": None, + "date" : "dt:2024-12-10 19:20:51", "detail" : None, "id" : 10151863, "modelVersion": None, @@ -336,6 +337,7 @@ __tests__ = ( }, "file": { "id" : {30748752, 30748747, 30748733}, + "date": "dt:2024-09-22 12:54:15", "uuid": {"6220fa0f-9037-4b1d-bfbd-a740a06eeb7c", "cd1edb7f-7b50-4da5-bf23-d38f24d8aef0", "cfd5b231-accd-49bd-8bde-370880f63aa6"}, @@ -436,6 +438,15 @@ __tests__ = ( "#pattern": r"https://image\.civitai\.com/xG1nkqKTMzGDvpLrqFT7WA/[0-9a-f-]+/original=true/\S+\.(jpe?g|png)", "#range" : "1-50", "#count" : 50, + + "file": { + "id" : int, + "date": "type:datetime", + }, + "post": { + "id" : int, + "date": "type:datetime", + }, }, {