{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/tubearchivist/json-schema/tubearchivist-video-schema.json",
  "title": "Video",
  "description": "serialize video item",
  "x-generated": "2026-10-28",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/tubearchivist-openapi.yml#/components/schemas/Video",
  "type": "object",
  "properties": {
    "active": {
      "type": "boolean"
    },
    "category": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "channel": {
      "$ref": "#/$defs/Channel"
    },
    "comment_count": {
      "type": [
        "integer",
        "null"
      ]
    },
    "date_downloaded": {
      "type": "integer"
    },
    "description": {
      "type": [
        "string",
        "null"
      ]
    },
    "media_size": {
      "type": "integer"
    },
    "media_url": {
      "type": "string"
    },
    "player": {
      "$ref": "#/$defs/Player"
    },
    "playlist": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "published": {
      "type": "string"
    },
    "sponsorblock": {
      "allOf": [
        {
          "$ref": "#/$defs/SponsorBlock"
        }
      ],
      "nullable": true
    },
    "stats": {
      "$ref": "#/$defs/Stats"
    },
    "streams": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/StreamItem"
      }
    },
    "subtitles": {
      "type": "array",
      "items": {
        "$ref": "#/$defs/SubtitleItem"
      }
    },
    "tags": {
      "type": "array",
      "items": {
        "type": "string"
      }
    },
    "title": {
      "type": "string"
    },
    "vid_last_refresh": {
      "type": "string"
    },
    "vid_thumb_url": {
      "type": "string"
    },
    "vid_type": {
      "$ref": "#/$defs/VidTypeFilterEnum"
    },
    "youtube_id": {
      "type": "string"
    },
    "_index": {
      "type": "string",
      "title": " index"
    },
    "_score": {
      "type": "number",
      "format": "double",
      "title": " score"
    }
  },
  "required": [
    "active",
    "category",
    "date_downloaded",
    "media_size",
    "media_url",
    "player",
    "published",
    "stats",
    "streams",
    "tags",
    "title",
    "vid_last_refresh",
    "vid_thumb_url",
    "vid_type",
    "youtube_id"
  ],
  "$defs": {
    "Channel": {
      "type": "object",
      "description": "serialize channel",
      "properties": {
        "channel_id": {
          "type": "string"
        },
        "channel_active": {
          "type": "boolean"
        },
        "channel_banner_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "channel_thumb_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "channel_tvart_url": {
          "type": [
            "string",
            "null"
          ]
        },
        "channel_description": {
          "type": [
            "string",
            "null"
          ]
        },
        "channel_last_refresh": {
          "type": "string"
        },
        "channel_name": {
          "type": "string"
        },
        "channel_overwrites": {
          "$ref": "#/$defs/ChannelOverwrite"
        },
        "channel_subs": {
          "type": "integer"
        },
        "channel_subscribed": {
          "type": "boolean"
        },
        "channel_tags": {
          "type": "array",
          "items": {
            "type": "string"
          }
        },
        "channel_tabs": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/VidTypeFilterEnum"
          }
        },
        "_index": {
          "type": "string",
          "title": " index"
        },
        "_score": {
          "type": "integer",
          "title": " score"
        }
      },
      "required": [
        "channel_active",
        "channel_id",
        "channel_last_refresh",
        "channel_name",
        "channel_subs",
        "channel_subscribed",
        "channel_tabs"
      ]
    },
    "ChannelOverwrite": {
      "type": "object",
      "description": "serialize channel overwrites",
      "properties": {
        "download_format": {
          "type": [
            "string",
            "null"
          ]
        },
        "autodelete_days": {
          "type": [
            "integer",
            "null"
          ]
        },
        "index_playlists": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "integrate_sponsorblock": {
          "type": [
            "boolean",
            "null"
          ]
        },
        "subscriptions_channel_size": {
          "type": [
            "integer",
            "null"
          ]
        },
        "subscriptions_live_channel_size": {
          "type": [
            "integer",
            "null"
          ]
        },
        "subscriptions_shorts_channel_size": {
          "type": [
            "integer",
            "null"
          ]
        }
      }
    },
    "ExtEnum": {
      "enum": [
        "json3",
        "vtt"
      ],
      "type": "string",
      "description": "* `json3` - json3\n* `vtt` - vtt"
    },
    "Player": {
      "type": "object",
      "description": "serialize player",
      "properties": {
        "watched": {
          "type": "boolean"
        },
        "watched_date": {
          "type": "integer"
        },
        "duration": {
          "type": "integer"
        },
        "duration_str": {
          "type": "string"
        },
        "progress": {
          "type": "number",
          "format": "double"
        },
        "position": {
          "type": "number",
          "format": "double"
        }
      },
      "required": [
        "duration",
        "duration_str",
        "watched"
      ]
    },
    "SourceEnum": {
      "enum": [
        "user",
        "auto"
      ],
      "type": "string",
      "description": "* `user` - user\n* `auto` - auto"
    },
    "SponsorBlock": {
      "type": "object",
      "description": "serialize sponsorblock",
      "properties": {
        "is_enabled": {
          "type": "boolean"
        },
        "last_refresh": {
          "type": "integer"
        },
        "has_unlocked": {
          "type": "boolean"
        },
        "segments": {
          "type": "array",
          "items": {
            "$ref": "#/$defs/SponsorBlockSegment"
          }
        }
      },
      "required": [
        "is_enabled",
        "last_refresh",
        "segments"
      ]
    },
    "SponsorBlockSegment": {
      "type": "object",
      "description": "serialize sponsorblock segment",
      "properties": {
        "actionType": {
          "type": "string"
        },
        "videoDuration": {
          "type": "number",
          "format": "double"
        },
        "segment": {
          "type": "array",
          "items": {
            "type": "number",
            "format": "double"
          }
        },
        "votes": {
          "type": "integer"
        },
        "category": {
          "type": "string"
        },
        "UUID": {
          "type": "string"
        },
        "locked": {
          "type": "integer"
        }
      },
      "required": [
        "UUID",
        "actionType",
        "category",
        "locked",
        "segment",
        "videoDuration",
        "votes"
      ]
    },
    "Stats": {
      "type": "object",
      "description": "serialize stats",
      "properties": {
        "like_count": {
          "type": "integer"
        },
        "average_rating": {
          "type": "number",
          "format": "double"
        },
        "view_count": {
          "type": "integer"
        },
        "dislike_count": {
          "type": "integer"
        }
      },
      "required": [
        "average_rating",
        "dislike_count",
        "like_count",
        "view_count"
      ]
    },
    "StreamItem": {
      "type": "object",
      "description": "serialize stream item",
      "properties": {
        "bitrate": {
          "type": "integer"
        },
        "codec": {
          "type": "string"
        },
        "height": {
          "type": "integer"
        },
        "index": {
          "type": "integer"
        },
        "type": {
          "$ref": "#/$defs/TypeEnum"
        },
        "width": {
          "type": "integer"
        }
      },
      "required": [
        "bitrate",
        "codec",
        "index",
        "type"
      ]
    },
    "SubtitleItem": {
      "type": "object",
      "description": "serialize subtitle item",
      "properties": {
        "ext": {
          "$ref": "#/$defs/ExtEnum"
        },
        "lang": {
          "type": "string"
        },
        "media_url": {
          "type": "string"
        },
        "name": {
          "type": "string"
        },
        "source": {
          "$ref": "#/$defs/SourceEnum"
        },
        "url": {
          "type": [
            "string",
            "null"
          ],
          "format": "uri"
        }
      },
      "required": [
        "ext",
        "lang",
        "media_url",
        "name",
        "source",
        "url"
      ]
    },
    "TypeEnum": {
      "enum": [
        "video",
        "audio"
      ],
      "type": "string",
      "description": "* `video` - video\n* `audio` - audio"
    },
    "VidTypeFilterEnum": {
      "enum": [
        "videos",
        "streams",
        "shorts"
      ],
      "type": "string",
      "description": "* `videos` - videos\n* `streams` - streams\n* `shorts` - shorts"
    }
  }
}