Skip to content

Commit

Permalink
Reformat scripts to take lesser storage after "compile"
Browse files Browse the repository at this point in the history
  • Loading branch information
nattadasu committed Dec 13, 2024
1 parent c63a0e7 commit bcdfceb
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 83 deletions.
8 changes: 4 additions & 4 deletions compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ def clean_characters(text: str) -> str:
"""
# fmt: off
replacements = [
(r",\s*;", ","), (r"{\s*;", "{"), (r";\s*}", "}"), (r"};\n{", "}\n{"),
(r";\s*$", ""), (r"\[\s*;", "["), (r";\s*\]", "]"), (r",\s+\)", ")"),
(r",\s*\]", "]"), (r"(\s)*", "\\1"), (r"->;", "->"), (r"->", "-> "),
(r"\r", ""), (r"\n", ""),
(r",\s*;", ","), (r";\.", "."), (r"{\s*;", "{"), (r";\s*}", "}"),
(r"};\n{", "}\n{"), (r";\s*$", ""), (r"\[\s*;", "["), (r";\s*\]", "]"),
(r",\s+\)", ")"), (r",\s*\]", "]"), (r"(\s)*", "\\1"), (r"->;", "->"),
(r"->", "-> "), (r"\r", ""), (r"\n", ""), (r"\|\|;", "||"), (r"&&;", "&&"),
]
# fmt: on

Expand Down
12 changes: 7 additions & 5 deletions modules/common_movie.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
@./r18_checker.groovy
{
// check Country of Origin
def cjk_countries = ["CN", "JP", "KR", "KP", "TW", "HK"]
def cjkani_tags = ["aeni", "donghua", "anime"]
def is_anime = any {anime} || info.Keywords.findAll { it in cjkani_tags } || (cjk_countries.contains(country) && genres =~ /Animation/)
def cjk_countries = ["CN","JP","KR","KP","TW","HK"]
def cjkani_tags = ["aeni","donghua","anime"]
def is_anime = (any {anime} ||
info.Keywords.findAll {it in cjkani_tags} ||
(cjk_countries.contains(country) && genres.contains("Animation")))
// Categorized path
is_anime ? "Anime Movies/" : "Movies/"
}
Expand All @@ -14,10 +16,10 @@
def db_name = id == tmdbid ? "TheMovieDB" : "IMDb"
def db_map = [
"TheMovieDB": "tmdbid",
"IMDb": "imdbid"
"IMDb": "imdbid",
]
def db_src = db_map[db_name]
def fixed_id = db_name == "IMDb" ? "tt${id}" : id
" [${db_src}-${fixed_id}]/"
}
@./filename_movie.groovy
@./filename_movie.groovy
8 changes: 5 additions & 3 deletions modules/common_tv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
@./r18_checker.groovy
{
// check Country of Origin
def cjk_countries = ["CN", "JP", "KR", "KP", "TW", "HK"]
def cjkani_tags = ["aeni", "donghua", "anime"]
def is_anime = any {anime} || info.Keywords.findAll { it in cjkani_tags } || (cjk_countries.contains(country) && genres =~ /Animation/)
def cjk_countries = ["CN","JP","KR","KP","TW","HK"]
def cjkani_tags = ["aeni","donghua","anime"]
def is_anime = (any {anime} ||
info.Keywords.findAll {it in cjkani_tags} ||
(cjk_countries.contains(country) && genres.contains("Animation")))
// Categorized path
is_anime ? "Anime/" : "TV Series/"
}
Expand Down
9 changes: 6 additions & 3 deletions modules/filename_tv.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
@./medianame.groovy
{" - "}{s00e00}
{
def invalid_chars = ['\\', '/', ':', '*', '?', '"', '<', '>', '|']
def fixed_name = t.replaceAll(invalid_chars.collect { "\\" + it }.join('|'), '_')
def epnum = any { e } { special }
def invalid_chars = ['\\','/',':','*','?','"','<','>','|']
def fixed_name = t.replaceAll(
invalid_chars.collect {"\\" + it}.join('|'),
'_'
)
def epnum = any {e} {special}
// check if fixed name length is more than 100, if so, empty it
fixed_name = fixed_name.length() > 100 ? " " : " - $fixed_name "
fixed_name == " - Episode $epnum " ? " " : fixed_name
Expand Down
10 changes: 7 additions & 3 deletions modules/filepath.groovy
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
// detect if the system is windows
def gp_ = { System.getProperty(it) }
def gp_ = {System.getProperty(it)}
def is_windows = gp_("os.name").toLowerCase().contains("windows")
// get current username
def user_ = gp_("user.name")
Expand All @@ -9,7 +9,8 @@
def mntp = "/run/media/${user_}"

//! OVERRIDE THIS PATH IF NEEDED, ELSE, BLANK IT ("")
def override = is_windows ? "H:/" : "$mntp/Videos"
// def override = is_windows ? "H:/" : "$mntp/Videos"
def override = ""

def mounts = [
[label: "Books", winmnt: "F:/", linmnt: "$mntp/Books"],
Expand All @@ -19,7 +20,10 @@
[label: "Videos", winmnt: "H:/", linmnt: "$mntp/Videos"],
]

def guess = (mounts.collect { it[is_windows ? "winmnt" : "linmnt"] as File }.sort { first, second -> first.exists() <=> second.exists() ?: first.diskSpace <=> second.diskSpace }).last()
def guess = (mounts.collect {it[is_windows ? "winmnt" : "linmnt"] as File}
.sort {first, second ->
first.exists() <=> second.exists() ?: first.diskSpace <=> second.diskSpace
}).last().path
def final_ = override ?: guess
"$final_/"
}
10 changes: 5 additions & 5 deletions modules/filespec.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,18 @@
{
def dub = " Dub"
// if audioLanguages contains language, blank out dub
def substat = audioLanguages.any { it.ISO3B == language.ISO3B } ? "" : dub
substat = audioLanguages.size() == 1 && audioLanguages.any { it.ISO3B == "und" } ? "" : substat
def substat = audioLanguages.any{it.ISO3B == language.ISO3B} ? "" : dub
substat = audioLanguages.size() == 1 && audioLanguages.any{it.ISO3B == "und"} ? "" : substat
substat
}
{
def audioLangCount = any { audioLanguages.size() } { 0 }
def audioLangCount = any {audioLanguages.size()} {0}
def substat = audioLangCount > 2 ? " MAud" : audioLangCount > 1 ? " DAud" : null
def langs_ = audioLangCount > 5 ? audioLanguages.take(5) : audioLanguages
substat ? substat + langs_.joining(" ", " (", "").upper() + (audioLangCount > 5 ? " ...)" : ")") : ""
}
{
def textLangCount = any { textLanguages.size() } { 0 }
def textLangCount = any {textLanguages.size()} {0}
def substat = textLangCount > 2 ? ", MSub" : textLangCount > 1 ? ", DSub" : null
def langs_ = textLangCount > 5 ? textLanguages.take(5) : textLanguages
substat ? substat + langs_.joining(" ", " (", "").upper() + (textLangCount > 5 ? " ...)" : ")") : ""
Expand All @@ -44,7 +44,7 @@
]
// Clean subt variable if any on langcode exists
def cleanedSubt = subt
langcode.values().each { code ->
langcode.values().each {code ->
if (cleanedSubt.contains(code)) {
cleanedSubt = cleanedSubt.replace(code, "")
}
Expand Down
26 changes: 13 additions & 13 deletions modules/forceshowid_tv.groovy
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
{
def tmdb_tv = "TheMovieDB::TV"
def show_id = [
[ 68854, tmdb_tv], // Kimi ni Todoke (2009) (君に届け), JP
[123542, tmdb_tv], // LINK CLICK (2021) (时光代理人), ZH, Donghua
[204098, tmdb_tv], // Murai in Love (2024) (村井の恋), JP
[235973, tmdb_tv], // Tom and Jerry (2022) (とむとじぇりー), JP
[239779, tmdb_tv], // True Beauty (2024) (여신강림), KR
[240125, tmdb_tv], // Trillion Game (2024) (トリリオンゲーム), JP
[257162, tmdb_tv], // LINK CLICK (2024) (时光代理人), ZH, Live Action
[259140, tmdb_tv], // Ranma 1/2 (2024) (らんま1/2), JP
[262295, tmdb_tv], // Roommates (2024) (戏精宿舍), ZH
[271026, tmdb_tv], // Taisho Era Contact Marriage (2024) (大正偽りブラヰダル~身代わり花嫁と軍服の猛愛), JP
[273190, tmdb_tv], // Ya She/Silent House (2024) (哑舍), ZH
[275695, tmdb_tv], // No Home (2024) (집이 없어), KR
[68854,tmdb_tv], // Kimi ni Todoke (2009) (君に届け), JP
[123542,tmdb_tv], // LINK CLICK (2021) (时光代理人), ZH, Donghua
[204098,tmdb_tv], // Murai in Love (2024) (村井の恋), JP
[235973,tmdb_tv], // Tom and Jerry (2022) (とむとじぇりー), JP
[239779,tmdb_tv], // True Beauty (2024) (여신강림), KR
[240125,tmdb_tv], // Trillion Game (2024) (トリリオンゲーム), JP
[257162,tmdb_tv], // LINK CLICK (2024) (时光代理人), ZH, Live Action
[259140,tmdb_tv], // Ranma 1/2 (2024) (らんま1/2), JP
[262295,tmdb_tv], // Roommates (2024) (戏精宿舍), ZH
[271026,tmdb_tv], // Taisho Era Contact Marriage (2024) (大正偽りブラヰダル~身代わり花嫁と軍服の猛愛), JP
[273190,tmdb_tv], // Ya She/Silent House (2024) (哑舍), ZH
[275695,tmdb_tv], // No Home (2024) (집이 없어), KR
]
def is_id_matches = show_id.find { it[0] == id && it[1] == info.database } != null
def is_id_matches = show_id.find{it[0] == id && it[1] == info.database} != null
// try map TheMovieDB::TV -> tmdbid, AniDB -> anidbid, TheTVDB -> tvdbid
def db_map = [
"TheMovieDB::TV": "tmdbid",
Expand Down
10 changes: 5 additions & 5 deletions modules/medianame.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
def tmdb_tv = "TheMovieDB::TV"
def short_title = [
// Media ID, target name, database
[mid: 68854, title: "From Me to You", src: tmdb_tv],
[mid: 94904, title: "My Next Life as a Villainess", src: tmdb_tv],
[mid: 68854, title: "From Me to You", src: tmdb_tv],
[mid: 94904, title: "My Next Life as a Villainess", src: tmdb_tv],
[mid: 229743, title: "VTuber Legend", src: tmdb_tv],
[mid: 234538, title: "Demon Lord 2099", src: tmdb_tv],
[mid: 237045, title: "Cherry Magic!", src: tmdb_tv],
Expand All @@ -14,7 +14,7 @@

// Replace title from short_title if series_id matches "series" from filebot
// Otherwise, use the original name
def db_name = any { info.database } { id == tmdbid ? "TheMovieDB" : "IMDb" }
def db_name = any {info.database} {id == tmdbid ? "TheMovieDB" : "IMDb"}
def fixed_id = db_name == "IMDb" ? "tt${id}" : id
def name_ = n
short_title.each {
Expand All @@ -23,8 +23,8 @@
}
}

def invalid_chars = ['\\', '/', ':', '*', '?', '"', '<', '>', '|']
def fixed_name = name_.replaceAll(invalid_chars.collect { "\\" + it }.join('|'), '')
def invalid_chars = ['\\','/',':','*','?','"','<','>','|']
def fixed_name = name_.replaceAll(invalid_chars.collect {"\\" + it}.join('|'), '')
// trim . and whitespace at the end
fixed_name = fixed_name.replaceAll(/(\s|\.)*$/, '')
fixed_name
Expand Down
16 changes: 8 additions & 8 deletions modules/r18_checker.groovy
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
// list of possibly R18+ tags
def known_tags = [
"boys' love (bl)", "gay theme", "yaoi", "yuri", "lesbian", "hentai",
"sex", "lgbt", "explicit", "adult animation", "adult content",
"boys' love (bl)","gay theme","yaoi","yuri","lesbian","hentai", "sex",
"lgbt","explicit","adult animation","adult content",
]

def tmdb_tv = "TheMovieDB::TV"
Expand All @@ -12,24 +12,24 @@
def known_titles = [
[271026, tmdb_tv], // Taisho Era Contract Marriage, 2024
[220118, tmdb_tv], // Sazanami Soushi ni Junketsu wo Sasagu, 2023
[ 74180, tmdb_tv], // My Marriage Partner Is My Student, a Cocky Troublemaker, 2017
[74180, tmdb_tv], // My Marriage Partner Is My Student, a Cocky Troublemaker, 2017
]

// List of known titles that might be misclassified as R18+
def override_tag = [
[236530, tmdb_tv] // How I Attended an All-Guy's Mixer, 2024
]

def db_name = any { info.database } { id == tmdbid ? "TheMovieDB" : "IMDb" }
def db_name = any {info.database} {id == tmdbid ? "TheMovieDB" : "IMDb"}
def fixed_id = db_name == "IMDb" ? "tt${id}" : id

// REQUIRES USER TO SET ADDITIONAL PROPERTY ON FILEBOT
// READ: https://www.filebot.net/forums/viewtopic.php?p=58610#p58610
def is_adult = any { info.adult } { false }
def is_adult = any {info.adult} {false}

def is_same_id = known_titles.find { it[0] == fixed_id && it[1] == db_name } != null
def is_adult_override = override_tag.find { it[0] == fixed_id && it[1] == db_name } != null
def is_r18 = info.Keywords.findAll { it in known_tags } || is_same_id || is_adult
def is_same_id = known_titles.find {it[0] == fixed_id && it[1] == db_name} != null
def is_adult_override = override_tag.find {it[0] == fixed_id && it[1] == db_name} != null
def is_r18 = info.Keywords.findAll {it in known_tags} || is_same_id || is_adult

// Apply R18+ tag to the path name
is_r18 = is_adult_override ? false : is_r18
Expand Down
12 changes: 2 additions & 10 deletions modules/releasegroup.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,9 @@
"Tsundere-Raws",
]

def finalGroup = customGroups.find { groupName -> fn.contains(groupName) } ?: ""
def fgr_ = customGroups.find {groupName -> fn.contains(groupName)} ?: ""

def group_ = any {
(fn =~ /^\[(.*?)\]/)[0][1]
} {
finalGroup
} {
group
} {
""
}
def group_ = any {(fn =~ /^\[(.*?)\]/)[0][1]} {fgr_} {group} {""}

group_ ? "[$group_] " : ""
}
35 changes: 15 additions & 20 deletions modules/releasesource.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,43 +3,38 @@
// Platform name is for internal use only, aliases are used to match the filename
["ABEMA"], // https://abema.tv/
["ADN"], // https://animationdigitalnetwork.com
["BILI", "B-Global", "BiliIntl", "B-Site", "BiliCN"], // https://www.bilibili.tv and https://www.bilibili.com
["HIDIVE", "HIDI.WEB-DL"], // https://hidive.com
["IQIYI", "IQ.WEB-DL"], // https://www.iq.com
["LAFTEL", "LFTL"], // https://laftel.tv
["BILI","B-Global","BiliIntl","B-Site","BiliCN"], // https://www.bilibili.tv and https://www.bilibili.com
["HIDIVE","HIDI.WEB-DL"], // https://hidive.com
["IQIYI","IQ.WEB-DL"], // https://www.iq.com
["LAFTEL","LFTL"], // https://laftel.tv
["MW.WEB-DL"], // https://www.mewatch.sg
["NF.WEB-DL", "NF WEB"], // https://www.netflix.com
["NF.WEB-DL","NF WEB"], // https://www.netflix.com
["SHAHID"], // https://shahid.mbc.net
["TVER"], // https://tver.jp
["UNEXT"], // https://video.unext.jp
["WETV"], // https://wetv.vip
["YT.WEB-DL", "YOUTUBE", "YTB"], // https://www.youtube.com
["YT.WEB-DL","YOUTUBE","YTB"], // https://www.youtube.com
]

// List of groups that re-encode or modified even further the video from specific source
def reencode_group = ["ASW", "Judas", "JRx7", "EMBER", "KawaSubs", "GuodongSubs"]
def reencode_group = ["ASW","Judas","JRx7","EMBER","KawaSubs","GuodongSubs"]
// List of groups that directly rip the video from specific source
def release_group = ["Erai-raws", "SubsPlease"]
def release_group = ["Erai-raws","SubsPlease"]
def unlisted_group = any {(fn =~ /^\[(.*?)\]/)[0][1]} {""}

// Find the release source from the custom releases list on filename (fn)
def release_ = any {
def platform = custom_releases.find { idx -> idx.find { known -> fn.lower().contains(known.lower()) } }[0]
def platform = custom_releases.find {idx ->
idx.find {known ->
fn.lower().contains(known.lower())}}[0]
platform = platform.replace(".WEB-DL", "")
platform ? "${platform}.WEB-DL" : ""
} {source} {
reencode_group.find {g_ -> group == g_ || unlisted_group == g_} ? "WEBRip" : ""
} {
} {
source
} {
reencode_group.find { g_ -> group == g_ || unlisted_group == g_ } ? "WEBRip" : ""
} {
def mtag = release_group.find { r_ -> group == r_ || unlisted_group == r_} ? "WEB-DL" : ""
def mtag = release_group.find {r_ -> group == r_ || unlisted_group == r_} ? "WEB-DL" : ""
(source == "Erai-raws" && vcf.upper() == "HEVC") ? "WEBRip" : mtag
} {
vs
} {
""
}
} {vs} {""}

release_ ? "$release_ " : ""
}
8 changes: 4 additions & 4 deletions modules/season.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
episode.special ? 'Specials' : 'Season '+s
}
{
def invalid_chars = ['\\', '/', ':', '*', '?', '"', '<', '>', '|']
def fixed_name = sn.replaceAll(invalid_chars.collect { "\\" + it }.join('|'), '_')
def fixed_title = n.replaceAll(invalid_chars.collect { "\\" + it }.join('|'), '_')
def invalid_chars = ['\\','/',':','*','?','"','<','>','|']
def fixed_name = sn.replaceAll(invalid_chars.collect {"\\" + it}.join('|'), '_')
def fixed_title = n.replaceAll(invalid_chars.collect {"\\" + it}.join('|'), '_')
// if kv contains Series name from fixed_title (partially or fully), then remove it
def kv = fixed_name.contains(fixed_title) ? "" : fixed_name
// Sanitize the season name if it just repeats the "Season" string
kv == 'Season '+ s ? "" : kv ? " - " + kv : ""
}
{"/"}
{"/"}

0 comments on commit bcdfceb

Please sign in to comment.