Skip to content

Commit

Permalink
Fix non-sequence parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
the1812 committed Dec 25, 2023
1 parent 3c216d9 commit 79b2b5c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "touhou-tagger",
"version": "1.11.0",
"version": "1.11.1",
"description": "从 THBWiki 自动填写东方 Project CD 曲目信息.",
"main": "dist/core/index.js",
"bin": {
Expand Down
10 changes: 10 additions & 0 deletions src/core/metadata/thb-wiki/thb-wiki.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,10 @@ export class ThbWiki extends MetadataSource {
}
}
}
const isSequence = (data: Element) => {
return [...data.childNodes].some(node => isNodeAnElement(node, 'br'))
}

const label = trackInfoRow.querySelector('.label').textContent.trim()
const rawData = trackInfoRow.querySelector('.text') as HTMLElement
const actions: { [infoName: string]: (data: HTMLElement) => TrackParseInfo } = {
Expand All @@ -151,6 +155,9 @@ export class ThbWiki extends MetadataSource {
作词: defaultInfoParser('lyricists'),
配音: data => {
const name = 'voices'
if (!isSequence(data)) {
return defaultInfoParser(name)(data)
}
const slices = splitChildNodesByBr(data)
const rows = slices.flatMap(it => {
const anchors = it.filter((a): a is HTMLAnchorElement => isNodeAnElement(a, 'a'))
Expand All @@ -177,6 +184,9 @@ export class ThbWiki extends MetadataSource {
},
演奏: data => {
const name = 'instruments'
if (!isSequence(data)) {
return defaultInfoParser(name)(data)
}
const slices = splitChildNodesByBr(data)
const rows = slices
.map(it => {
Expand Down

0 comments on commit 79b2b5c

Please sign in to comment.