凉凉 更新: 给 b 站用的生成 yt-dlp 的下载工具
yt-dlp
原理是扫描所有的 a
标签并匹配是否是 video/BV...
,
若是则生成类似于 yt-dlp --cookies-from-browser safari .../video/BV... # 视频名称
的 shell 脚本,
并拷贝到剪贴板中.
// ==UserScript==
// @name YT-DLP Bilibili
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Extract bilibili video links from Bilibili user space
// @author 凉凉
// @match https://space.bilibili.com/*
// @icon https://www.google.com/s2/favicons?sz=64&domain=bilibili.com
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Your code here...
const userAgent = navigator.userAgent;
var cmd;
if (userAgent.includes("Firefox")) {
cmd = "yt-dlp --cookies-from-browser firefox ";
} else if (userAgent.includes("Opera") || userAgent.includes("OPR")) {
cmd = "yt-dlp --cookies-from-browser opera ";
} else if (userAgent.includes("Edge")) {
cmd = "yt-dlp --cookies-from-browser edge ";
} else if (userAgent.includes("Chrome")) {
cmd = "yt-dlp --cookies-from-browser chrome ";
} else if (userAgent.includes("Safari")) {
cmd = "yt-dlp --cookies-from-browser safari ";
} else {
cmd = "unknown";
}
const video_re = new RegExp("https://www.bilibili.com/video/BV[a-zA-Z0-9]{10}");
const yt_dlp = document.createElement("button");
yt_dlp.id = "ryo-yt-dlp";
yt_dlp.innerHTML = "yt-dlp";
Object.assign(yt_dlp.style, {
position: 'fixed',
left: '20px',
bottom: '20px',
width: '60px',
height: '60px',
borderRadius: '50%',
backgroundColor: "#00AEEC",
color: 'white',
border: 'none',
boxShadow: '0 2px 10px rgba(0,0,0,0.2)',
cursor: 'pointer',
alignItems: 'center',
justifyContent: 'center',
transition: 'all 0.3s ease'
});
yt_dlp.onclick = function () {
navigator.clipboard.writeText(
Array.from(document.querySelectorAll("div.bili-video-card__title > a"))
.map((a) => {
const match = a.href.match(video_re)
if (match) {
return cmd + match[0] + " # " + a.text;
} else {
return "";
}
}).join("\n"))
.then(() => {
alert("Copied! ");
})
.catch(err => {
alert("Cannot Copy... ");
})
};
document.body.appendChild(yt_dlp);
})();
(原因是某些切片上传的电视剧并没有做合集, 一个一个跳转去看还是有点麻烦的, 不如下载下来一起看)
TV-asahi (douga.tv-asahi) 的 m3u8
感谢日本落后的 IT 行业 (嘻嘻), 有一定的保护 (不是那种抽象的直接 m3u8 地址明文写在网页里面, 并且将音频轨道和视频轨道分开成两个轨道), 但是保护的不多, 可以监视网络请求并抓取 m3u8 地址, 使用 ffmpeg 命令:
ffmpeg -i <视频.m3u8> -i <音频.m3u8> -map 0:v:0 -map 1:a:0 <输出.你想要的格式, 比如 .mp4>
不过貌似并不是很清晰... 不清楚是 .mp4
压制的问题还是源本身就有问题. 不过好处就是可以白嫖新的 ドラマ 上来的时候的限免和偶尔出现的限免下载视频以后看 (有种录像带的感觉)
(不过具体如何自动抓取 m3u8
还没有想好怎么干, 目前没有想看的, 就不继续折腾下去了)
吐槽: 明明有可以把现实剧拍成那种超级无敌牛逼骗学生选择这种天坑职业的编剧能力, 怎么到了某些动画编剧, 绝大部分的综艺都搞得一坨... 不过也有有些和样板戏一样的剧情设置...