Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: the1812/Touhou-Tagger
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.8.0
Choose a base ref
...
head repository: the1812/Touhou-Tagger
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: master
Choose a head ref

Commits on Jul 29, 2023

  1. Fix instruments split

    the1812 committed Jul 29, 2023
    Copy the full SHA
    fa6006e View commit details

Commits on Aug 4, 2023

  1. Copy the full SHA
    8b5b9fb View commit details
  2. Add eslint

    the1812 committed Aug 4, 2023
    Copy the full SHA
    848eb73 View commit details
  3. Lint all source files

    the1812 committed Aug 4, 2023
    Copy the full SHA
    a16e874 View commit details
  4. Copy the full SHA
    b6410fe View commit details

Commits on Aug 5, 2023

  1. Add simplifyMetadataInfo API

    the1812 committed Aug 5, 2023
    Copy the full SHA
    23b270a View commit details
  2. Copy the full SHA
    808f8c3 View commit details
  3. Add batch dump support

    the1812 committed Aug 5, 2023
    Copy the full SHA
    b0387bb View commit details
  4. Update README

    the1812 committed Aug 5, 2023
    Copy the full SHA
    720e0b7 View commit details
  5. Update version number

    the1812 committed Aug 5, 2023
    Copy the full SHA
    8fd0af9 View commit details

Commits on Aug 6, 2023

  1. Update example image

    the1812 committed Aug 6, 2023
    Copy the full SHA
    c431da8 View commit details

Commits on Aug 30, 2023

  1. Copy the full SHA
    f315a16 View commit details

Commits on Sep 1, 2023

  1. Copy the full SHA
    8cc22fa View commit details

Commits on Sep 3, 2023

  1. Fix resize params

    the1812 committed Sep 3, 2023
    Copy the full SHA
    26045c2 View commit details
  2. Update version number

    the1812 committed Sep 3, 2023
    Copy the full SHA
    d866a18 View commit details

Commits on Nov 28, 2023

  1. Change jsdom to linkedom

    the1812 committed Nov 28, 2023
    Copy the full SHA
    20de48b View commit details
  2. Update version number

    the1812 committed Nov 28, 2023
    Copy the full SHA
    d30b5da View commit details

Commits on Dec 11, 2023

  1. Copy the full SHA
    da50f3f View commit details

Commits on Dec 12, 2023

  1. Add albumOptions

    the1812 committed Dec 12, 2023
    Copy the full SHA
    a5a5a00 View commit details
  2. Copy the full SHA
    1b51387 View commit details
  3. Refactor fs calls to async

    the1812 committed Dec 12, 2023
    Copy the full SHA
    8907340 View commit details

Commits on Dec 13, 2023

  1. Replace map + flat to flatMap

    the1812 committed Dec 13, 2023
    Copy the full SHA
    e0f75e0 View commit details
  2. Update version number

    the1812 committed Dec 13, 2023
    Copy the full SHA
    4b61962 View commit details

Commits on Dec 14, 2023

  1. Refactor cli options

    the1812 committed Dec 14, 2023
    Copy the full SHA
    1a59d5e View commit details
  2. Fix albumOptions load

    the1812 committed Dec 14, 2023
    Copy the full SHA
    3ba51d0 View commit details

Commits on Dec 15, 2023

  1. Copy the full SHA
    91cedb0 View commit details
  2. Refactor doujin-meta source

    the1812 committed Dec 15, 2023
    Copy the full SHA
    9a6748c View commit details
  3. Fix characters not escaped

    the1812 committed Dec 15, 2023
    Copy the full SHA
    f049816 View commit details

Commits on Dec 16, 2023

  1. Copy the full SHA
    90934a8 View commit details
  2. Copy the full SHA
    7fb13a2 View commit details
  3. Fix NaN in album year

    the1812 committed Dec 16, 2023
    Copy the full SHA
    975f0b1 View commit details
  4. Update README

    the1812 committed Dec 16, 2023
    Copy the full SHA
    a945705 View commit details
  5. Copy the full SHA
    35d7692 View commit details
  6. Update albumArtists altNames

    the1812 committed Dec 16, 2023
    Copy the full SHA
    89240ee View commit details

Commits on Dec 20, 2023

  1. Update alt names

    the1812 committed Dec 20, 2023
    Copy the full SHA
    10a6eab View commit details
  2. Improve numbers plugin

    the1812 committed Dec 20, 2023
    Copy the full SHA
    3c216d9 View commit details

Commits on Dec 25, 2023

  1. Fix non-sequence parsing

    the1812 committed Dec 25, 2023
    Copy the full SHA
    79b2b5c View commit details

Commits on Dec 28, 2023

  1. Update README.md

    the1812 authored Dec 28, 2023
    Copy the full SHA
    053eaa5 View commit details

Commits on Jan 5, 2024

  1. Copy the full SHA
    797b27c View commit details

Commits on Jan 10, 2024

  1. Ignore local json album hint

    the1812 committed Jan 10, 2024
    Copy the full SHA
    1eb0d9e View commit details

Commits on Jan 14, 2024

  1. Update alt names

    the1812 committed Jan 14, 2024
    Copy the full SHA
    2670046 View commit details

Commits on Feb 29, 2024

  1. Upgrade dependencies

    the1812 committed Feb 29, 2024
    Copy the full SHA
    d9a7f42 View commit details

Commits on May 9, 2024

  1. Update alt names

    the1812 committed May 9, 2024
    Copy the full SHA
    78c83f5 View commit details

Commits on Dec 11, 2024

  1. Improve debug info

    the1812 committed Dec 11, 2024
    Copy the full SHA
    fc29c5d View commit details
  2. Upgrade axios

    the1812 committed Dec 11, 2024
    Copy the full SHA
    c57268a View commit details

Commits on Jan 26, 2025

  1. Update THBWiki cache host

    the1812 committed Jan 26, 2025
    Copy the full SHA
    255abc3 View commit details
  2. Upgrade pnpm setup action

    the1812 committed Jan 26, 2025
    Copy the full SHA
    beb6598 View commit details

Commits on Feb 15, 2025

  1. Upgrade to pnpm 10

    the1812 committed Feb 15, 2025
    Copy the full SHA
    c139a85 View commit details
  2. Use THBWiki cache as default

    the1812 committed Feb 15, 2025
    Copy the full SHA
    43d7478 View commit details
  3. Update alt names

    the1812 committed Feb 15, 2025
    Copy the full SHA
    5b64792 View commit details
Showing with 4,357 additions and 2,133 deletions.
  1. +4 −0 .eslintignore
  2. +24 −0 .eslintrc.cjs
  3. +1 −2 .github/workflows/npmpublish.yml
  4. +13 −1 .vscode/settings.json
  5. +0 −15 .vscode/tasks.json
  6. +104 −102 README.md
  7. BIN after-files.jpg
  8. BIN after.jpg
  9. BIN before-files.jpg
  10. BIN before.jpg
  11. BIN example.jpg
  12. +32 −0 logo.svg
  13. +26 −15 package.json
  14. +2,963 −1,185 pnpm-lock.yaml
  15. +51 −0 src/cli/album-options.ts
  16. +74 −19 src/cli/batch.ts
  17. +14 −0 src/cli/command-base.ts
  18. +1 −1 src/cli/config-file.ts
  19. +20 −10 src/cli/default-album-name.ts
  20. +0 −87 src/cli/dump.ts
  21. +94 −0 src/cli/dumper.ts
  22. +8 −0 src/cli/helper.ts
  23. +3 −1 src/cli/index.ts
  24. +168 −144 src/cli/options.ts
  25. +13 −0 src/cli/run-dumper.ts
  26. +7 −6 src/cli/run-tagger.ts
  27. +71 −50 src/cli/tagger.ts
  28. +1 −1 src/core/core-config.ts
  29. +1 −1 src/core/debug.ts
  30. +1 −1 src/core/imageinfo.d.ts
  31. +1 −1 src/core/index.ts
  32. +12 −0 src/core/metadata/alt-names.ts
  33. +37 −97 src/core/metadata/doujin-meta/doujin-meta.ts
  34. +0 −27 src/core/metadata/local-json/common-fields.ts
  35. +0 −32 src/core/metadata/local-json/cover.ts
  36. +0 −21 src/core/metadata/local-json/infer-number.ts
  37. +11 −35 src/core/metadata/local-json/local-json.ts
  38. +0 −10 src/core/metadata/local-json/omit-artists.ts
  39. +20 −18 src/core/metadata/local-mp3/local-mp3.ts
  40. +2 −1 src/core/metadata/metadata-source.ts
  41. +3 −7 src/core/metadata/{local-json → normalize}/alt-names.ts
  42. +23 −0 src/core/metadata/normalize/artists.ts
  43. +65 −0 src/core/metadata/normalize/common-fields.ts
  44. +19 −0 src/core/metadata/normalize/cover.ts
  45. +72 −0 src/core/metadata/normalize/normalize.ts
  46. +52 −0 src/core/metadata/normalize/number.ts
  47. +3 −8 src/core/metadata/source-mappings.ts
  48. +49 −28 src/core/metadata/thb-wiki/lyrics/lyric-parser.ts
  49. +30 −23 src/core/metadata/thb-wiki/lyrics/thb-wiki-lyrics.ts
  50. +154 −106 src/core/metadata/thb-wiki/thb-wiki.ts
  51. +1 −0 src/core/node-id3.d.ts
  52. +2 −2 src/core/proxy.ts
  53. +1 −1 src/core/reader/flac/flac-reader.ts
  54. +7 −5 src/core/reader/metadata-reader.ts
  55. +9 −8 src/core/reader/mp3/mp3-reader.ts
  56. +10 −3 src/core/writer/flac/flac-writer.ts
  57. +55 −37 src/core/writer/image-compress.ts
  58. +8 −6 src/core/writer/metadata-writer.ts
  59. +13 −12 src/core/writer/mp3/mp3-writer.ts
  60. +4 −4 src/core/writer/writer-mappings.ts
4 changes: 4 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
dist/
node_modules/
test-files/
patches/
24 changes: 24 additions & 0 deletions .eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
module.exports = {
extends: ['@the1812/eslint-config'],
rules: {
'class-methods-use-this': 'off',
},
overrides: [
{
files: ['*-mappings.ts'],
rules: {
'@typescript-eslint/naming-convention': [
'error',
{
selector: 'property',
format: ['strictCamelCase', 'StrictPascalCase'],
filter: {
regex: '[-/]|^[.]',
match: false,
},
},
],
},
},
],
}
3 changes: 1 addition & 2 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
@@ -17,9 +17,8 @@ jobs:
with:
node-version: 18
registry-url: https://registry.npmjs.org/
- uses: pnpm/action-setup@v2.2.4
- uses: pnpm/action-setup@v4
with:
version: ^8.6.5
run_install: true
- run: pnpm build
- run: npm publish
14 changes: 13 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -6,17 +6,23 @@
"Doujin",
"doujininfo",
"flac",
"formatversion",
"imageinfo",
"linkedom",
"Matthiola",
"metadatas",
"mozjpeg",
"musicgenres",
"ogmusic",
"opensearch",
"ORIGINALYEAR",
"postprocess",
"promisify",
"squoosh",
"STREAMINFO",
"thbwiki",
"thtag",
"thwiki",
"TLMC",
"touhou",
"TRACKNUMBER",
@@ -25,5 +31,11 @@
"Violetium",
"Vorbis",
"wikitable"
]
],
"[javascript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
},
"[typescript]": {
"editor.defaultFormatter": "dbaeumer.vscode-eslint"
}
}
15 changes: 0 additions & 15 deletions .vscode/tasks.json

This file was deleted.

206 changes: 104 additions & 102 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Touhou Tagger

<div align="center">
<img src="./logo.svg" height="300" />
</div>

[THBWiki](http://thwiki.cc/首页) 自动填写东方 Project CD 曲目信息.

支持的曲目信息包括:
@@ -17,6 +22,10 @@
- 发布年份
- 封面图片

<div align="center">
<img src="./example.jpg" width="1200" />
</div>

## 安装 / 更新
需要事先装有 [Node.js](https://nodejs.org/en/)[pnpm](https://pnpm.io/installation), 然后使用以下命令来安装此工具:
```powershell
@@ -34,21 +43,6 @@ thtag

如果最后输入的名称没有**精确匹配**的专辑(**精确匹配**在 THBWiki 中表现为输入到搜索框回车能直接跳转到词条), 则会列出以此名称在 THBWiki 中的搜索结果, 可以继续选择一项作为专辑信息. (有精确匹配的话会直接开始下载专辑信息)

<details><summary><strong>图片示例</strong></summary>
<div>
<img src="./before-files.jpg" alt="example" width="800">
</div>
<div>
<img src="./before.jpg" alt="example" width="400">
</div>
<div>
<img src="./after-files.jpg" alt="example" width="800">
</div>
<div>
<img src="./after.jpg" alt="example" width="400">
</div>
</details>

## 选项
### 保存封面为单独的文件
文件名为 `cover`, 类型取决于 THBWiki 上的资源
@@ -76,7 +70,7 @@ thtag --comment-language eng
### 自动压缩封面图片
`可自动保存的选项`

可以设置当封面图片达到一定大小时, 自动进行压缩后再写入音乐文件中, 这有助于减少音乐文件的体积. 自动压缩**不会**作用于通过 `--cover` 选项保存的单独文件, 结合 `--cover` 可以做到写入较小体积的封面, 同时保存无损的原图.
可以设置当封面图片达到一定大小时, 自动进行压缩 (使用 [MozJPEG](https://github.com/mozilla/mozjpeg)) 后再写入音乐文件中, 这有助于减少音乐文件的体积. 自动压缩**不会**作用于通过 `--cover` 选项保存的单独文件, 结合 `--cover` 可以做到写入较小体积的封面, 同时保存无损的原图.

参数为数字, 单位为 MB, 设置为 `0` 时关闭此功能 (默认为 `0`). 下面的例子设置了当封面超过 2MB 时, 使用自动压缩.

@@ -88,7 +82,7 @@ thtag -ccs 2
thtag --cover-compress-size 2
```

此外, 还可以设置压缩的最大边长, 单位为 px, 设置为 `0` 时关闭此功能 (默认为 `0`).
此外, 还可以设置压缩的最大边长 (需要当大小达到上面的 `--cover-compress-size` 设置时才会一同生效), 单位为 px, 设置为 `0` 时关闭此功能 (默认为 `0`).
当封面的任意边长超过设定值时能够自动进行缩放. 下面的例子设置了当封面边长超过 2000px 时, 将尺寸缩放至 2000px (保持宽高比).

```powershell
@@ -111,32 +105,101 @@ thtag -s xxx
thtag --source xxx
```

此工具还内置了另外三种数据源:
此工具还内置了另外一种数据源:

#### doujin-meta
[Doujin-Meta](https://github.com/the1812/Doujin-Meta) 获取曲目信息, 通常用于获取原创同人曲目信息.
```powershell
thtag -s doujin-meta
```

#### local-mp3
从 MP3 文件提取曲目信息, 通常用于 FLAC 文件未填信息, 而已有填好信息的 MP3 文件. 可以使用此数据源按专辑进行信息复制.
### 下载歌词
`可自动保存的选项`

歌词相关的处理, 除了 `--lyric` 外的选项都会自动保存.

#### 选项说明
- `-l` / `--lyric`: 启用歌词下载
- `-t` / `--lyric-type`: 歌词类型
- **`original`(默认)**: 原版歌词
- `translated`: 译文歌词, 没有译文时会回退到原版歌词
- `mixed`: 混合原文和译文的歌词, 没有译文时同原版歌词
- `-o` / `--lyric-output`: 歌词输出
- **`metadata`(默认)**: 写入到元数据中
- `lrc`: 创建额外的`.lrc`歌词文件 (**⚠此功能尚未完善**)
- `--no-lyric-time`: 禁用元数据歌词时轴
- `-lcs` / `--lyric-cache-size`: 设置歌词最大缓存数量, 用来加速重复曲目的歌词下载, **默认 16**

#### 示例
启用歌词下载, 写入原版歌词到元数据中
```powershell
thtag -l
```
启用歌词下载, 写入混合原文和译文的歌词到元数据中
```powershell
thtag -l -t mixed
```

### 禁止交互
不做任何询问, 按照理想行为运行到底, 例如:
- 专辑名称不再询问, 直接取文件夹的名称
- 根据文件夹名称搜索:
- 搜索不到专辑时: 判为失败并退出
- 搜索到多个专辑时: 只有一个结果就取这个结果, 否则判为失败并退出
```powershell
thtag --no-interactive
```

### 批量运行
假设总的文件夹叫 `folder`, 里面有多个文件夹, 每个文件夹包含一张专辑, 文件夹名称为专辑名称
> 当前路径就在 `folder` 里的时候, 用 `thtag -b .` 就行了, `.` 表示当前文件夹
```powershell
thtag -b folder
```
```powershell
thtag -s local-mp3
thtag --batch folder
```
程序会将里面的子文件夹逐个进行专辑信息获取.

#### 设置文件夹层级
如果专辑文件夹并不是直接放在 `folder` 下的, 而是有更深的层级, 可以更改批量运行时搜索文件夹的层级来获取正确的专辑文件夹列表.

例如按社团分类后, 专辑相对于 `folder` 隔了两层:
```
folder
├─社团1
│ └─专辑A
└─社团2
└─专辑B
```
在启动后, 询问专辑名称时填入 MP3 文件所在的文件夹即可.

> 注意此数据源需要填入 MP3 的文件夹路径, 因此不能用于批量模式中
将层级设为 `2` 就可以检测到里面的专辑:
```powershell
thtag -bd 2
```
```powershell
thtag --batch-depth 2
```

#### local-json
从 JSON 文件读取曲目信息, JSON 内数据的类型为 `Metadata[]` (定义位于 `src/core/metadata.ts`). 可以使用此数据源处理一些原创专辑, 用法与 `local-mp3` 基本相同.
### 超时 / 重试
`可自动保存的选项`

> 如果已存在名为 `metadata.json` 的文件, 程序会直接使用其中的曲目信息, 跳过曲目信息下载. 事先在各个文件夹中准备好 `metadata.json` 的话也是可以使用批量模式的.
默认 30 秒后无法完成专辑信息下载判定为超时, 并自动进行重试, 总尝试次数到达默认的 3 次后, 程序会判为失败并停止.

可以通过相应的开关调整以上的数值, 下面的例子为 60 秒超时, 最多试 5 次:
```powershell
thtag -s local-json
thtag --timeout 60 --retry 5
```

## 专辑配置
### 曲目信息配置
在下载曲目信息前, 如果文件夹下已存在名为 `metadata.json` 的文件, 程序会直接使用其中的曲目信息, 跳过曲目信息下载.

`metadata.json` 中数据的类型为 `Metadata[]` (定义位于 `src/core/metadata.ts`)

为了方便使用, JSON 的内容可以进行一些省略:
- 整张专辑中相同的数据, 例如专辑名称 / 社团名称等, 只需要在第一首曲目中写上即可, 后续曲目均会使用相同的数据.
- 编曲者 (artists) 和作曲者 (composers) 相同时, 可以只写作曲者. (但不能只写编曲者, 因为东方同人曲的编曲者和作曲者一般是不同的, 作曲者从原曲信息就可以推断, 所以作曲者通常是省略的. 如果只写编曲者, 程序会让作曲者留空)
@@ -286,87 +349,27 @@ thtag -s local-json

</details>

### Touhou Tagger 运行配置
可以为每一张专辑保存不同的运行配置, 无论是单独进行写入还是批量模式, 程序都会尝试读取专辑文件夹下的 `thtag.json` 文件. 可配置的内容有:
- `defaultAlbumHint`: 默认用于搜索的专辑名称
- `source`: 使用的数据源

### 下载歌词
`可自动保存的选项`

歌词相关的处理, 除了 `--lyric` 外的选项都会自动保存.

#### 选项说明
- `-l` / `--lyric`: 启用歌词下载
- `-t` / `--lyric-type`: 歌词类型
- **`original`(默认)**: 原版歌词
- `translated`: 译文歌词, 没有译文时会回退到原版歌词
- `mixed`: 混合原文和译文的歌词, 没有译文时同原版歌词
- `-o` / `--lyric-output`: 歌词输出
- **`metadata`(默认)**: 写入到元数据中
- `lrc`: 创建额外的`.lrc`歌词文件 (**⚠此功能尚未完善**)
- `--no-lyric-time`: 禁用元数据歌词时轴
- `-lcs` / `--lyric-cache-size`: 设置歌词最大缓存数量, 用来加速重复曲目的歌词下载, **默认 16**

#### 示例
启用歌词下载, 写入原版歌词到元数据中
```powershell
thtag -l
```
启用歌词下载, 写入混合原文和译文的歌词到元数据中
```powershell
thtag -l -t mixed
```

### 禁止交互
不做任何询问, 按照理想行为运行到底, 例如:
- 专辑名称不再询问, 直接取文件夹的名称
- 根据文件夹名称搜索:
- 搜索不到专辑时: 判为失败并退出
- 搜索到多个专辑时: 只有一个结果就取这个结果, 否则判为失败并退出
```powershell
thtag --no-interactive
```

### 批量运行
假设总的文件夹叫 `folder`, 里面有多个文件夹, 每个文件夹包含一张专辑, 文件夹名称为专辑名称
> 当前路径就在 `folder` 里的时候, 用 `thtag -b .` 就行了, `.` 表示当前文件夹
```powershell
thtag -b folder
```
```powershell
thtag --batch folder
```
程序会将里面的子文件夹逐个进行专辑信息获取.

#### 设置文件夹层级
如果专辑文件夹并不是直接放在 `folder` 下的, 而是有更深的层级, 可以更改批量运行时搜索文件夹的层级来获取正确的专辑文件夹列表.

例如按社团分类后, 专辑相对于 `folder` 隔了两层:
例子:
```
folder
├─社团1
│ └─专辑A
└─社团2
└─专辑B
├─专辑A
│ └─thtag.json -> { "defaultAlbumHint": "Album A" }
├─专辑B
│ └─thtag.json -> { "source": "doujin-meta" }
└─专辑C
```

将层级设为 `2` 就可以检测到里面的专辑:
```powershell
thtag -bd 2
```
当批量运行时
```powershell
thtag --batch-depth 2
thtag -b folder
```

### 超时 / 重试
`可自动保存的选项`

默认 30 秒后无法完成专辑信息下载判定为超时, 并自动进行重试, 总尝试次数到达默认的 3 次后, 程序会判为失败并停止.

可以通过相应的开关调整以上的数值, 下面的例子为 60 秒超时, 最多试 5 次:
```powershell
thtag --timeout 60 --retry 5
```
`专辑A`, 会使用 `Album A` 去 THBWiki 搜索; 对 `专辑B`, 会使用 `专辑B` 去 Doujin Meta 搜索; 对 `专辑C`, 会使用 `专辑C` 去 THBWiki 搜索.

## 提取曲目信息
在专辑文件夹中运行:
@@ -378,8 +381,7 @@ thtag dump
`thtag dump` 也可以和部分选项结合使用:
- `--cover`: 同时提取封面图片
- `--debug`: 额外保存一个 `metadata.debug.json` 文件, 记录原始的数据结构
- `--batch`: (未完成) 批量进行提取

- `--batch`: 批量进行提取

## 特别感谢
- [THBWiki](http://thwiki.cc/首页)
Binary file removed after-files.jpg
Binary file not shown.
Binary file removed after.jpg
Binary file not shown.
Binary file removed before-files.jpg
Binary file not shown.
Binary file removed before.jpg
Binary file not shown.
Binary file added example.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading