From 79b01ba8cd480314d2ac7de0772b022451e86d58 Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Sat, 14 Oct 2023 22:56:28 +0300 Subject: [PATCH] improve group parsing --- src/handlers.js | 3 ++- test/group.js | 14 +++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/handlers.js b/src/handlers.js index 7c59567..3dd4c3c 100644 --- a/src/handlers.js +++ b/src/handlers.js @@ -130,7 +130,7 @@ exports.addDefaults = /** @type Parser */ parser => { parser.addHandler("audio", /\bQ?AAC(?:[. ]?2[. ]0|x2)?\b/, value("aac"), { remove: true }); // Group - parser.addHandler("group", /- ?(?!\d+$|S\d+|\d+x|ep?\d+|[^[]+]$)([^\-. []+[^\-. [\d][^\-. []*)(?:\[[\w.-]+])?(?=\.\w{2,4}$|$)/i, { remove: true }); + parser.addHandler("group", /- ?(?!\d+$|S\d+|\d+x|ep?\d+|[^[]+]$)([^\-. []+[^\-. [)\]\d][^\-. [)\]]*)(?:\[[\w.-]+])?(?=\.\w{2,4}$|$)/i, { remove: true }); // Container parser.addHandler("container", /\.?[[(]?\b(MKV|AVI|MP4|WMV|MPG|MPEG)\b[\])]?/i, lowercase); @@ -369,6 +369,7 @@ exports.addDefaults = /** @type Parser */ parser => { // Group parser.addHandler("group", /^\[([^[\]]+)]/); + parser.addHandler("group", /\(([\w-]+)\)(?:$|\.\w{2,4}$)/); parser.addHandler("group", ({ result, matched }) => { if (matched.group && matched.group.rawMatch.match(/^\[.+]$/)) { const endIndex = matched.group && matched.group.matchIndex + matched.group.rawMatch.length || 0; diff --git a/test/group.js b/test/group.js index c080b5a..ccbc39d 100644 --- a/test/group.js +++ b/test/group.js @@ -87,11 +87,17 @@ describe("Parsing group", () => { }); it("should detect anime group in brackets with spaces", () => { - const releaseName = "[KNK E MMS Fansubs] Nisekoi - 20 Final [PT-BR]"; + const releaseName = "[KNK E MMS Fansubs] Nisekoi - 20 Final [PT-BR].mkv"; expect(parse(releaseName)).to.deep.include({ group: "KNK E MMS Fansubs" }); }); + it("should detect anime group in brackets when bracket part exist at the end", () => { + const releaseName = "[ToonsHub] JUJUTSU KAISEN - S02E01 (Japanese 2160p x264 AAC) [Multi-Subs].mkv"; + + expect(parse(releaseName)).to.deep.include({ group: "ToonsHub" }); + }); + it("should detect anime group in brackets with a link", () => { const releaseName = "[HD-ELITE.NET] - The.Art.Of.The.Steal.2014.DVDRip.XviD.Dual.Aud"; @@ -104,6 +110,12 @@ describe("Parsing group", () => { expect(parse(releaseName)).to.deep.include({ group: "BladeBDP" }); }); + it("should detect group in parenthesis", () => { + const releaseName = "Jujutsu Kaisen S02E01 2160p WEB H.265 AAC -Tsundere-Raws (B-Global).mkv"; + + expect(parse(releaseName)).to.deep.include({ group: "B-Global" }); + }); + it("should not detect brackets group when it contains other parsed parameters", () => { const releaseName = "[DVD-RIP] Kaavalan (2011) Sruthi XVID [700Mb] [TCHellRaiser]";