Skip to content

Commit

Permalink
parse italian season descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeastLT committed Oct 22, 2024
1 parent d8726b3 commit b98e2ba
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ exports.addDefaults = /** @type Parser */ parser => {

// Episode code
parser.addHandler("episodeCode", /[[(]([a-zA-Z0-9]{8})[\])](?=\.[a-zA-Z0-9]{1,5}$|$)/, uppercase, { remove: true });
parser.addHandler("episodeCode", /\[([A-Z0-9]{8})]/, uppercase, { remove: true });
parser.addHandler("episodeCode", /\[(?=[A-Z]+\d|\d+[A-Z])([A-Z0-9]{8})]/, uppercase, { remove: true });

// Resolution
parser.addHandler("resolution", /\b[([]?4k[)\]]?\b/i, value("4k"), { remove: true });
Expand Down Expand Up @@ -161,11 +161,11 @@ exports.addDefaults = /** @type Parser */ parser => {
parser.addHandler("seasons", /(?:complete\W|seasons?\W|\W|^)((?:s\d{1,2}[., +/\\&-]+)+s\d{1,2}\b)/i, range, { remove: true });
parser.addHandler("seasons", /(?:complete\W|seasons?\W|\W|^)[([]?(s\d{2,}-\d{2,}\b)[)\]]?/i, range, { remove: true });
parser.addHandler("seasons", /(?:complete\W|seasons?\W|\W|^)[([]?(s[1-9]-[2-9]\b)[)\]]?/i, range, { remove: true });
parser.addHandler("seasons", /(?:(?:\bthe\W)?\bcomplete\W)?(?:seasons?|[Сс]езони?|temporadas?)[. ]?[-:]?[. ]?[([]?((?:\d{1,2}[, /\\&]+)+\d{1,2}\b)[)\]]?/i, range, { remove: true });
parser.addHandler("seasons", /(?:(?:\bthe\W)?\bcomplete\W)?(?:seasons|[Сс]езони?|temporadas?)[. ]?[-:]?[. ]?[([]?((?:\d{1,2}[. -]+)+[1-9]\d?\b)[)\]]?/i, range, { remove: true });
parser.addHandler("seasons", /(?:(?:\bthe\W)?\bcomplete\W)?(?:seasons?|[Сс]езони?|temporadas?|stagioni)[. ]?[-:]?[. ]?[([]?((?:\d{1,2}[, /\\&]+)+\d{1,2}\b)[)\]]?/i, range, { remove: true });
parser.addHandler("seasons", /(?:(?:\bthe\W)?\bcomplete\W)?(?:seasons|[Сс]езони?|temporadas?|stagioni)[. ]?[-:]?[. ]?[([]?((?:\d{1,2}[. -]+)+0?[1-9]\d?\b)[)\]]?/i, range, { remove: true });
parser.addHandler("seasons", /(?:(?:\bthe\W)?\bcomplete\W)?season[. ]?[([]?((?:\d{1,2}[. -]+)+[1-9]\d?\b)[)\]]?(?!.*\.\w{2,4}$)/i, range, { remove: true });
parser.addHandler("seasons", /(?:(?:\bthe\W)?\bcomplete\W)?\bseasons?\b[. -]?(\d{1,2}[. -]?(?:to|thru|and|\+|:)[. -]?\d{1,2})\b/i, range, { remove: true });
parser.addHandler("seasons", /(?:(?:\bthe\W)?\bcomplete\W)?(?:saison|seizoen|season|series|temp(?:orada)?):?[. ]?(\d{1,2})/i, array(integer));
parser.addHandler("seasons", /(?:(?:\bthe\W)?\bcomplete\W)?(?:saison|seizoen|stagione|season|series|temp(?:orada)?):?[. ]?(\d{1,2})/i, array(integer));
parser.addHandler("seasons", /(\d{1,2})(?:-?й)?[. _]?(?:[Сс]езон|sez(?:on)?)(?:\W?\D|$)/i, array(integer));
parser.addHandler("seasons", /[Сс]езон:?[. _]?№?(\d{1,2})(?!\d)/i, array(integer));
parser.addHandler("seasons", /(?:\D|^)(\d{1,2})Â?[°ºªa]?[. ]*temporada/i, array(integer), { remove: true });
Expand Down Expand Up @@ -259,7 +259,7 @@ exports.addDefaults = /** @type Parser */ parser => {
parser.addHandler("complete", /\b(?:series|seasons|movies?)\b.*\b(?:complete|collection)\b/i, boolean);
parser.addHandler("complete", /(?:\bthe\W)?\bultimate\b[ .]\bcollection\b/i, boolean, { skipIfAlreadyFound: false });
parser.addHandler("complete", /\bcollection\b.*\b(?:set|pack|movies)\b/i, boolean);
parser.addHandler("complete", /\bcollection\b/i, boolean, { skipFromTitle: true });
parser.addHandler("complete", /\b(collection|completa)\b/i, boolean, { skipFromTitle: true });
parser.addHandler("complete", /duology|trilogy|quadr[oi]logy|tetralogy|pentalogy|hexalogy|heptalogy|anthology|saga/i, boolean, { skipIfAlreadyFound: false });

// Language
Expand Down
5 changes: 5 additions & 0 deletions test/complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ describe("Parsing complete collection", () => {
expect(parse(releaseName)).to.deep.include({ complete: true });
});

it("should detect italian complete", () => {
const releaseName = "Inganno - Miniserie (2024) [COMPLETA] SD H264 ITA AAC-UBi";
expect(parse(releaseName)).to.deep.include({ complete: true });
});

it("should not remove collection from title", () => {
const releaseName = "[Erai-raws] Ninja Collection - 05 [720p][Multiple Subtitle].mkv";
expect(parse(releaseName)).to.deep.include({ title: "Ninja Collection", complete: true });
Expand Down
10 changes: 10 additions & 0 deletions test/episodeCode.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,14 @@ describe("Parsing episode code", () => {
const releaseName = "Lost.[Perdidos].6x05.HDTV.XviD.[www.DivxTotaL.com].avi";
expect(parse(releaseName)).to.not.have.property("episodeCode");
});

it("should not detect episode code when it's a word", () => {
const releaseName = "Lost - Stagioni 01-06 (2004-2010) [COMPLETA] SD x264 AAC ITA SUB ITA";
expect(parse(releaseName)).to.not.have.property("episodeCode");
});

it("should not detect episode code when it's only numbers", () => {
const releaseName = "The voice of Holland S05E08 [20141017] NL Battles 1.mp4";
expect(parse(releaseName)).to.not.have.property("episodeCode");
});
});
10 changes: 10 additions & 0 deletions test/season.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,16 @@ describe("Parsing season", () => {
expect(parse(releaseName)).to.deep.include({ season: 22 });
});

it("should detect italian season word", () => {
const releaseName = "Nobody Wants This - Stagione 1 (2024) [COMPLETA] 720p H264 ITA AAC 2.0-Zer0landia";
expect(parse(releaseName)).to.deep.include({ season: 1 });
});

it("should detect italian season range", () => {
const releaseName = "Red Oaks - Stagioni 01-03 (2014-2017) [COMPLETA] SD x264 AAC ITA SUB ITA - mkeagle3";
expect(parse(releaseName)).to.deep.include({ seasons: [1, 2, 3] });
});

it("should not detect season when it's part of the name", () => {
const releaseName = "Ranma-12-86.mp4";
expect(parse(releaseName)).to.not.have.property("season");
Expand Down

0 comments on commit b98e2ba

Please sign in to comment.