Skip to content

Commit

Permalink
better language handlers for chinese and malay
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBeastLT committed Oct 31, 2023
1 parent 5691af5 commit 0224089
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
7 changes: 4 additions & 3 deletions src/handlers.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,11 @@ exports.addDefaults = /** @type Parser */ parser => {
parser.addHandler("languages", /\b(japanese|japon[eê]s)\b/i, uniqConcat(value("japanese")), { skipIfFirst: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(?:KOR|kor[ .-]?sub)\b/i, uniqConcat(value("korean")), { skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(korean|coreano)\b/i, uniqConcat(value("korean")), { skipIfFirst: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(?:traditional\W*chinese|chinese\W*traditional)\b/i, uniqConcat(value("taiwanese")), { skipIfAlreadyFound: false, remove: true });
parser.addHandler("languages", /\b(?:traditional\W*chinese|chinese\W*traditional)(?:\Wchi)?\b/i, uniqConcat(value("taiwanese")), { skipIfAlreadyFound: false, remove: true });
parser.addHandler("languages", /\bzh-hant\b/i, uniqConcat(value("taiwanese")), { skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(?:mand[ae]rin|ch[sn])\b/i, uniqConcat(value("chinese")), { skipIfAlreadyFound: false });
parser.addHandler("languages", /\bCH[IT]\b/, uniqConcat(value("chinese")), { skipFromTitle: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(chinese|chin[eê]s)\b/i, uniqConcat(value("chinese")), { skipIfFirst: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(chinese|chin[eê]s|chi)\b/i, uniqConcat(value("chinese")), { skipIfFirst: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\bzh-hans\b/i, uniqConcat(value("chinese")), { skipIfAlreadyFound: false });
parser.addHandler("languages", /\bFR(?:ench|a|e|anc[eê]s)?\b/i, uniqConcat(value("french")), { skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(Truefrench|VF[FI])\b/i, uniqConcat(value("french")), { skipIfAlreadyFound: false });
Expand Down Expand Up @@ -347,10 +347,11 @@ exports.addDefaults = /** @type Parser */ parser => {
parser.addHandler("languages", /\barab.*(?:audio|lang(?:uage)?|sub(?:s|titles?)?)\b/i, uniqConcat(value("arabic")), { skipFromTitle: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\bar(?=\.(?:ass|ssa|srt|sub|idx)$)/i, uniqConcat(value("arabic")), { skipFromTitle: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(?:turkish|tur(?:co)?)\b/i, uniqConcat(value("turkish")), { skipFromTitle: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\bvietnamese\b|\b(?:vie|may)(?=[\]_)]?\.\w{2,4}$)/i, uniqConcat(value("vietnamese")), { skipFromTitle: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\bvietnamese\b|\bvie(?=[\]_)]?\.\w{2,4}$)/i, uniqConcat(value("vietnamese")), { skipFromTitle: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\bind(?:onesian)?\b/i, uniqConcat(value("indonesian")), { skipFromTitle: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(thai|tailand[eê]s)\b/i, uniqConcat(value("thai")), { skipIfFirst: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(THA|tha)\b/, uniqConcat(value("thai")), { skipFromTitle: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(?:malay|may(?=[\]_)]?\.\w{2,4}$)|(?<=subs?\([a-z,]+)may)\b/i, uniqConcat(value("malay")), { skipIfFirst: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\bheb(?:rew|raico)?\b/i, uniqConcat(value("hebrew")), { skipFromTitle: true, skipIfAlreadyFound: false });
parser.addHandler("languages", /\b(persian|persa)\b/i, uniqConcat(value("persian")), { skipFromTitle: true, skipIfAlreadyFound: false });

Expand Down
9 changes: 7 additions & 2 deletions test/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -530,9 +530,14 @@ describe("Parsing language", () => {
expect(parse(releaseName)).to.deep.include({ languages: ["french", "german", "arabic"] });
});

it("Subs(chi,eng,ind,kor,may,tha,vie).srt", () => {
const releaseName = "Subs(chi,ind,kor,may,tha,vie).srt";

expect(parse(releaseName)).to.deep.include({ languages: ["korean", "chinese", "vietnamese", "indonesian", "thai", "malay"] });
});

it("Miami.Bici.2020.1080p.NETFLIX.WEB-DL.DDP5.1.H.264.EN-ROSub-ExtremlymTorrents", () => {
const releaseName = "Miami.Bici.2020.1080p.NETFLIX.WEB-DL.DDP5.1.H.264.EN-ROSub-ExtremlymTorrents";

expect(parse(releaseName)).to.deep.include({ languages: ["english", "romanian"] });
});

Expand Down Expand Up @@ -973,7 +978,7 @@ describe("Parsing language", () => {

it("Subs/Dear.S01E05.WEBRip.x265-ION265/25_may.srt", () => {
const releaseName = "Subs/Dear.S01E05.WEBRip.x265-ION265/25_may.srt";
expect(parse(releaseName)).to.deep.include({ languages: ["vietnamese"] });
expect(parse(releaseName)).to.deep.include({ languages: ["malay"] });
});

it("Midnight.Diner.Tokyo.Stories.S02E10.WEBRip.x264-ION10/14_Indonesian.srt", () => {
Expand Down

0 comments on commit 0224089

Please sign in to comment.