Skip to content

Commit

Permalink
improve group parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeastLT committed Oct 14, 2023
1 parent ea6ec93 commit 79b01ba
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
Expand Down
14 changes: 13 additions & 1 deletion test/group.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand All @@ -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]";

Expand Down

0 comments on commit 79b01ba

Please sign in to comment.