From b98e2ba2fb64fd5fa1c34c620bd9050bbc2e271d Mon Sep 17 00:00:00 2001 From: TheBeastLT Date: Tue, 22 Oct 2024 19:48:47 +0300 Subject: [PATCH] parse italian season descriptions --- src/handlers.js | 10 +++++----- test/complete.js | 5 +++++ test/episodeCode.js | 10 ++++++++++ test/season.js | 10 ++++++++++ 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/src/handlers.js b/src/handlers.js index 8ede657..7f0a18a 100644 --- a/src/handlers.js +++ b/src/handlers.js @@ -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 }); @@ -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 }); @@ -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 diff --git a/test/complete.js b/test/complete.js index b19d1b4..46cca25 100644 --- a/test/complete.js +++ b/test/complete.js @@ -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 }); diff --git a/test/episodeCode.js b/test/episodeCode.js index 499a1f9..be807c1 100644 --- a/test/episodeCode.js +++ b/test/episodeCode.js @@ -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"); + }); }); diff --git a/test/season.js b/test/season.js index c6478db..913edfe 100644 --- a/test/season.js +++ b/test/season.js @@ -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");