Skip to content

Commit

Permalink
feat: hack for oshi no ki
Browse files Browse the repository at this point in the history
  • Loading branch information
yjl9903 committed Apr 15, 2023
1 parent 7e8b89b commit c4dc40c
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
14 changes: 13 additions & 1 deletion packages/anitomy/src/tokenizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,19 @@ export function tokenize(filename: string, options: AnitomyOptions) {
function validateDelimiterTokens() {
for (let i = 0; i < tokens.length; i++) {
const token = tokens[i];
if (token.category !== TokenCategory.Delimiter) continue;
if (token.category !== TokenCategory.Delimiter) {
// Hack for "【我推的孩子】"
if (token.content === '我推的孩子') {
if (tokens[i - 1]?.content === '【' && tokens[i + 1]?.content === '】') {
tokens[i - 1].category = TokenCategory.Invalid;
tokens[i].content = '【我推的孩子】';
tokens[i].enclosed = false;
tokens[i + 1].category = TokenCategory.Invalid;
}
}
continue;
}

const delimiter = token.content[0];

const prevToken = findPrevToken(tokens, i, TokenFlag.Valid);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ exports[`Lilith-Raws > should parse 13`] = `
"season": undefined,
"source": "WEB-DL",
"subtitles": undefined,
"title": "/ Oshi no Ko",
"title": "【我推的孩子】 / Oshi no Ko",
"type": undefined,
"video": {
"resolution": "1080p",
Expand Down
14 changes: 2 additions & 12 deletions packages/anitomy/test/__snapshots__/tokenizer.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7078,20 +7078,10 @@ exports[`tokenize > should work 37`] = `
"content": " ",
"enclosed": false,
},
{
"category": "Bracket",
"content": "",
"enclosed": true,
},
{
"category": "Unknown",
"content": "我推的孩子",
"enclosed": true,
},
{
"category": "Bracket",
"content": "",
"enclosed": true,
"content": "【我推的孩子】",
"enclosed": false,
},
{
"category": "Delimiter",
Expand Down

0 comments on commit c4dc40c

Please sign in to comment.