[iwara] extract more metadata (#6582)

https://github.com/mikf/gallery-dl/issues/6582#issuecomment-3315927586

- description
- tags
- slug
- rating
- comments
- likes
- views
This commit is contained in:
Mike Fährmann
2025-09-21 16:43:04 +02:00
parent 997e7422ff
commit 830bb8f2ef
2 changed files with 115 additions and 65 deletions

View File

@@ -103,34 +103,37 @@ class IwaraExtractor(Extractor):
raise exception.AbortExtraction(f"Unsupported result type '{type}'")
def extract_media_info(self, item, key, include_file_info=True):
title = t.strip() if (t := item.get("title")) else ""
info = {
"id" : item["id"],
"slug" : item.get("slug"),
"rating" : item.get("rating"),
"likes" : item.get("numLikes"),
"views" : item.get("numViews"),
"comments": item.get("numComments"),
"tags" : [t["id"] for t in item.get("tags") or ()],
"title" : t.strip() if (t := item.get("title")) else "",
"description": t.strip() if (t := item.get("body")) else "",
}
if include_file_info:
file_info = item if key is None else item.get(key) or {}
filename, _, extension = file_info.get("name", "").rpartition(".")
return {
"id" : item["id"],
"file_id" : file_info.get("id"),
"title" : title,
"filename" : filename,
"extension": extension,
"date" : text.parse_datetime(
file_info.get("createdAt"), "%Y-%m-%dT%H:%M:%S.%fZ"),
"date_updated": text.parse_datetime(
file_info.get("updatedAt"), "%Y-%m-%dT%H:%M:%S.%fZ"),
"mime" : file_info.get("mime"),
"size" : file_info.get("size"),
"width" : file_info.get("width"),
"height" : file_info.get("height"),
"duration" : file_info.get("duration"),
"type" : file_info.get("type"),
}
else:
return {
"id" : item["id"],
"title": title,
}
info["file_id"] = file_info.get("id")
info["filename"] = filename
info["extension"] = extension
info["date"] = text.parse_datetime(
file_info.get("createdAt"), "%Y-%m-%dT%H:%M:%S.%fZ")
info["date_updated"] = text.parse_datetime(
file_info.get("updatedAt"), "%Y-%m-%dT%H:%M:%S.%fZ")
info["mime"] = file_info.get("mime")
info["size"] = file_info.get("size")
info["width"] = file_info.get("width")
info["height"] = file_info.get("height")
info["duration"] = file_info.get("duration")
info["type"] = file_info.get("type")
return info
def extract_user_info(self, profile):
user = profile.get("user") or {}

View File

@@ -189,55 +189,102 @@ __tests__ = (
},
{
"#url" : "https://www.iwara.tv/video/6QvQvzZnELJ9vv/bluearchive-rio",
"#category" : ("", "iwara", "video"),
"#class" : iwara.IwaraVideoExtractor,
"#pattern" : r"https://\w+.iwara.tv/download\?filename=7ba6e734-b9df-4588-88fc-4eef2bbf5c56_Source.mp4&path=2025%2F07%2F05&expires=\d+&hash=[0-9a-f]{64}",
"#count" : 1,
"#url" : "https://www.iwara.tv/video/6QvQvzZnELJ9vv/bluearchive-rio",
"#category" : ("", "iwara", "video"),
"#class" : iwara.IwaraVideoExtractor,
"#pattern" : r"https://\w+.iwara.tv/download\?filename=7ba6e734-b9df-4588-88fc-4eef2bbf5c56_Source.mp4&path=2025%2F07%2F05&expires=\d+&hash=[0-9a-f]{64}",
"#count" : 1,
"user": {
"id" : "b3f86af1-874c-41f1-b62e-4e4b736ad3a4",
"name": "croove",
"nick": "crooveNSFW",
"comments" : range(100, 200),
"count" : 1,
"date" : "dt:2025-07-05 06:49:56",
"date_updated": "dt:2025-07-05 06:50:14",
"duration" : 107,
"extension" : "mp4",
"file_id" : "7ba6e734-b9df-4588-88fc-4eef2bbf5c56",
"filename" : "7ba6e734-b9df-4588-88fc-4eef2bbf5c56",
"height" : None,
"id" : "6QvQvzZnELJ9vv",
"likes" : range(8_000, 15_000),
"mime" : "video/mp4",
"num" : 1,
"rating" : "ecchi",
"size" : 86328642,
"slug" : "bluearchive-rio",
"title" : "[BlueArchive / ブルアカ] Rio",
"type" : "video",
"views" : range(200_000, 500_000),
"width" : None,
"description" : """\
You can find FHD(1080p) and UHD(2160p) videos on my patreon page, so please check that out if you are interested.
Patreon : https://www.patreon.com/croove
Twitter : https://x.com/croove_nsfw\
""",
"tags" : [
"blender",
"blue_archive",
"tsukatsuki_rio",
],
"user" : {
"date" : "dt:2022-04-01 01:55:59",
"id" : "b3f86af1-874c-41f1-b62e-4e4b736ad3a4",
"name" : "croove",
"nick" : "crooveNSFW",
"premium" : False,
"role" : "user",
"status" : "active",
"description": """\
You can find FHD(1080p) and UHD(2160p) videos on my patreon page, so please check that out if you are interested.
Patreon : https://www.patreon.com/croove
Twitter : https://x.com/croove_nsfw\
""",
},
"id" : "6QvQvzZnELJ9vv",
"title" : "[BlueArchive / ブルアカ] Rio",
"file_id" : "7ba6e734-b9df-4588-88fc-4eef2bbf5c56",
"filename" : "7ba6e734-b9df-4588-88fc-4eef2bbf5c56",
"extension" : "mp4",
"mime" : "video/mp4",
"size" : 86328642,
"width" : None,
"height" : None,
"duration" : 107,
"type" : "video",
"date" : "dt:2025-07-05 06:49:56",
"date_updated" : "dt:2025-07-05 06:50:14",
},
{
"#url" : "https://www.iwara.tv/image/5m3gLfcei6BQsL/sparkle",
"#category" : ("", "iwara", "image"),
"#class" : iwara.IwaraImageExtractor,
"#pattern" : r"https://i.iwara.tv/image/original/[\w-]{36}/[\w-]{36}\.png",
"#count" : 13,
"#url" : "https://www.iwara.tv/image/5m3gLfcei6BQsL/sparkle",
"#category" : ("", "iwara", "image"),
"#class" : iwara.IwaraImageExtractor,
"#pattern" : r"https://i.iwara.tv/image/original/[\w-]{36}/[\w-]{36}\.png",
"#count" : 13,
"user": {
"id" : "771d2b29-5935-43d7-85e1-30abbf47ccad",
"name": "zcccz",
"nick": "zcccz",
"comments" : int,
"count" : 13,
"date" : "type:datetime",
"date_updated": "type:datetime",
"description" : "card from OoOoO & Rat",
"duration" : None,
"extension" : "png",
"file_id" : "iso:uuid",
"filename" : "iso:uuid",
"height" : int,
"width" : int,
"size" : int,
"id" : "5m3gLfcei6BQsL",
"likes" : int,
"mime" : "image/png",
"num" : range(1, 13),
"rating" : "ecchi",
"slug" : "sparkle",
"title" : "Sparkle",
"type" : "image",
"views" : int,
"tags" : [
"koikatsu",
"sparkle",
],
"user" : {
"date" : "dt:2025-07-04 19:17:20",
"description": "card from OoOoO & Rat",
"id" : "771d2b29-5935-43d7-85e1-30abbf47ccad",
"name" : "zcccz",
"nick" : "zcccz",
"premium" : False,
"role" : "limited",
"status" : "active",
},
"id" : "5m3gLfcei6BQsL",
"title" : "Sparkle",
"extension" : "png",
"mime" : "image/png",
"type" : "image",
"width" : int,
"height" : int,
"count" : 13,
"num" : range(1, 13),
"date" : "type:datetime",
"date_updated" : "type:datetime",
},
{