Skip to content

Commit df70a65

Browse files
committed
add index.mjs
1 parent 687b2b4 commit df70a65

File tree

6 files changed

+419
-6
lines changed

6 files changed

+419
-6
lines changed

.gitignore

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
package-lock.json
3+
test.json
4+
out
5+
dist
6+
.vscode

README.md

+104
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# 喵帕斯解析器 (nyanpasu)
2+
3+
喵帕斯解析器是一个 BiliBili 番剧视频和弹幕元数据的解析脚本,可以根据链接自动下载和解析视频和弹幕元数据,并创建下载列表。
4+
5+
## 安装
6+
7+
此脚本没有使用任何平台特定的代码,应当可以适用于所有主流操作系统,但是它只在 Linux 下测试过。
8+
9+
你需要首先安装 Node.JS 以运行此脚本。你可以从 Github Release 下载到一个压缩后脚本,包含脚本代码及其 NPM 依赖。该脚本包含正确的“井号注释”(shebang),可以直接赋予可执行权限并执行。你可以考虑将其复制到 PATH 目录下(例如 `~/.local/bin` 或者 `/usr/local/bin`)以便于使用。
10+
11+
你可能希望安装 [yt-dlp](https://github.com/yt-dlp/yt-dlp) 及其依赖 [ffmpeg](https://ffmpeg.org/) 以便于下载视频。你可能还希望使用 [Tmux](https://github.com/tmux/tmux) 或者 [GNU Screen](https://www.gnu.org/software/screen/) 以防止因为关闭终端而导致下载中断。
12+
13+
## 构建
14+
15+
你也可以手工构建并打包此项目,首先你需要安装 Node.JS 和 npm,并下载本仓库,然后执行:
16+
17+
```
18+
npm install
19+
npm run build
20+
```
21+
22+
即可在 `dist/nyanpasu.mjs` 找到输出。
23+
24+
请注意,此脚本的打包脚本 `build.sh` 不适用于 Windows(依赖于 `/bin/sh`),但是可以应当很容易的适配到 Windows(如果对此需要帮助,请随时提交一个 Issue)。
25+
26+
## 使用方法
27+
28+
首先,你需要得到番剧的一集的链接,并作为命令行参数传入脚本。以下以 [幸运星](https://www.bilibili.com/bangumi/play/ep35595) 为例,切换到一个合适的空目录并执行:
29+
30+
```sh
31+
nyanpasu.mjs https://www.bilibili.com/bangumi/play/ep35595
32+
```
33+
34+
得到类似于以下的输出:
35+
36+
```
37+
Downloading descriptor info
38+
Title: 幸运星
39+
Count: 25 episodes
40+
* Episode 1: 狂奔的女人
41+
* Episode 2: 努力与结果
42+
* Episode 3: 形形色色的人们
43+
* Episode 4: 干劲的问题
44+
* Episode 5: 神射手
45+
* Episode 6: 夏天的例行节目
46+
* Episode 7: 印象
47+
* Episode 8: 即使不是我也很旺盛喔
48+
* Episode 9: 这种感觉
49+
* Episode 10: 愿望
50+
* Episode 11: 过平安夜的各种方法
51+
* Episode 12: 一起去祭典吧
52+
* Episode 13: 美味的日子
53+
* Episode 14: 同一个屋檐下
54+
* Episode 15: 一时变不过来
55+
* Episode 16: 循环
56+
* Episode 17: 名正言顺
57+
* Episode 18: 十个人十个样
58+
* Episode 19: 二次元的本质
59+
* Episode 20: 渡过夏天的方法
60+
* Episode 21: 潘朵拉的盒子
61+
* Episode 22: 在这里的彼方
62+
* Episode 23: 微妙的那条线
63+
* Episode 24: 未定
64+
* Episode 25: OVA
65+
Command hint: yt-dlp -a vlist.txt -o "%(autonumber)s.%(ext)s" -f mp4
66+
```
67+
68+
并生成四个文件:
69+
70+
```plain
71+
cache.json descriptor.xml download-danmu.sh vlist.txt
72+
```
73+
74+
其中 `cache.json` 是番剧元数据的缓存,`descriptor.xml` 是简化后的番剧元数据,可供人阅读或其他软件解析。`download-danmu.sh` 是用于下载弹幕数据和番剧封面图的脚本(内部使用 `wget`)。`vlist.txt` 是各集视频的链接,你可以进一步使用如下命令下载弹幕数据和番剧封面图:
75+
76+
```sh
77+
./download-danmu.sh
78+
```
79+
80+
如果你安装了 [yt-dlp](https://github.com/yt-dlp/yt-dlp),你进一步可以根据 `vlist.txt` 中的链接下载各集视频:
81+
82+
```
83+
yt-dlp -a vlist.txt -o "%(autonumber)s.%(ext)s" -f mp4
84+
```
85+
86+
根据需要,你可能需要添加 `--cookies``--cookies-from-browser``--abort-on-error` 等命令选项,注意可能无法下载付费视频和地区限制视频,可能会报错。更多信息请参考 [yt-dlp](https://github.com/yt-dlp/yt-dlp) 的文档。
87+
88+
你可以通过 `--help` 选项或阅读 `src/index.mjs` 源代码以查看更多命令行选项。
89+
90+
## 社区
91+
92+
我们期待来自社区的贡献。如果您遇到了错误,请随时提出问题。还有许多可以添加的功能。如果您实现了任何增强功能,欢迎打开一个拉取请求。
93+
94+
## 声明
95+
96+
请注意,本项目不代表上海宽娱数码科技有限公司或番剧版权方的意见,本项目按照“按其原样”的原则提供,不提供任何附带保证,使用者需承担可能的风险。
97+
98+
本项目完全开源,且没有任何代码加密操作,如有疑虑请自行审查代码或停止使用相关文件。对于使用本项目产生的额外问题,如账户封禁或被盗等,维护者不对此负责,请谨慎使用。
99+
100+
请尊重数字版权,请勿二次分发使用此脚本(以及使用此脚本生成的脚本)得到文件。
101+
102+
## 版权
103+
104+
本项目使用 GNU 通用公共许可证 v2.0 许可证。根据该许可证,您有权复制、修改、分发本项目的源代码和衍生作品。然而,您必须遵守许可证中规定的条件,包括在您的衍生作品中保留原始版权信息和许可证,并在分发时提供许可证的副本。此外,您还需要确保任何引用或使用本项目的内容的用户也能够获得许可证的副本。请注意,GNU 通用公共许可证 v2.0 许可证不允许您将本项目的代码用于专有软件,因此任何基于本项目的衍生作品也必须使用GNU 通用公共许可证 v2.0 许可证发布。详细信息请见 `LICENSE` 文件。

build.sh

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/sh
2+
cd $(git rev-parse --show-toplevel)
3+
rm -rf dist
4+
npx ncc build -m src/index.mjs
5+
cat nyanpasu.js dist/index.mjs > dist/nyanpasu.mjs
6+
chmod +x dist/nyanpasu.mjs

nyanpasu.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env -S node --experimental-modules
2+
/*
3+
nyanpasu.js BiliBili 番剧视频和弹幕元数据解析脚本
4+
Copyright (C) 2023 方而静
5+
6+
This program is free software; you can redistribute it and/or modify
7+
it under the terms of the GNU General Public License as published by
8+
the Free Software Foundation; either version 2 of the License, or
9+
(at your option) any later version.
10+
11+
This program is distributed in the hope that it will be useful,
12+
but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
GNU General Public License for more details.
15+
16+
You should have received a copy of the GNU General Public License along
17+
with this program; if not, write to the Free Software Foundation, Inc.,
18+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19+
*/
20+

package.json

+16-6
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
11
{
2-
"name": "nyanpasu-clone",
2+
"name": "nyanpasu",
3+
"type": "module",
34
"version": "0.1.0",
4-
"description": "下载缓存B站上某一番剧的全部视频和弹幕",
5-
"main": "src/index.js",
5+
"description": "BiliBili 番剧视频和弹幕元数据解析脚本",
6+
"main": "src/index.mjs",
67
"scripts": {
7-
"test": "echo \"Error: no test specified\" && exit 1"
8+
"build": "./build.sh"
89
},
910
"repository": {
1011
"type": "git",
11-
"url": "https://git.gzezfisher.top/szTom/nyanpasu-clone"
12+
"url": "https://github.com/szdytom/nyanpasu"
1213
},
1314
"author": "方而静 <szdytom@qq.com>",
14-
"license": "GPL-2.0-only"
15+
"license": "GPL-2.0-only",
16+
"dependencies": {
17+
"@xmldom/xmldom": "^0.8.10",
18+
"node-fetch": "^3.3.2",
19+
"xml-formatter": "^3.6.0",
20+
"yargs": "^17.7.2"
21+
},
22+
"devDependencies": {
23+
"@vercel/ncc": "^0.38.1"
24+
}
1525
}

0 commit comments

Comments
 (0)