[civitai] ensure 'file' & 'post' data has a 'date' value (#7548)
https://github.com/mikf/gallery-dl/issues/7548#issuecomment-3091492518
This commit is contained in:
@@ -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",
|
||||
|
||||
@@ -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",
|
||||
},
|
||||
},
|
||||
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user