From fa99150a261bc858501155880c5a871a0bb958ac Mon Sep 17 00:00:00 2001 From: Natsu Tadama Date: Sat, 14 Dec 2024 21:35:03 +0700 Subject: [PATCH] Revert "Reformat scripts to take lesser storage after "compile"" This reverts commit bcdfceb29174f69ddc569ea8119928529330143e. --- compiler.py | 4 ++-- modules/common_movie.groovy | 12 +++++------- modules/common_tv.groovy | 8 +++----- modules/filename_tv.groovy | 9 +++------ modules/filepath.groovy | 10 +++------- modules/filespec.groovy | 10 +++++----- modules/forceshowid_tv.groovy | 26 +++++++++++++------------- modules/medianame.groovy | 10 +++++----- modules/r18_checker.groovy | 16 ++++++++-------- modules/releasegroup.groovy | 12 ++++++++++-- modules/releasesource.groovy | 35 ++++++++++++++++++++--------------- modules/season.groovy | 8 ++++---- 12 files changed, 81 insertions(+), 79 deletions(-) diff --git a/compiler.py b/compiler.py index 1ab549e..3cb8a7b 100755 --- a/compiler.py +++ b/compiler.py @@ -176,9 +176,9 @@ 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*;", "["), (r";\s*\]", "]"), (r",\s+\)", ")"), (r",\s*\]", "]"), (r"(\s)*", "\\1"), (r"->;", "->"), (r"->", "-> "), - (r"\r", ""), (r"\n", ""), (r"\|\|;", "||"), (r"&&;", "&&"), (r";\.", ".") + (r"\r", ""), (r"\n", ""), ] # fmt: on diff --git a/modules/common_movie.groovy b/modules/common_movie.groovy index eb9b59f..abb7c10 100644 --- a/modules/common_movie.groovy +++ b/modules/common_movie.groovy @@ -2,11 +2,9 @@ @./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.contains("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 =~ /Animation/) // Categorized path is_anime ? "Anime Movies/" : "Movies/" } @@ -16,10 +14,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 \ No newline at end of file diff --git a/modules/common_tv.groovy b/modules/common_tv.groovy index 4a1b04b..4fb8928 100644 --- a/modules/common_tv.groovy +++ b/modules/common_tv.groovy @@ -2,11 +2,9 @@ @./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.contains("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 =~ /Animation/) // Categorized path is_anime ? "Anime/" : "TV Series/" } diff --git a/modules/filename_tv.groovy b/modules/filename_tv.groovy index 72c0489..9fde0c8 100644 --- a/modules/filename_tv.groovy +++ b/modules/filename_tv.groovy @@ -2,12 +2,9 @@ @./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 diff --git a/modules/filepath.groovy b/modules/filepath.groovy index 7fdf65f..68b3acf 100644 --- a/modules/filepath.groovy +++ b/modules/filepath.groovy @@ -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") @@ -9,8 +9,7 @@ def mntp = "/run/media/${user_}" //! OVERRIDE THIS PATH IF NEEDED, ELSE, BLANK IT ("") - // def override = is_windows ? "H:/" : "$mntp/Videos" - def override = "" + def override = is_windows ? "H:/" : "$mntp/Videos" def mounts = [ [label: "Books", winmnt: "F:/", linmnt: "$mntp/Books"], @@ -20,10 +19,7 @@ [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().path + def guess = (mounts.collect { it[is_windows ? "winmnt" : "linmnt"] as File }.sort { first, second -> first.exists() <=> second.exists() ?: first.diskSpace <=> second.diskSpace }).last() def final_ = override ?: guess "$final_/" } \ No newline at end of file diff --git a/modules/filespec.groovy b/modules/filespec.groovy index 38b1da2..155dc9d 100644 --- a/modules/filespec.groovy +++ b/modules/filespec.groovy @@ -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 ? " ...)" : ")") : "" @@ -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, "") } diff --git a/modules/forceshowid_tv.groovy b/modules/forceshowid_tv.groovy index 1e5dfb1..48c7ac1 100644 --- a/modules/forceshowid_tv.groovy +++ b/modules/forceshowid_tv.groovy @@ -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", diff --git a/modules/medianame.groovy b/modules/medianame.groovy index 91096e6..12147fd 100644 --- a/modules/medianame.groovy +++ b/modules/medianame.groovy @@ -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], @@ -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 { @@ -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 diff --git a/modules/r18_checker.groovy b/modules/r18_checker.groovy index 2a50bca..ee0b9b1 100644 --- a/modules/r18_checker.groovy +++ b/modules/r18_checker.groovy @@ -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" @@ -12,7 +12,7 @@ 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+ @@ -20,16 +20,16 @@ [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 diff --git a/modules/releasegroup.groovy b/modules/releasegroup.groovy index cc96356..4c6bd7e 100644 --- a/modules/releasegroup.groovy +++ b/modules/releasegroup.groovy @@ -8,9 +8,17 @@ "Tsundere-Raws", ] - def fgr_ = customGroups.find {groupName -> fn.contains(groupName)} ?: "" + def finalGroup = customGroups.find { groupName -> fn.contains(groupName) } ?: "" - def group_ = any {(fn =~ /^\[(.*?)\]/)[0][1]} {fgr_} {group} {""} + def group_ = any { + (fn =~ /^\[(.*?)\]/)[0][1] + } { + finalGroup + } { + group + } { + "" + } group_ ? "[$group_] " : "" } diff --git a/modules/releasesource.groovy b/modules/releasesource.groovy index 181172c..29587e8 100644 --- a/modules/releasesource.groovy +++ b/modules/releasesource.groovy @@ -3,38 +3,43 @@ // 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" : "" } { - def mtag = release_group.find {r_ -> group == r_ || unlisted_group == r_} ? "WEB-DL" : "" + } { + source + } { + reencode_group.find { g_ -> group == g_ || unlisted_group == g_ } ? "WEBRip" : "" + } { + 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_ " : "" } diff --git a/modules/season.groovy b/modules/season.groovy index 0f55213..fc6bfd7 100644 --- a/modules/season.groovy +++ b/modules/season.groovy @@ -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 : "" } -{"/"} +{"/"} \ No newline at end of file