Skip to content

Commit

Permalink
实现视频下载功能 (#21)
Browse files Browse the repository at this point in the history
* 初步搭建视频下载框架

* 支持curl命令行

* 支持aria2c命令行

* 更新下载源获取流程

* 实现APP鉴权获取流程

* 视频工具栏分享二维码

* Update README.md

* Bump 1.0.5.0
  • Loading branch information
MotooriKashin authored Sep 29, 2024
1 parent fc07fd0 commit 079df62
Show file tree
Hide file tree
Showing 36 changed files with 1,225 additions and 141 deletions.
56 changes: 55 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,55 @@
重构 B 站旧版页面
<div align="center">
<img src="src/assets/panel.gif" alt="logo">

# Bilibili 2019
恢复 2019 年 12 月 09 日前的部分[B站](https://www.bilibili.com/)页面,为了那些念旧的人

</div>

---
这是一个[Google Chrome](https://www.google.com/chrome/)[manifest V3](https://developer.chrome.com/docs/extensions/mv3/manifest/)扩展项目,恢复 2019 年 12 月 09 日前的部分[B站](https://www.bilibili.com/)页面,尤其是那个小电视播放器。
项目前身是[Bilibili-Old](https://github.com/MotooriKashin/Bilibili-Old)油猴脚本,在B站原始页面的基础上修修补补了四年多,奈何实在老旧,难以为继,于是有了推倒重来的念头。加上[manifest V3](https://developer.chrome.com/docs/extensions/mv3/manifest/)标准的推行,油猴脚本前途未卜,索性转为扩展项目。
由于 HTML + js + css 都不再复用,从零开始手搓,肯定做不到完全复刻当年的模样,请多见谅!

---
# 功能
各种页面正在慢慢搭建中……
- 播放器
+ 视频
- [x] DASH
- [x] flv
- [x] 本地视频文件
+ 弹幕
- [x] 普通弹幕(mode1/4/5/6)
- [x] 高级弹幕(mode7)
- [x] 代码弹幕(mode8)
- [x] BAS弹幕(mode9)
- [x] 本地弹幕文件
+ 字幕
- [x] 在线 CC 字幕
- [x] 本地 vtt 文件
- 评论
+ [x] 翻页
- 页面
+ [x] B站主页
+ [x] av
+ [x] Bangumi

---
# 安装
- 欢迎在安装之前访问核心[播放器页面](https://motoorikashin.github.io/Bilibili-2019/)体验一下旧版播放器
- 若要安装,则要求使用最新的[Google Chrome](https://www.google.com/chrome/)浏览器(当前要求核心版本 **130** 以上,以后只会更高,且暂时无暇理会任何兼容性需求)。
1.[RELEASE](https://github.com/MotooriKashin/Bilibili-2019/releases)页面下载最新的版本
2. 解压到本地磁盘任意目录
3. 打开 Chrome [管理扩展程序](chrome://extensions/)页面打开右上角的【开发者模式】
4. 点击【加载已解压的扩展程序】按钮加载刚解压出的文件所在目录
5. 更新版本请重复上述步骤

另外,也可以克隆项目到本地手动构建,参看[代码贡献指南](.github/contributing.md)

# 维护
欢迎念旧的人一起搭建记忆中的Bilibili,这里有一份简易的[代码贡献指南](.github/contributing.md)供参考

---
# 开源
[MIT License](LICENSE)
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"dependencies": {
"flv.js": "*"
"flv.js": "*",
"easyqrcodejs": "*"
},
"devDependencies": {
"@types/fs-extra": "*",
Expand Down
Binary file added src/assets/checked.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/flesh.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion src/dash-player/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ interface IMPDJsonData {
duration: number;
dolby?: {
type: number;
audio: IAVStreamSegment[];
audio?: IAVStreamSegment[];
};
flac?: {
display: boolean;
Expand Down
7 changes: 6 additions & 1 deletion src/io/com/bapis/bilibili/playershared/VideoVod.proto
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,12 @@ message VideoVod {
optional int32 force_host = 7;
/** 是否4K */
optional bool fourk = 8;
/** 视频编码 */
/**
* 视频编码
* | 0 | 1 | 2 | 3 |
* | :-: | :-: | :-: | :-: |
* | 不指定 | AVC | HEVC | AV1 |
*/
CodeType prefer_codec_type = 9;
/** 响度均衡 */
optional uint64 voice_balance = 10;
Expand Down
7 changes: 6 additions & 1 deletion src/io/com/bapis/bilibili/playershared/VideoVod.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/io/com/bapis/bilibili/playershared/VodInfo.proto
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,12 @@ message DashVideo {
repeated string backup_url = 2;
/** 带宽 */
uint32 bandwidth = 3;
/** 编码id */
/**
* 编码id
* | 7 | 12 | 13 |
* | :-: | :-: | :-: |
* | AVC | HEVC | AV1 |
*/
uint32 codecid = 4;
/** md5 */
optional string md5 = 5;
Expand Down
7 changes: 6 additions & 1 deletion src/io/com/bapis/bilibili/playershared/VodInfo.ts

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/io/com/bilibili/api/pgc/player/web/playurl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export interface IDash {
width: number;
}[];
dolby: {
audio: IDash['audio'];
audio?: IDash['audio'];
type: number;
};
duration: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Passport } from "../../..";
import { RestType } from "../../../../../../code";
import { sign } from "../../../../../../sign";

/** TV端扫码登录 */
Expand All @@ -13,12 +14,14 @@ export async function auth_code() {
ts: (Date.now() / 1000).toFixed(0),
}), '27eb53fc9058f8c3'),
});
return <IAuthCode>(await response.json()).data;
return <IAuthCode>await response.json();
}

interface IAuthCode {
/** 二维码内容 url */
url: string;
/** 扫码登录秘钥 */
auth_code: string;
interface IAuthCode extends RestType {
data: {
/** 二维码内容 url */
url: string;
/** 扫码登录秘钥 */
auth_code: string;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ interface IPoll extends RestType {
*/
code: number;
/** 当且仅当 code===0 时登录成功 */
data?: IPollData;
data: IPollData;
}

interface IPollData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ export async function PlayViewUnite(
cid,
qn = QUALITY.P_8K,
extraContent = {},
preferCodecType = 0,
mid = 0n,
fnval = FNVAL.DASH_H265 ^ FNVAL.HDR ^ FNVAL.DASH_4K ^ FNVAL.DOLBY_AUDIO ^ FNVAL.DOLBY_VIDEO ^ FNVAL.DASH_8K ^ FNVAL.DASH_AV1
}: IPlayViewUnite) {
const rep = PlayViewUniteReq.encode({
vod: VideoVod.create({ aid, cid, qn: BigInt(qn), fnval, forceHost: 2, qnTrial: 1 }),
vod: VideoVod.create({ aid, cid, qn: BigInt(qn), fnval, forceHost: 2, preferCodecType, qnTrial: 1 }),
extraContent,
}).finish();
const body = new Uint8Array(await new Response(new Blob([rep]).stream().pipeThrough(new CompressionStream('gzip'))).arrayBuffer());
Expand All @@ -40,4 +41,11 @@ interface IPlayViewUnite {
mid?: bigint;
/** 视频流格式 */
fnval?: number;
/**
* 视频编码
* | 0 | 1 | 2 | 3 |
* | :-: | :-: | :-: | :-: |
* | 不指定 | AVC | HEVC | AV1 |
*/
preferCodecType?: number;
}
164 changes: 164 additions & 0 deletions src/main/accessKey/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
@scope {
:scope {
color-scheme: light dark;

--000000a6: #000000a6;
--999: #999;
--00a1d6: #00a1d6;
--e7e7e7: #e7e7e7;
--212121: #212121;
--ffffffe6: #ffffffe6;
--fff: #fff;
--505050: #505050;

border: 0;
border-radius: 8px;
box-shadow: 0 0 6px rgba(0, 0, 0, .1);
padding: 52px 65px 29px 92px;
background-image: url(https://s1.hdslb.com/bfs/seed/jinkela/short/mini-login/img/22_open.72c00877.png), url(https://s1.hdslb.com/bfs/seed/jinkela/short/mini-login/img/33_open.43a09438.png);
background-position: 0 100%, 100% 100%;
background-repeat: no-repeat, no-repeat;
background-size: 14%;
}

&::backdrop {
background-color: var(--000000a6);
}

a {
text-decoration: none;
}
}

.container {
display: flex;
flex-direction: column;
row-gap: 40px;

>.wrap {
display: flex;
column-gap: 40px;

>.left {
display: flex;
flex-direction: column;
row-gap: 18px;

>header {
text-align: center;
font-size: 18px;
color: var(--212121);
}

>.panel {
inline-size: 173px;
block-size: 173px;
border-radius: 8px;
border: 1px solid var(--e7e7e7);
display: flex;
justify-content: center;
align-items: center;
position: relative;

>.qrcode {
inline-size: 160px;
block-size: 160px;

>canvas {
inline-size: inherit;
block-size: inherit;
}
}

>.qrtip {
position: absolute;
block-size: 173px;
}

>.progress {
position: absolute;
inline-size: inherit;
block-size: inherit;
background-color: var(--ffffffe6);
border: 1px solid var(--e7e7e7);
border-radius: 8px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
row-gap: 4px;

&:not(.d) {
display: none;
}

>:first-child {
inline-size: 56px;
block-size: 56px;
background-position: center;
background-repeat: no-repeat;
background-color: var(--fff);
border-radius: 50%;
}

&.to>:first-child {
background-image: url(../../assets/flesh.png);
}

&.sd>:first-child {
background-image: url(../../assets/checked.png);
}

>:not(:first-child) {
font-size: 13px;
color: var(--505050);
}

}

&:not(:has(~footer a:hover))>.qrtip {
display: none;
}
}

>footer {
color: var(--212121);
font-size: 14px;
display: flex;
flex-direction: column;
align-items: center;

a {
color: var(--00a1d6);
}
}
}

>.line {
background-color: var(--e7e7e7);
inline-size: 1px;
}

>.right {
inline-size: 400px;

>header {
text-align: center;
font-size: 18px;
color: var(--212121);
}
}
}

>.buttom {
font-size: 13px;
color: var(--999);
display: flex;
flex-direction: column;
align-items: center;

a {
color: var(--00a1d6);
}
}
}
2 changes: 2 additions & 0 deletions src/main/accessKey/index.d.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
declare const stylesheet: CSSStyleSheet;
export default stylesheet;
Loading

0 comments on commit 079df62

Please sign in to comment.