# Source / release origin patterns.
#
# All source detection is handled here (v0.2.1+).
# Side-effects emit Other:Rip, Other:Screener, Other:Reencoded
# for patterns that carry those signals.

property = "source"

# ── Single-token exact matches (no side-effects needed) ────────────────
[exact]
# Blu-ray (plain — no Rip/Screener)
bluray    = "Blu-ray"
bd        = "Blu-ray"
bdremux   = "Blu-ray"
brremux   = "Blu-ray"
bd5       = "Blu-ray"
bd9       = "Blu-ray"
bd25      = "Blu-ray"
bd50      = "Blu-ray"

# Web (plain)
web       = "Web"
webdl     = "Web"
webuhd    = "Web"
dlweb     = "Web"
dlmux     = "Web"

# HDTV
hdtv      = "HDTV"
ahdtv     = "Analog HDTV"
uhdtv     = "Ultra HDTV"

# DVD (plain)
dvd       = "DVD"
dvdr      = "DVD"
dvd5      = "DVD"
dvd9      = "DVD"
vts       = "DVD"

# Digital TV
pdtv      = "Digital TV"
dvb       = "Digital TV"

# Camera
cam       = "Camera"
hdcam     = "HD Camera"

# Satellite
dsr       = "Satellite"
dth       = "Satellite"

# Telecine / Telesync
tc        = "Telecine"
telecine  = "Telecine"
telesync  = "Telesync"
hdtc      = "HD Telecine"
ts        = "Telesync"

# Other
vhs       = "VHS"
screener  = "Screener"
workprint = "Workprint"
wp        = "Workprint"
ppv       = "Pay-per-view"
vod       = "Video on Demand"
tv        = "TV"
sd        = "TV"
dm        = "Digital Master"

# ── Exact matches with side-effects (must be [[patterns]]) ───────────

# Rip variants (single token)
[[patterns]]
match = '(?i)^bdrip$'
value = "Blu-ray"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^brrip$'
value = "Blu-ray"
side_effects = [
    { property = "other", value = "Rip" },
    { property = "other", value = "Reencoded" },
]

[[patterns]]
match = '(?i)^webrip$'
value = "Web"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^webcap$'
value = "Web"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^dvdrip$'
value = "DVD"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^vhsrip$'
value = "VHS"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^hdrip$'
value = "HD"
side_effects = [{ property = "other", value = "Rip" }]

# Screener variants (single token)
[[patterns]]
match = '(?i)^bdscr$'
value = "Blu-ray"
side_effects = [{ property = "other", value = "Screener" }]

[[patterns]]
match = '(?i)^brscr$'
value = "Blu-ray"
side_effects = [{ property = "other", value = "Screener" }]

[[patterns]]
match = '(?i)^dvdscr$'
value = "DVD"
side_effects = [{ property = "other", value = "Screener" }]

# ── Compound patterns (2–3 token windows) ──────────────────────────

# Blu-ray compounds (plain)
[[patterns]]
match = '(?i)^blu[-. _]?ray$'
value = "Blu-ray"

[[patterns]]
match = '(?i)^b[dr][-. ]?remux$'
value = "Blu-ray"

# Blu-ray compounds (with Rip)
[[patterns]]
match = '(?i)^b[dr][-. ]?rip$'
value = "Blu-ray"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^br[-. ]?rip$'
value = "Blu-ray"
side_effects = [
    { property = "other", value = "Rip" },
    { property = "other", value = "Reencoded" },
]

# Blu-ray compounds (with Screener)
[[patterns]]
match = '(?i)^b[dr][-. ]?scr(?:eener)?$'
value = "Blu-ray"
side_effects = [{ property = "other", value = "Screener" }]

# Web compounds (plain)
[[patterns]]
match = '(?i)^web[-. _]?dl$'
value = "Web"

[[patterns]]
match = '(?i)^web[-. _]?uhd$'
value = "Web"

[[patterns]]
match = '(?i)^web[-. _]?hd$'
value = "Web"

# Web compounds (with Rip)
[[patterns]]
match = '(?i)^web[-. _]?rip$'
value = "Web"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^web[-. _]?cap(?:[-. ]?rip)?$'
value = "Web"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^web[-. _]?(?:dl[-. ]?)?rip$'
value = "Web"
side_effects = [{ property = "other", value = "Rip" }]

# Web compounds (with Screener)
[[patterns]]
match = '(?i)^web[-. ]?scr(?:eener)?$'
value = "Web"
side_effects = [{ property = "other", value = "Screener" }]

# HDTV compounds
[[patterns]]
match = '(?i)^hd[-. ]?tv$'
value = "HDTV"

[[patterns]]
match = '(?i)^hd[-. ]?tv[-. ]?rip$'
value = "HDTV"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^uhd[-. ]?tv$'
value = "Ultra HDTV"

[[patterns]]
match = '(?i)^uhd[-. ]?(?:tv[-. ]?)?rip$'
value = "Ultra HDTV"
side_effects = [{ property = "other", value = "Rip" }]

# DVD compounds
[[patterns]]
match = '(?i)^dvd[-. ]?rip$'
value = "DVD"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^dvd[-. ]?scr(?:eener)?$'
value = "DVD"
side_effects = [{ property = "other", value = "Screener" }]

[[patterns]]
match = '(?i)^video[-. _]?ts$'
value = "DVD"

# HD-DVD compounds
[[patterns]]
match = '(?i)^hd[-. ]?dvd$'
value = "HD-DVD"

[[patterns]]
match = '(?i)^hd[-. ]?dvd[-. ]?rip$'
value = "HD-DVD"
side_effects = [{ property = "other", value = "Rip" }]

# Digital TV compounds
[[patterns]]
match = '(?i)^pd[-. ]?tv$'
value = "Digital TV"

[[patterns]]
match = '(?i)^(?:pd[-. ]?tv|dvb)[-. ]?rip$'
value = "Digital TV"
side_effects = [{ property = "other", value = "Rip" }]

# SD/TV compounds
[[patterns]]
match = '(?i)^sd[-. ]?tv$'
value = "TV"

[[patterns]]
match = '(?i)^(?:sd[-. ]?)?tv[-. ]?rip$'
value = "TV"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^tv[-. ]?dub$'
value = "TV"

# Camera compounds
[[patterns]]
match = '(?i)^hd[-. ]?cam$'
value = "HD Camera"

[[patterns]]
match = '(?i)^hd[-. ]?cam[-. ]?rip$'
value = "HD Camera"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^cam[-. ]?rip$'
value = "Camera"
side_effects = [{ property = "other", value = "Rip" }]

# Satellite compounds
[[patterns]]
match = '(?i)^(?:dsr?|dth|sat)[-. ]?rip$'
value = "Satellite"
side_effects = [{ property = "other", value = "Rip" }]

# Telecine compounds
[[patterns]]
match = '(?i)^hd[-. ]?(?:telecine|tc)$'
value = "HD Telecine"

[[patterns]]
match = '(?i)^hd[-. ]?(?:telecine|tc)[-. ]?rip$'
value = "HD Telecine"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^(?:telecine|tc)[-. ]?rip$'
value = "Telecine"
side_effects = [{ property = "other", value = "Rip" }]

# Telesync compounds
[[patterns]]
match = '(?i)^hd[-. ]?(?:telesync|ts)$'
value = "HD Telesync"

[[patterns]]
match = '(?i)^hd[-. ]?(?:telesync|ts)[-. ]?rip$'
value = "HD Telesync"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^(?:telesync|ts)[-. ]?rip$'
value = "Telesync"
side_effects = [{ property = "other", value = "Rip" }]

# VHS / PPV / VOD / Digital Master compounds
[[patterns]]
match = '(?i)^vhs[-. ]?rip$'
value = "VHS"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^ppv[-. ]?rip$'
value = "Pay-per-view"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^vod[-. ]?rip$'
value = "Video on Demand"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^dm[-. ]?rip$'
value = "Digital Master"
side_effects = [{ property = "other", value = "Rip" }]

# HD generic
[[patterns]]
match = '(?i)^hd[-. ]?rip$'
value = "HD"
side_effects = [{ property = "other", value = "Rip" }]

# ── Ultra HD Blu-ray (2–3 token windows) ───────────────────────────
# Wider UHD+Blu-ray combinations (4+ tokens apart) are handled by
# the pipeline's promote_uhd_bluray() post-processing rule.

[[patterns]]
match = '(?i)^uhd[-. ]blu[-. ]?ray$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^uhd[-. ]bluray$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^uhd[-. ]b[dr]rip$'
value = "Ultra HD Blu-ray"
side_effects = [
    { property = "other", value = "Rip" },
    { property = "other", value = "Reencoded" },
]

[[patterns]]
match = '(?i)^uhd[-. ]bdrip$'
value = "Ultra HD Blu-ray"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
# UHD + (any token) + Bluray/BD/BR (3-token window)
match = '(?i)^uhd[-. ]\w+[-. ]blu(?:[-. ]?ray)?$'
value = "Ultra HD Blu-ray"

[[patterns]]
# UHD + (any token) + BRRip (3-token window)
match = '(?i)^uhd[-. ]\w+[-. ]brrip$'
value = "Ultra HD Blu-ray"
side_effects = [
    { property = "other", value = "Rip" },
    { property = "other", value = "Reencoded" },
]

[[patterns]]
# UHD + (any token) + BDRip (3-token window)
match = '(?i)^uhd[-. ]\w+[-. ]bdrip$'
value = "Ultra HD Blu-ray"
side_effects = [{ property = "other", value = "Rip" }]

[[patterns]]
match = '(?i)^blu(?:[-. ]?ray)?[-. ]uhd$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^ultra[-. ]bluray$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^ultra[-. ]blu[-. ]?ray$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^ultra[-. ]?hd[-. ]?bluray$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^ultra[-. ]?hd[-. ]?blu[-. ]?ray$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^bluray[-. ]ultra(?:[-. ]?hd)?$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^blu[-. ]?ray[-. ]ultra(?:[-. ]?hd)?$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^4k[-. ]blu(?:[-. ]?ray)?$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^blu(?:[-. ]?ray)?[-. ]4k$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^2160p[-. ]blu(?:[-. ]?ray)?$'
value = "Ultra HD Blu-ray"

[[patterns]]
match = '(?i)^blu(?:[-. ]?ray)?[-. ]2160p$'
value = "Ultra HD Blu-ray"
