Skip to content

Instantly share code, notes, and snippets.

@rlaphoenix
Last active July 26, 2021 04:14
Show Gist options
  • Save rlaphoenix/f4bb99fbe7b7b23bbeba34de1648037c to your computer and use it in GitHub Desktop.
Save rlaphoenix/f4bb99fbe7b7b23bbeba34de1648037c to your computer and use it in GitHub Desktop.
RPG style P2P Movies and TV filebot template. (Note: Specifically designed around DVD REMUXs)
{
// Requirements: MediaInfo and libmediainfo v19.09 or newer.
// Examples:
// "The.IT.Crowd.S01E01.Yesterdays.Jam.PAL.DVD.DD.2.0.MPEG-2.REMUX-RPG"
// "Luca.2021.Repack.NTSC.DVD.DD.5.1.MPEG-2.REMUX-RPG"
def Movie = false;
def Group = "RPG"; // Only used if no Group Tag is detected in the original filenames
def Source = "DVD"; // e.g. BluRay, DVD, and so on
def Edition = "Unrated Open Matte"; // If empty or not set, it will be detected from the original filename
def Tags = "REMUX";
// =========================== //
if ((m = fn =~ /-(\w+)$/)) {
Group = m.group(1)
}
if (!Edition) {
Edition = []
if ((m = fn.space(".") =~ /(?i)\b(open\.matte|unrated|extended)\b/)) {
Edition.add(m.group(1).tokenize(".")*.toLowerCase()*.capitalize().join(" "))
}
if ((m = fn.space(".") =~ /(?i)\b(repack|proper)\b/)) {
Edition.add(m.group(1).tokenize(".")*.toLowerCase()*.capitalize().join(" "))
}
Edition = Edition.join(" ")
}
def Ac = audio[0].format_commercial
def Ach = (any{ audio.ChannelLayout*.replaceAll(/Object Based/)*.split()*.collect{ it.replace(/LFE/, '0.1').replaceFirst(/(\b(?:L|R|C)(?:b+|s+|w+)?\b)/, '1').toDouble() }*.sum().collect{ it == null ? audio.findAll{ it.ChannelLayout == /Object Based/ }.Channels*.replace(/8/,'7.1')*.replace(/6/,'5.1')[0] + ' (Objs)' : it }[0] }{ audio.Channels[0].toDouble() }).toString()
switch (Ac) {
case "Dolby TrueHD with Dolby Atmos": Ac = "TrueHD@.Atmos"; break
case "Dolby TrueHD": Ac = "TrueHD"; break
case "DTS-HD Master Audio": Ac = "DTS-HD MA"; break
case "DTS-ES Matrix": Ac = "DTS-ES"; break
case "Dolby Digital": Ac = "DD"; break
case "Dolby Digital Plus": Ac = "DDP"; break
case "HE-AAC": Ac = "AAC"; break
}
if (any{audio[0].format_additionalfeatures}{false}) {
switch (audio[0].format_additionalfeatures) {
case "XLL X": Ac = audio[0].format + "-X"; break
}
}
def fnf = fn.lower().space(".");
def Fn = [
// Title
n.replace(" - ", " "),
// Year or S00E00 and Episode Name
Movie ? y : (S00E00 + " " + t),
// Edition, e.g. Repack, Proper, Open Matte, Unrated, Extended, etc.
Edition,
// Standard. No need to specify the resolution. Scan could be a mix, so don't specify.
height == 480 ? "NTSC" : "PAL",
// Source, e.g. BluRay, DVD, and so on
Source,
// Dynamic Range
any{hdr}{" "},
// Audio Codec and Channels, e.g. AAC 2.0, DDP 5.1, TrueHD 7.1 Atmos, etc.
Ac.contains("@") ? Ac.replace('@', Ach) : (Ac + " " + Ach),
// Video Codec
video[0].codecId.replace("V_MPEG", "MPEG-"),
// Tags
Tags
].join(" ") + "-" + Group
// Condense spaces, replace spaces with dots
Fn = Fn.replaceAll(/[ ]{2,}/, " ").space(".")
// Remove special characters that may not be usable on some file systems
Fn = Fn.replaceAll(/([<>:"\/\\!|?*,'()_]|\s|[\x00-\x1F\x7F]|(?:(?!\p{IsLatin})\p{L})|\.$)/).ascii()
return Fn
}
@rlaphoenix
Copy link
Author

rlaphoenix commented Jul 18, 2021

Coming from the RPG handbook? You may want to use the Generic Base Style listed above for the MKV Container Title. While your at it, check this out! This python script will auto-set the MKV file's container title to whatever the MKV filename is, which would be the container title. This RPG style template should only be applied once the MKV is ready for release, or verification.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment