Compare commits

..

No commits in common. "76a55d862f767ee20ae417ecd128fde442eea77f" and "e29fdaf8502541780bea64a28f45bb01c2285086" have entirely different histories.

14 changed files with 243 additions and 337 deletions

32
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file
View File

@ -0,0 +1,32 @@
---
name: "[请按照此模板填写] 报告 Bug"
about: "创建一个 Bug 报告,不按照模板的 Issue 会被直接关闭,不予回复。"
title: "[Bug] 总结你的 Bug 报告"
labels: bug
assignees: taurusxin
---
**Bug 描述**
清晰地描述一下 Bug 的大致问题,例如无法转换,或者其他问题。
**复现方法**
复现此 Bug 的方法
1. 使用本项目处理文件 '...'
2. 发生报错
**屏幕截图**
如果可以,屏幕截图可以更好地阐述你的问题。
**环境**
- 操作系统: Windows / macOS / Linux
- 网易云版本(重要): [e.g. 3.0.1]
- 所选择的音质: 极高、无损等
**附加内容**
如果遇到无法转换的问题,请将样本附加到这里,便于分析。

View File

@ -1,101 +0,0 @@
name: 报告 Bug
description: 创建一个 Bug 报告。
title: "[Bug]: "
labels: "bug"
assignees:
- taurusxin
body:
- type: markdown
attributes:
value: |
# taurusxin/ncmdump Bug 反馈须知
请__严格遵守该模板进行 Bug 反馈__否则维护者有权直接关闭本 Issue 不予回复!
为了保证 Bug 追踪的顺利请__务必提供详细信息并接受来自维护者的提问__
- type: checkboxes
attributes:
label: 该 Bug 是否针对 `libncmdump`
description: 如果是命令行工具 `ncmdump` 请不要勾选。
options:
- label: 是的,此 Bug 是针对动态库 `libncmdump` 而不是命令行工具 `ncmdump`!
- type: dropdown
attributes:
label: 类型
options:
- 无法转换文件
- 转换成功但音频文件无法播放
- 功能失效
- 程序崩溃
- 其他
validations:
required: true
- type: textarea
attributes:
label: Bug 描述
description: 清晰地描述一下 Bug 的大致问题及表现,对上面的类型进行补充说明。
validations:
required: true
- type: textarea
attributes:
label: 复现方法
description: 复现此 Bug 的方法。
placeholder: |
1. 使用本项目处理文件 '...'
2. 发生报错
validations:
required: true
- type: textarea
attributes:
label: 屏幕截图或视频
description: 如果可以,屏幕截图可以更好地阐述你的问题。
placeholder: 将截图或视频文件拖入此处
validations:
required: false
- type: input
attributes:
label: 操作系统
description: 请提供您当前正在使用的操作系统如果可以请提供更多关于操作系统的版本信息Linux 请提供发行版名称。
placeholder: Windows / macOS / Debian
validations:
required: true
- type: input
attributes:
label: ncmdump 版本
description: 请提供您正在使用的 ncmdump 版本,如果是来自 Github Actions 的构建,请提供 commit 信息。
placeholder: 1.5.0
validations:
required: true
- type: input
attributes:
label: 网易云版本(重要)
description: 请提供您下载 ncm 文件的网易云客户端及版本,请写明客户端平台与版本号。
placeholder: Windows 版 3.0.1
validations:
required: true
- type: dropdown
attributes:
label: 所下载的音质
options:
- 标准
- 极高
- 无损
- 高清臻音
- 超清母带
- 沉浸环绕声
validations:
required: true
- type: textarea
attributes:
label: 附加内容
placeholder: 如果遇到无法转换的问题,请将样本附加到这里,便于分析。
validations:
required: false

View File

@ -1,8 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: 寻求帮助
url: https://github.com/taurusxin/ncmdump/discussions/categories/q-a
about: 有疑问?请转移到讨论的 Q&A 分区!
- name: 意见与新功能请求
url: https://github.com/taurusxin/ncmdump/discussions/categories/ideas
about: 需要什么新功能?请到讨论的 Ideas 分区!

View File

@ -4,123 +4,139 @@ env:
BUILD_PATH: build BUILD_PATH: build
on: on:
push: push:
branches: [ main, dev ] branches: [ main ]
jobs: jobs:
# ---------------------------------------------------------------------- build_on_windows_msys2:
# 1. Linux Build runs-on: windows-latest
# ----------------------------------------------------------------------
job_linux: steps:
name: Linux Build - name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
update: true
install: git mingw-w64-ucrt-x86_64-toolchain
- name: Configure build
run: cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -B ${{ env.BUILD_PATH }}
- name: Build
run: cmake --build ${{ env.BUILD_PATH }} -j 4
- name: Strip
run: strip ${{ env.BUILD_PATH }}/ncmdump.exe
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: windows_amd64_build_msys2_exe
path: ${{ env.BUILD_PATH }}/ncmdump.exe
build_on_windows_msvc:
runs-on: windows-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Configure build
run: cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -B ${{ env.BUILD_PATH }}
- name: Build
run: cmake --build ${{ env.BUILD_PATH }} -j 4 --config ${{ env.BUILD_TYPE }}
- name: Upload artifact executable
uses: actions/upload-artifact@v4
with:
name: windows_amd64_build_msvc_exe
path: ${{ env.BUILD_PATH }}/${{ env.BUILD_TYPE }}/ncmdump.exe
- name: Upload artifact DLL
uses: actions/upload-artifact@v4
with:
name: windows_amd64_build_msvc_dll
path: ${{ env.BUILD_PATH }}/${{ env.BUILD_TYPE }}/libncmdump.dll
build_on_linux_amd64:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- name: Checkout - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
submodules: true submodules: recursive
- name: Install Dependencies - name: Install dependencies
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install -y build-essential cmake libtag1-dev zlib1g-dev sudo apt-get install -y build-essential cmake
# ubuntu 24.04 does not contains taglib v2.x, which does not support cmake, built it manually - name: Configure build
- name: Build TagLib v2.1.1 run: cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -B ${{ env.BUILD_PATH }}
run: |
wget https://github.com/taglib/taglib/releases/download/v2.1.1/taglib-2.1.1.tar.gz
tar -xzf taglib-2.1.1.tar.gz
cd taglib-2.1.1
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release .
make -j$(nproc)
sudo make install
- name: Configure CMake - name: Build
run: | run: cmake --build ${{ env.BUILD_PATH }} -j 4
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=Release \
-S ${{github.workspace}}
- name: Build - name: Upload artifact
run: cmake --build ${{github.workspace}}/build --config Release uses: actions/upload-artifact@v4
with:
name: linux_build_amd64
path: ${{ env.BUILD_PATH }}/ncmdump
- name: Upload Linux Artifact build_on_macos_amd64:
uses: actions/upload-artifact@v4
with:
name: ncmdump-linux
path: ${{github.workspace}}/build/ncmdump
# ----------------------------------------------------------------------
# 2. macOS Build
# ----------------------------------------------------------------------
job_macos:
name: macOS Build
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- name: Checkout - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
submodules: true submodules: recursive
- name: Install Dependencies - name: Install dependencies
run: | run: |
brew install taglib brew install git cmake
- name: Configure CMake - name: Configure build
run: | run: cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -B ${{ env.BUILD_PATH }} -DCMAKE_OSX_ARCHITECTURES=x86_64
cmake -B ${{github.workspace}}/build \
-DCMAKE_BUILD_TYPE=Release \
-S ${{github.workspace}}
- name: Build - name: Build
run: cmake --build ${{github.workspace}}/build --config Release run: cmake --build ${{ env.BUILD_PATH }} -j 4
- name: Upload macOS Artifact - name: Upload artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ncmdump-macos name: macOS_build_amd64
path: ${{github.workspace}}/build/ncmdump path: ${{ env.BUILD_PATH }}/ncmdump
# ---------------------------------------------------------------------- build_on_macos_arm64:
# 3. Windows Build runs-on: macos-latest
# ----------------------------------------------------------------------
job_windows:
name: Windows Build
runs-on: windows-latest
env:
VCPKG_TRIPLET: x64-windows-static
steps: steps:
- name: Checkout - name: Checkout repository
uses: actions/checkout@v4 uses: actions/checkout@v4
with: with:
submodules: true submodules: recursive
- name: Install Dependencies - name: Install dependencies
uses: lukka/run-vcpkg@v11 run: |
id: vcpkg brew install git cmake
with:
vcpkgJsonGlob: '**/vcpkg.json'
- name: Configure CMake - name: Configure build
run: | run: cmake -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -B ${{ env.BUILD_PATH }} -DCMAKE_OSX_ARCHITECTURES=arm64
cmake -B ${{github.workspace}}/build `
-DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake `
-DVCPKG_TARGET_TRIPLET=${{ env.VCPKG_TRIPLET }} `
-S ${{github.workspace}}
- name: Build - name: Build
run: cmake --build ${{github.workspace}}/build --config Release run: cmake --build ${{ env.BUILD_PATH }} -j 4
- name: Upload Windows Executable Artifact - name: Upload artifact
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: ncmdump-windows name: macOS_build_arm64
path: ${{github.workspace}}/build/Release/ncmdump.exe path: ${{ env.BUILD_PATH }}/ncmdump
- name: Upload Windows Library Artifact
uses: actions/upload-artifact@v4
with:
name: libncmdump-windows
path: ${{github.workspace}}/build/Release/libncmdump.dll

2
.gitignore vendored
View File

@ -7,5 +7,3 @@ ncmdump
build build
cmake-build-* cmake-build-*
vcpkg_installed

3
.gitmodules vendored Normal file
View File

@ -0,0 +1,3 @@
[submodule "taglib"]
path = taglib
url = https://github.com/taglib/taglib.git

View File

@ -5,8 +5,10 @@ project(ncmdump LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(ZLIB) set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
find_package(TagLib REQUIRED) set(WITH_ZLIB OFF)
set(BUILD_TESTING OFF)
add_subdirectory(taglib)
if(MSVC) if(MSVC)
add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/execution-charset:utf-8>") add_compile_options("$<$<CXX_COMPILER_ID:MSVC>:/execution-charset:utf-8>")
@ -20,15 +22,12 @@ FILE(GLOB LIBRARY_SOURCES src/lib/*.cpp)
FILE(GLOB WIN_SOURCES src/platform/win32_init.cpp) FILE(GLOB WIN_SOURCES src/platform/win32_init.cpp)
if(WIN32) if(WIN32)
# windows executable
add_executable(ncmdump_exec add_executable(ncmdump_exec
${COMMON_HEADERS} ${COMMON_HEADERS}
${COMMON_SOURCES} ${COMMON_SOURCES}
${EXECUTABLE_SOURCES} ${EXECUTABLE_SOURCES}
${WIN_SOURCES} ${WIN_SOURCES}
) )
# windows library
add_library(ncmdump_lib SHARED add_library(ncmdump_lib SHARED
${COMMON_HEADERS} ${COMMON_HEADERS}
${COMMON_SOURCES} ${COMMON_SOURCES}
@ -37,27 +36,22 @@ if(WIN32)
${WIN_SOURCES} ${WIN_SOURCES}
) )
target_include_directories(ncmdump_lib PRIVATE src/include)
set_target_properties(ncmdump_lib PROPERTIES OUTPUT_NAME "libncmdump") set_target_properties(ncmdump_lib PROPERTIES OUTPUT_NAME "libncmdump")
target_link_libraries(ncmdump_lib TagLib::tag)
# msvc target_include_directories(ncmdump_lib PRIVATE src/include)
if(MSVC)
# Debug/Release 使 C target_link_libraries(ncmdump_lib tag)
foreach(flag_var target_include_directories(ncmdump_lib PRIVATE taglib)
CMAKE_CXX_FLAGS target_include_directories(ncmdump_lib PRIVATE taglib/taglib)
CMAKE_C_FLAGS target_include_directories(ncmdump_lib PRIVATE taglib/taglib/toolkit)
CMAKE_CXX_FLAGS_DEBUG target_include_directories(ncmdump_lib PRIVATE taglib/taglib/mpeg/id3v2)
CMAKE_CXX_FLAGS_RELEASE
) if(CMAKE_COMPILER_IS_GNUCXX)
if(${flag_var}) # static link when using MinGW
string(REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") target_link_options(ncmdump_exec PRIVATE -static)
endif() target_link_options(ncmdump_lib PRIVATE -static)
endforeach()
endif() endif()
else() else()
# linux / macOS executable
add_executable(ncmdump_exec add_executable(ncmdump_exec
${COMMON_HEADERS} ${COMMON_HEADERS}
${COMMON_SOURCES} ${COMMON_SOURCES}
@ -69,8 +63,11 @@ endif()
set_target_properties(ncmdump_exec PROPERTIES OUTPUT_NAME "ncmdump") set_target_properties(ncmdump_exec PROPERTIES OUTPUT_NAME "ncmdump")
target_include_directories(ncmdump_exec PRIVATE src/include) target_include_directories(ncmdump_exec PRIVATE src/include)
# executable link to taglib target_link_libraries(ncmdump_exec tag)
target_link_libraries(ncmdump_exec TagLib::tag) target_include_directories(ncmdump_exec PRIVATE taglib)
target_include_directories(ncmdump_exec PRIVATE taglib/taglib)
target_include_directories(ncmdump_exec PRIVATE taglib/taglib/toolkit)
target_include_directories(ncmdump_exec PRIVATE taglib/taglib/mpeg/id3v2)
include(GNUInstallDirs) include(GNUInstallDirs)
@ -83,6 +80,7 @@ if(WIN32)
else() else()
install(TARGETS ncmdump_exec install(TARGETS ncmdump_exec
BUNDLE DESTINATION . BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
) )
endif() endif()

105
README.md
View File

@ -6,19 +6,29 @@
该版本为最早的 C++ 版本,也是作者开发的市面上第一个支持 ncm 转换的程序 该版本为最早的 C++ 版本,也是作者开发的市面上第一个支持 ncm 转换的程序
源码复刻自 anonymous5l/ncmdump (2021年10月6日原作者已经删库) 源码复刻自 anonymous5l/ncmdump,感谢前辈的付出!做了 Windows 下的移植,修复了一些编译问题
感谢前辈的付出!此版本做了全操作系统下的的跨平台编译移植,修复了一些内存溢出的问题 1.3.0 版本更新说明因为之前有小伙伴反馈无法解密带有特殊字符的文件名例如中文、日文、韩文或者是表情符号等在1.3.0以及之后的版本彻底修复了这个问题,所有的 UTF-8 字符都可以正常解密。并且还自带了 dll 的构建可以供其他应用程序C#、Python、Java等调用
1.3.0 版本更新说明:因为之前有较多 Issue 反馈无法解密带有特殊字符的文件名例如中文、日文、韩文或者是表情符号等在1.3.0以及之后的版本彻底修复了这个问题,所有的 UTF-8 字符都可以正常解密。并且还自带了 dll 的构建可以供其他应用程序C#、Python、Java等调用。 ## 传送门
2021年10月6日原作者已经删库
## 使用 ## 使用
注意:网易云音乐 3.0 之后的某些版本,下载的 ncm 文件会出现不内置歌曲专辑的封面图片的情况,所需的封面图数据需要从网络获取,介于在一个小工具中嵌入庞大网络库的非必要性,可以移步我的另一个仓库 [ncmdump-go](https://git.taurusxin.com/taurusxin/ncmdump-go) 或者使用基于此项目开发的可视化 GUI 程序 [ncmdump-gui](https://git.taurusxin.com/taurusxin/ncmdump-gui),其中后者基于前者,均完全使用 Golang 重写,并支持自动从元数据读取封面信息后从网络获取封面图并嵌入到目标音乐文件。 注意:自网易云音乐 3.0 版本开始,下载的 ncm 文件均不内置歌曲专辑的封面图片,需要从网络获取,介于在一个小工具中嵌入庞大网络库的非必要性,可以移步我的另一个仓库<https://git.taurusxin.com/taurusxin/ncmdump-go>),下载完全使用 Golang 重写的新版本,支持从网络自动获取封面图并嵌入到目标音乐文件。
### 命令行工具 ### 命令行工具
从 [Release](https://github.com/taurusxin/ncmdump/releases) 下载最新版本的对应系统的已编译好的二进制文件 **[不推荐]** 你可以使用 Homebrew 来安装 Linux 或者 macOS 下的 ncmdump
注意:由于本项目依赖的库 taglib 的 2.0 版本尚未发布到 homebrew-core主要是因为 taglib 2.0 导致其他 brew 包存在版本兼容问题),目前的 cmake 构建链无法在 macOS 上正常使用。根据 brew 的要求,如果依赖库已有官方的 brew 包,构建时必须使用官方仓库中的包,不能从 git 获取。而 taglib 2.0 版本开始才支持 cmake 构建。因此ncmdump 在 homebrew 上只能发布到 `1.2.1` 版本。建议直接通过二进制方式安装,`1.3.0` 后版本修复了许多 bug使用体验会更好。
```shell
brew install ncmdump
```
或者从 [Release](https://github.com/taurusxin/ncmdump/releases) 下载最新版本的对应系统的已编译好的二进制文件
使用 `-h``--help` 参数来打印帮助 使用 `-h``--help` 参数来打印帮助
@ -50,12 +60,6 @@ ncmdump -d source_dir
ncmdump -d source_dir -r ncmdump -d source_dir -r
``` ```
使用 `-m` 参数来删除源文件若正确处理
```shell
ncmdump -m
```
使用 `-o` 参数来指定输出目录,将转换后的文件输出到指定目录,该参数支持与 `-r` 参数一起使用 使用 `-o` 参数来指定输出目录,将转换后的文件输出到指定目录,该参数支持与 `-r` 参数一起使用
```shell ```shell
@ -83,71 +87,40 @@ ncmdump -d source_dir -o output_dir -r
git clone https://github.com/taurusxin/ncmdump.git git clone https://github.com/taurusxin/ncmdump.git
``` ```
### Windows 更新子模块
安装 Visual Studio 2022 和 cmake并安装 C++ 桌面开发环境,然后安装 [vcpkg](https://github.com/microsoft/vcpkg)
```shell ```shell
# 安装 vcpkg 并安装 taglib 的静态库 cd ncmdump
git clone https://github.com/microsoft/vcpkg.git git submodule update --init --recursive
cd vcpkg
./bootstrap-vcpkg.bat
``` ```
配置项目 使用 CMake 配置项目。Windows 下若使用 GNU 套件,推荐使用 [msys2](https://www.msys2.org/) 或者 [winlibs](https://winlibs.com/)
```shell ```shell
# 使用 cmake 配置项目,替换 %VCPKG_ROOT% 为你的 vcpkg 安装路径 # Windows MinGW
cmake -G "Visual Studio 17 2022" -DCMAKE_TOOLCHAIN_FILE=%VCPKG_ROOT%/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows-static -B build cmake -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release -B build
# 编译项目 # Windows MSVC
cmake -G "Visual Studio 17 2022" -A x64 -B build
# Linux / macOS
cmake -DCMAKE_BUILD_TYPE=Release -B build
# 如果需要在 macOS 下交叉编译,可以指定 `CMAKE_OSX_ARCHITECTURES` 变量来指明目标系统架构
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=arm64 -B build # arm64
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES=x86_64 -B build # Intel-based
```
编译项目
```shell
# Windows MSVC 需要在构建阶段指定 --config Release
cmake --build build -j 8 --config Release cmake --build build -j 8 --config Release
# Windows MinGW / Linux / macOS
cmake --build build -j 8
``` ```
### macOS
macOS 下,你可以方便地使用 Homebrew 来安装 taglib 库
```shell
# 安装 taglib 库
brew install taglib
# 配置项目
cmake -DCMAKE_BUILD_TYPE=Release -B build
# 编译项目
cmake --build build -j$(nproc)
```
### Linux
Linux 下,由于 Ubuntu 24.04 的 taglib 仍然为 1.x 版本,不支持 CMake所以需要手动编译安装 2.x 版本,目前 GitHub Actions 的 Linux 构建流程也是手动编译。
```shell
# 拉取源码
wget https://github.com/taglib/taglib/releases/download/v2.1.1/taglib-2.1.1.tar.gz
# 解压并进入
tar -xzf taglib-2.1.1.tar.gz && cd taglib-2.1.1
# 配置、编译和安装
cmake -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_BUILD_TYPE=Release .
make -j$(nproc)
sudo make install
```
然后和 macOS 上一样,使用 CMake 配置项目并编译项目
```shell
# 配置项目
cmake -DCMAKE_BUILD_TYPE=Release -B build
# 编译项目
cmake --build build -j$(nproc)
```
---
你可以在 `build` 文件夹下找到编译好的二进制文件,以及一个可供其它项目使用的动态库(Windows Only),使用方法见仓库的 `example` 文件夹 你可以在 `build` 文件夹下找到编译好的二进制文件,以及一个可供其它项目使用的动态库(Windows Only),使用方法见仓库的 `example` 文件夹
## Star History ## Star History

View File

@ -1,3 +1,3 @@
#define VERSION_MAJOR 1 #define VERSION_MAJOR 1
#define VERSION_MINOR 5 #define VERSION_MINOR 5
#define VERSION_PATCH 1 #define VERSION_PATCH 0

View File

@ -15,7 +15,7 @@
namespace fs = std::filesystem; namespace fs = std::filesystem;
void processFile(const fs::path &filePath, const fs::path &outputFolder, bool isRequiredRemoved) void processFile(const fs::path &filePath, const fs::path &outputFolder)
{ {
if (fs::exists(filePath) == false) if (fs::exists(filePath) == false)
{ {
@ -35,14 +35,7 @@ void processFile(const fs::path &filePath, const fs::path &outputFolder, bool is
crypt.Dump(outputFolder.u8string()); crypt.Dump(outputFolder.u8string());
crypt.FixMetadata(); crypt.FixMetadata();
std::cout << BOLDGREEN << "[Done] " << RESET << "'" << filePath.u8string() << "' -> '" << crypt.dumpFilepath().u8string() << "'" ; std::cout << BOLDGREEN << "[Done] " << RESET << "'" << filePath.u8string() << "' -> '" << crypt.dumpFilepath().u8string() << "'" << std::endl;
if (isRequiredRemoved)
{
fs::remove(filePath);
std::cout << " with removed as required.";
}
std::cout << std::endl;
} }
catch (const std::invalid_argument &e) catch (const std::invalid_argument &e)
{ {
@ -68,7 +61,6 @@ int main(int argc, char **argv)
("r,recursive", "Process files recursively (requires -d option)", cxxopts::value<bool>()->default_value("false")) ("r,recursive", "Process files recursively (requires -d option)", cxxopts::value<bool>()->default_value("false"))
("o,output", "Output folder (default: original file folder)", cxxopts::value<std::string>()) ("o,output", "Output folder (default: original file folder)", cxxopts::value<std::string>())
("v,version", "Print version information", cxxopts::value<bool>()->default_value("false")) ("v,version", "Print version information", cxxopts::value<bool>()->default_value("false"))
("m,remove", "Remove original file if done", cxxopts::value<bool>()->default_value("false"))
("filenames", "Input files", cxxopts::value<std::vector<std::string>>()); ("filenames", "Input files", cxxopts::value<std::vector<std::string>>());
options.positional_help("<files>"); options.positional_help("<files>");
@ -173,7 +165,7 @@ int main(int argc, char **argv)
fs::create_directories(destinationPath.parent_path()); fs::create_directories(destinationPath.parent_path());
// 处理文件 // 处理文件
processFile(path, destinationPath.parent_path(), result.count("remove")); processFile(path, destinationPath.parent_path());
} }
} }
} }
@ -186,11 +178,11 @@ int main(int argc, char **argv)
{ {
if (outputDirSpecified) if (outputDirSpecified)
{ {
processFile(path, outputDir, result.count("remove")); processFile(path, outputDir);
} }
else else
{ {
processFile(path, "", result.count("remove")); processFile(path, "");
} }
} }
} }
@ -212,11 +204,11 @@ int main(int argc, char **argv)
if (outputDirSpecified) if (outputDirSpecified)
{ {
processFile(filePathU8, outputDir, result.count("remove")); processFile(filePathU8, outputDir);
} }
else else
{ {
processFile(filePathU8, "", result.count("remove")); processFile(filePathU8, "");
} }
} }
} }

View File

@ -4,12 +4,13 @@
#include "cJSON.h" #include "cJSON.h"
#include "color.h" #include "color.h"
#include <taglib/tfile.h> #define TAGLIB_STATIC
#include <taglib/mpegfile.h> #include "taglib/toolkit/tfile.h"
#include <taglib/flacfile.h> #include "taglib/mpeg/mpegfile.h"
#include <taglib/attachedpictureframe.h> #include "taglib/flac/flacfile.h"
#include <taglib/id3v2tag.h> #include "taglib/mpeg/id3v2/frames/attachedpictureframe.h"
#include <taglib/tag.h> #include "taglib/mpeg/id3v2/id3v2tag.h"
#include "taglib/tag.h"
#include <stdexcept> #include <stdexcept>
#include <string> #include <string>
@ -25,7 +26,8 @@ const unsigned char NeteaseCrypt::mPng[8] = {0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A,
static void aesEcbDecrypt(const unsigned char *key, std::string &src, std::string &dst) static void aesEcbDecrypt(const unsigned char *key, std::string &src, std::string &dst)
{ {
int i, n; int n, i;
unsigned char out[16]; unsigned char out[16];
n = src.length() >> 4; n = src.length() >> 4;
@ -49,6 +51,18 @@ static void aesEcbDecrypt(const unsigned char *key, std::string &src, std::strin
dst += std::string((char *)out, 16 - pad); dst += std::string((char *)out, 16 - pad);
} }
static void replace(std::string &str, const std::string &from, const std::string &to)
{
if (from.empty())
return;
size_t start_pos = 0;
while ((start_pos = str.find(from, start_pos)) != std::string::npos)
{
str.replace(start_pos, from.length(), to);
start_pos += to.length(); // In case 'to' contains 'from', like replacing 'x' with 'yx'
}
}
NeteaseMusicMetadata::~NeteaseMusicMetadata() NeteaseMusicMetadata::~NeteaseMusicMetadata()
{ {
cJSON_Delete(mRaw); cJSON_Delete(mRaw);
@ -227,7 +241,7 @@ void NeteaseCrypt::FixMetadata()
if (!mImageData.empty()) if (!mImageData.empty())
{ {
auto *cover = new TagLib::FLAC::Picture; TagLib::FLAC::Picture *cover = new TagLib::FLAC::Picture;
cover->setMimeType(mimeType(mImageData)); cover->setMimeType(mimeType(mImageData));
cover->setType(TagLib::FLAC::Picture::FrontCover); cover->setType(TagLib::FLAC::Picture::FrontCover);
cover->setData(vector); cover->setData(vector);
@ -236,7 +250,7 @@ void NeteaseCrypt::FixMetadata()
} }
} }
if (mMetaData != nullptr) if (mMetaData != NULL)
{ {
tag->setTitle(TagLib::String(mMetaData->name(), TagLib::String::UTF8)); tag->setTitle(TagLib::String(mMetaData->name(), TagLib::String::UTF8));
tag->setArtist(TagLib::String(mMetaData->artist(), TagLib::String::UTF8)); tag->setArtist(TagLib::String(mMetaData->artist(), TagLib::String::UTF8));

View File

@ -2142,7 +2142,7 @@ CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newit
{ {
cJSON *after_inserted = NULL; cJSON *after_inserted = NULL;
if (which < 0 || newitem == NULL) if (which < 0)
{ {
return; return;
} }
@ -2154,10 +2154,6 @@ CJSON_PUBLIC(void) cJSON_InsertItemInArray(cJSON *array, int which, cJSON *newit
return; return;
} }
if (after_inserted != array->child && newitem->prev == NULL) {
return;
}
newitem->next = after_inserted; newitem->next = after_inserted;
newitem->prev = after_inserted->prev; newitem->prev = after_inserted->prev;
after_inserted->prev = newitem; after_inserted->prev = newitem;

1
taglib Submodule

@ -0,0 +1 @@
Subproject commit e3de03501ff66221d1f1f971022b248d5b38ba06

View File

@ -1,8 +0,0 @@
{
"name": "ncmdump",
"version": "1.6.0",
"builtin-baseline": "a62ce77d56ee07513b4b67de1ec2daeaebfae51a",
"dependencies": [
"taglib"
]
}