Skip to content

Commit

Permalink
handle episode in brackets
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeastLT committed Oct 28, 2023
1 parent b0ed4ee commit 7bc5645
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ exports.addDefaults = /** @type Parser */ parser => {
parser.addHandler("episodes", /-\s?\d{1,2}\.(\d{2,3})\s?-/, array(integer));
parser.addHandler("episodes", /(?<=\D|^)(\d{1,3})[. ]?(?:of|из|iz)[. ]?\d{1,3}(?=\D|$)/i, array(integer));
parser.addHandler("episodes", /\b\d{2}[ ._-](\d{2})(?:.F)?\.\w{2,4}$/, array(integer));
parser.addHandler("episodes", /(?<!^)\[(\d{2,3})](?!(?:\.\w{2,4})?$)/, array(integer));

// can be both absolute episode and season+episode in format 101
parser.addHandler("episodes", ({ title, result, matched }) => {
Expand Down
10 changes: 10 additions & 0 deletions test/episode.js
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,16 @@ describe("Parsing episode", () => {
expect(parse(releaseName)).to.deep.include({ season: 3, episode: 5 });
});

it("should detect episode in brackets", () => {
const releaseName = "[KTKJ]_[BLEACH]_[DVDRIP]_[116]_[x264_640x480_aac].mkv";
expect(parse(releaseName)).to.deep.include({ episode: 116 });
});

it("should detect episode in brackets but not years", () => {
const releaseName = "[GM-Team][国漫][绝代双骄][Legendary Twins][2022][08][HEVC][GB][4K].mp4";
expect(parse(releaseName)).to.deep.include({ episode: 8 });
});

xit("should not detect season-episode pattern when it's a date", () => {
const releaseName = "8-6 2006.07.16.avi";
expect(parse(releaseName)).to.deep.include({ season: 8, episode: 6 });
Expand Down

0 comments on commit 7bc5645

Please sign in to comment.