{
 "$schema": "https://json-schema.org/draft/2020-12/schema",
 "$id": "https://seamlessscene.com/schemas/seamless-edit-pack-v1.json",
 "title": "Seamless Scene edit pack (edit.json) v1",
 "type": "object",
 "required": [
  "id",
  "episode",
  "scenes"
 ],
 "properties": {
  "format": {
   "const": "seamless-edit-pack"
  },
  "version": {
   "const": 1
  },
  "id": {
   "type": "string",
   "pattern": "^[a-z0-9][a-z0-9._-]{0,127}$"
  },
  "creator_name": {
   "type": "string",
   "maxLength": 120,
   "description": "display text for local use only"
  },
  "title": {
   "type": "string",
   "maxLength": 120,
   "minLength": 3,
   "description": "3–120 characters"
  },
  "description": {
   "type": "string",
   "maxLength": 5000,
   "minLength": 20,
   "description": "20–5000 characters"
  },
  "category": {
   "enum": [
    "casting-swap",
    "visual-fx-update",
    "outfit-swap",
    "parody",
    "major-rewrite",
    "extended-scene",
    "other"
   ],
   "description": "one of the website’s edit types"
  },
  "tags": {
   "type": "array",
   "maxItems": 5,
   "items": {
    "type": "string",
    "minLength": 1,
    "maxLength": 40
   },
   "description": "0–5 tags of 1–40 characters (the primary way to describe and filter)"
  },
  "mature": {
   "type": "boolean",
   "description": "true or false"
  },
  "release_notes": {
   "type": "string",
   "maxLength": 4000,
   "description": "at most 4000 characters; required from revision 2"
  },
  "imdb_url": {
   "type": "string",
   "maxLength": 300,
   "description": "an imdb.com/title/tt… link, or \"\""
  },
  "revision": {
   "type": "integer",
   "minimum": 1,
   "description": "a whole number from 1"
  },
  "episode": {
   "type": "object",
   "required": [
    "gti",
    "show",
    "season",
    "episode",
    "runtime_ms"
   ],
   "properties": {
    "service": {
     "const": "prime-video"
    },
    "gti": {
     "type": "string",
     "minLength": 1
    },
    "show": {
     "type": "string",
     "minLength": 1
    },
    "season": {
     "type": "integer",
     "minimum": 0
    },
    "episode": {
     "type": "integer",
     "minimum": 0
    },
    "episode_title": {
     "type": "string",
     "maxLength": 200
    },
    "runtime_ms": {
     "type": "integer",
     "minimum": 1
    },
    "runtime_tolerance_ms": {
     "type": "integer",
     "minimum": 0,
     "maximum": 5000
    },
    "territory": {
     "type": "string",
     "pattern": "^[A-Z]{2}$"
    },
    "tier": {
     "enum": [
      "ad-free",
      "ad-supported",
      "unverified"
     ]
    },
    "version_tag": {
     "type": "string",
     "maxLength": 120,
     "pattern": "^[a-z0-9][a-z0-9._-]*$"
    }
   }
  },
  "scenes": {
   "type": "array",
   "minItems": 1,
   "items": {
    "oneOf": [
     {
      "type": "object",
      "required": [
       "action",
       "start",
       "end",
       "clip"
      ],
      "properties": {
       "action": {
        "const": "REPLACE"
       },
       "start": {
        "anyOf": [
         {
          "type": "integer",
          "minimum": 0
         },
         {
          "type": "string",
          "pattern": "^(?:\\d+:)?\\d{1,2}:\\d{2}(?:\\.\\d{1,3})?$"
         }
        ]
       },
       "end": {
        "anyOf": [
         {
          "type": "integer",
          "minimum": 0
         },
         {
          "type": "string",
          "pattern": "^(?:\\d+:)?\\d{1,2}:\\d{2}(?:\\.\\d{1,3})?$"
         }
        ]
       },
       "clip": {
        "type": "string"
       },
       "gain_db": {
        "type": "integer",
        "minimum": -24,
        "maximum": 6
       },
       "note": {
        "type": "string"
       }
      }
     },
     {
      "type": "object",
      "required": [
       "action",
       "at",
       "clip"
      ],
      "properties": {
       "action": {
        "const": "INSERT"
       },
       "at": {
        "anyOf": [
         {
          "type": "integer",
          "minimum": 0
         },
         {
          "type": "string",
          "pattern": "^(?:\\d+:)?\\d{1,2}:\\d{2}(?:\\.\\d{1,3})?$"
         }
        ]
       },
       "clip": {
        "type": "string"
       },
       "gain_db": {
        "type": "integer",
        "minimum": -24,
        "maximum": 6
       },
       "note": {
        "type": "string"
       }
      }
     }
    ]
   }
  }
 }
}
