Merge pull request #32 from nikoyoke1/master

🎈pref:优化YouTuBe支持多线程下载
This commit is contained in:
Zhiyu 2024-10-17 22:00:52 +08:00 committed by GitHub
commit 14d54334d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 18 additions and 3 deletions

View File

@ -283,6 +283,8 @@ export class tools extends plugin {
this.biliResolution = this.toolsConfig.biliResolution;
// 加载youtube的限制时长
this.youtubeDuration = this.toolsConfig.youtubeDuration
// 加载youtube下载最大线程数
this.youtubemaxThreads = this.toolsConfig.youtubemaxThreads
// 加载油管下载画质选项
this.YouTubeGraphicsOptions = this.toolsConfig.YouTubeGraphicsOptions
// 加载抖音Cookie
@ -1973,7 +1975,7 @@ export class tools extends plugin {
} else {
e.reply([segment.image(`${ path }/thumbnail.png`),`${ this.identifyPrefix }识别:油管,视频下载中请耐心等待 \n视频标题:${ title }\n视频时长:${(Duration / 60).toFixed(2).replace(/\.00$/, '')} 分钟`]);
}
await ytDlpHelper(path, url, isOversea, this.myProxy, true, graphics, timeRange);
await ytDlpHelper(path, url, isOversea, this.myProxy, true, graphics, timeRange, this.youtubemaxThreads);
this.sendVideoToUpload(e, `${ path }/temp.mp4`);
} catch (error) {
logger.error(error);

View File

@ -29,6 +29,7 @@ neteaseCloudAudioQuality: exhigh # 网易云解析最高音质 默认exhigh(极
YouTubeGraphicsOptions: 720 # YouTobe的下载画质0为原画1080720480自定义画面高度默认为720
youtubeDuration: 300 # YouTobe限制的最大视频时长默认5分钟单位
youtubemaxThreads: 1 # YouTobe下载最大线程数 默认1
douyinCookie: '' # douyin's cookie, 格式odin_tt=xxx;passport_fe_beating_status=xxx;sid_guard=xxx;uid_tt=xxx;uid_tt_ss=xxx;sid_tt=xxx;sessionid=xxx;sessionid_ss=xxx;sid_ucp_v1=xxx;ssid_ucp_v1=xxx;passport_assist_user=xxx;ttwid=xxx;
douyinCompression: true # true-压缩false-不压缩;是否使用压缩视频格式的抖音(默认使用),使用后加速视频发送

View File

@ -231,6 +231,17 @@ export function supportGuoba() {
placeholder: "请输入YouTuBe视频最大时长限制默认5分钟",
},
},
{
field: "tools.youtubemaxThreads",
label: "YouTuBe最大下载线程",
bottomHelpMessage:
"默认为 1,请根据自己的服务器调节,一定程度上缓解切片下载慢的问题",
component: "InputNumber",
required: false,
componentProps: {
placeholder: "请输入YouTuBe最大下载线程",
},
},
{
field: "tools.YouTubeGraphicsOptions",
label: "YouTube最高分辨率",

View File

@ -54,12 +54,13 @@ export function ytDlpGetThumbnail(path, url, isOversea, proxy) {
* @param merge 是否合并输出为 mp4 格式 (仅适用于视频合并需求)
* @param graphics YouTube画质参数
* @param timeRange 截取时间段
* @param maxThreads 最大线程数
*/
export async function ytDlpHelper(path, url, isOversea, proxy, merge = false, graphics, timeRange) {
export async function ytDlpHelper(path, url, isOversea, proxy, merge = false, graphics, timeRange, maxThreads) {
return new Promise((resolve, reject) => {
const mergeOption = merge ? '--merge-output-format "mp4"' : '';
const fParam = url.includes("youtu") ? `--download-sections "*${timeRange}" -f "bv${graphics}[ext=mp4]+ba[ext=m4a]"` : "";
const fParam = url.includes("youtu") ? `--download-sections "*${timeRange}" -f "bv${graphics}[ext=mp4]+ba[ext=m4a]" --concurrent-fragments ${maxThreads} ` : "";
const command = `yt-dlp ${fParam} ${constructProxyParam(isOversea, proxy)} -P ${path} -o "temp.%(ext)s" ${url}`;