From 2b30dea287a262ff29c43625865a95593cd2e990 Mon Sep 17 00:00:00 2001 From: zhiyu1998 <542716863@qq.com> Date: Wed, 26 Jun 2024 21:28:47 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9E=20fix:=20=E4=BF=AE=E5=A4=8D=20dy?= =?UTF-8?q?=20=E5=9B=BD=E5=86=85=E6=9C=8D=E5=8A=A1=E5=99=A8=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E8=A7=A3=E6=9E=90=E9=97=AE=E9=A2=98=20&=20=E6=8F=90?= =?UTF-8?q?=E5=8D=87=20dy=20=E8=A7=A3=E6=9E=90=E9=80=9F=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. 使用 265 格式,提升速度降低画质 2. 使用随机均衡负载 3. 修复使用https解析出错问题 --- apps/tools.js | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/apps/tools.js b/apps/tools.js index 87271b1..645f519 100644 --- a/apps/tools.js +++ b/apps/tools.js @@ -275,10 +275,19 @@ export class tools extends plugin { const urlTypeCode = item.aweme_type; const urlType = douyinTypeMap[urlTypeCode]; if (urlType === "video") { - const resUrl = item.video.play_addr.url_list[0].replace( - "http", - "https", - ); + // logger.info(item.video); + // 多位面选择:play_addr、play_addr_265、play_addr_h264 + // H.265压缩率更高、流量省一半. 相对于H.264 + let resUrl; + // 265 和 264 随机均衡负载 + if (Math.random() > 0.5) { + const videoAddrList = item.video.play_addr_265.url_list; + resUrl = videoAddrList[videoAddrList.length - 1 || 0]; + } else { + const videoAddrList = item.video.play_addr_h264.url_list; + resUrl = videoAddrList[videoAddrList.length - 1 || 0]; + } + // logger.info(resUrl); const path = `${ this.getCurDownloadPath(e) }/temp.mp4`; await this.downloadVideo(resUrl).then(() => { this.sendVideoToUpload(e, path)