{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://www.sonyatv.store/webplayer-playlist-schema-v3.json",
  "title": "SonyATV Playlist and Immersive Media Manifest Row v3",
  "description": "A portable SonyATV media row with a guaranteed compatible source plus optional ordered playlist, HLS, DASH, and publisher-declared Dolby Digital Plus Atmos/JOC delivery metadata.",
  "type": "object",
  "required": ["schema", "id", "title", "kind"],
  "properties": {
    "schema": { "const": "sony-atv.webplayer.playlist/v3" },
    "id": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$" },
    "title": { "type": "string", "minLength": 1, "maxLength": 160 },
    "kind": { "enum": ["audio", "video", "image", "document", "file"] },
    "media_url": { "type": "string", "format": "uri", "pattern": "^https://" },
    "filename": { "type": "string", "maxLength": 255, "pattern": "^[^/\\\\]+$" },
    "media_type": { "type": "string", "maxLength": 80 },
    "artwork_url": { "type": "string", "format": "uri", "pattern": "^https://" },
    "thumbnail_url": { "type": "string", "format": "uri", "pattern": "^https://" },
    "description": { "type": "string", "maxLength": 1000 },
    "creator": { "type": "string", "maxLength": 120 },
    "collection": { "type": "string", "maxLength": 120 },
    "genre": { "type": "string", "maxLength": 80 },
    "release_date": { "type": "string", "pattern": "^(\\d{4}|\\d{4}-\\d{2}-\\d{2})$" },
    "duration_seconds": { "oneOf": [{ "type": "number", "minimum": 0 }, { "type": "string", "pattern": "^(0|[1-9]\\d*)(\\.\\d+)?$" }] },
    "captions_url": { "type": "string", "format": "uri", "pattern": "^https://.*\\.vtt(?:[?#].*)?$" },
    "alt_text": { "type": "string", "maxLength": 300 },
    "enabled": { "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false", "1", "0", "yes", "no", "on", "off", "enabled", "disabled"] }], "default": true },
    "featured": { "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false", "1", "0", "yes", "no", "on", "off", "enabled", "disabled"] }], "default": false },
    "sort_order": { "oneOf": [{ "type": "integer", "minimum": 1 }, { "type": "string", "pattern": "^[1-9]\\d*$" }] },
    "downloadable": { "oneOf": [{ "type": "boolean" }, { "type": "string", "enum": ["true", "false", "1", "0", "yes", "no", "on", "off", "enabled", "disabled"] }] },
    "tags": { "type": "string", "description": "Pipe- or semicolon-separated display tags." },
    "playlist_id": { "type": "string", "pattern": "^[A-Za-z0-9][A-Za-z0-9._:-]{0,63}$" },
    "playlist_title": { "type": "string", "minLength": 1, "maxLength": 160 },
    "track_number": { "oneOf": [{ "type": "integer", "minimum": 1 }, { "type": "string", "pattern": "^[1-9]\\d*$" }] },
    "hls_url": { "type": "string", "format": "uri", "pattern": "^https://.*\\.m3u8(?:[?#].*)?$" },
    "dash_url": { "type": "string", "format": "uri", "pattern": "^https://.*\\.mpd(?:[?#].*)?$" },
    "atmos_url": { "type": "string", "format": "uri", "pattern": "^https://" },
    "atmos_media_type": { "enum": ["audio/mp4", "video/mp4"] },
    "atmos_codecs": { "type": "string", "pattern": "^[Ee][Cc]-3$" },
    "atmos_profile": { "type": "string", "pattern": "^[Dd][Dd][Pp]-[Jj][Oo][Cc]$" },
    "audio_channels": { "oneOf": [{ "type": "integer", "const": 16 }, { "type": "string", "pattern": "^(16|16/[Jj][Oo][Cc])$" }] }
  },
  "oneOf": [
    { "required": ["media_url"], "not": { "required": ["filename"] } },
    { "required": ["filename"], "not": { "required": ["media_url"] } }
  ],
  "allOf": [
    { "if": { "required": ["playlist_title"] }, "then": { "required": ["playlist_id"] } },
    { "if": { "required": ["track_number"] }, "then": { "required": ["playlist_id"] } },
    { "if": { "anyOf": [{ "required": ["playlist_id"] }, { "required": ["playlist_title"] }, { "required": ["track_number"] }] }, "then": { "properties": { "kind": { "enum": ["audio", "video"] } } } },
    { "if": { "anyOf": [{ "required": ["hls_url"] }, { "required": ["dash_url"] }, { "required": ["atmos_url"] }] }, "then": { "properties": { "kind": { "enum": ["audio", "video"] } } } },
    { "if": { "required": ["atmos_url"] }, "then": { "required": ["atmos_media_type", "atmos_codecs", "atmos_profile", "audio_channels"] } },
    {
      "if": { "anyOf": [{ "required": ["atmos_media_type"] }, { "required": ["atmos_codecs"] }, { "required": ["atmos_profile"] }, { "required": ["audio_channels"] }] },
      "then": {
        "required": ["atmos_codecs", "atmos_profile", "audio_channels"],
        "anyOf": [{ "required": ["atmos_url"] }, { "required": ["hls_url"] }, { "required": ["dash_url"] }]
      }
    }
  ],
  "additionalProperties": false
}
