Skip to content

Commit dff7654

Browse files
committed
improve anime episode parsing when title contains numbers
1 parent d29c6c7 commit dff7654

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/handlers.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ exports.addDefaults = /** @type Parser */ parser => {
232232
const middleTitle = title.slice(startIndex, endIndex);
233233

234234
// try to match the episode inside the title with a separator, if not found include the start of the title as well
235-
const matches = beginningTitle.match(/(?<!movie\W*|film\W*|^)(?:[ .]+-[ .]+|[([][ .]*)(\d{1,4})(?:a|b|v\d)?(?:\W|$)(?!movie|film)/i) ||
235+
const matches = Array.from(beginningTitle.matchAll(/(?<!movie\W*|film\W*|^)(?:[ .]+-[ .]+|[([][ .]*)(\d{1,4})(?:a|b|v\d|\.\d)?(?:\W|$)(?!movie|film|\d+)/gi)).pop() ||
236236
middleTitle.match(/^(?:[([-][ .]?)?(\d{1,4})(?:a|b|v\d)?(?:\W|$)(?!movie|film)/i);
237237

238238
if (matches) {

test/episode.js

+5
Original file line numberDiff line numberDiff line change
@@ -674,6 +674,11 @@ describe("Parsing episode", () => {
674674
expect(parse(releaseName)).to.deep.include({ episode: 35 });
675675
});
676676

677+
it("should detect anime episode with hyphen number in title", () => {
678+
const releaseName = "[SubsPlease] Fairy Tail - 100 Years Quest - 05 (1080p) [1107F3A9].mkv";
679+
expect(parse(releaseName)).to.deep.include({ episode: 5 });
680+
});
681+
677682
it("should detect anime episode recap episode", () => {
678683
const releaseName = "[KH] Sword Art Online II - 14.5 - Debriefing.mkv";
679684
expect(parse(releaseName)).to.deep.include({ episode: 14 });

0 commit comments

Comments
 (0)