mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
🐞 fix:修复部分没有音频的b视频无法发出问题(感谢 @辰 提供样本)
This commit is contained in:
parent
16fbdd8ab7
commit
9ad9436a88
@ -483,7 +483,7 @@ export class tools extends plugin {
|
||||
* @param second
|
||||
*/
|
||||
async sendStreamSegment(e, stream_url, second = this.streamDuration) {
|
||||
let outputFilePath = `${ this.getCurDownloadPath(e) }/stream_${second}s.flv`;
|
||||
let outputFilePath = `${ this.getCurDownloadPath(e) }/stream_${ second }s.flv`;
|
||||
// 删除临时文件
|
||||
if (this.streamCompatibility) {
|
||||
await checkAndRemoveFile(outputFilePath.replace("flv", "mp4"));
|
||||
@ -899,7 +899,18 @@ export class tools extends plugin {
|
||||
// 获取下载链接
|
||||
const data = await getDownloadUrl(url, this.biliSessData);
|
||||
|
||||
await this.downBili(tempPath, data.videoUrl, data.audioUrl);
|
||||
if (data.audioUrl != null) {
|
||||
await this.downBili(tempPath, data.videoUrl, data.audioUrl);
|
||||
} else {
|
||||
// 处理无音频的情况
|
||||
await downloadBFile(data.videoUrl, `${ tempPath }.mp4`, _.throttle(
|
||||
value =>
|
||||
logger.mark("视频下载进度", {
|
||||
data: value,
|
||||
}),
|
||||
1000,
|
||||
));
|
||||
}
|
||||
|
||||
// 上传视频
|
||||
return this.sendVideoToUpload(e, `${ tempPath }.mp4`);
|
||||
|
@ -14,6 +14,7 @@ import {
|
||||
BILI_SCAN_CODE_GENERATE,
|
||||
BILI_VIDEO_INFO
|
||||
} from "../constants/tools.js";
|
||||
import { saveJsonToFile } from "./common.js";
|
||||
import { mkdirIfNotExists } from "./file.js";
|
||||
|
||||
export const BILI_HEADER = {
|
||||
@ -210,11 +211,16 @@ export async function getDownloadUrl(url, SESSDATA) {
|
||||
const { video, audio } = dash;
|
||||
const videoData = video?.[0];
|
||||
const audioData = audio?.[0];
|
||||
// saveJsonToFile(dash);
|
||||
// 提取信息
|
||||
const { backupUrl: videoBackupUrl, baseUrl: videoBaseUrl } = videoData;
|
||||
const videoUrl = selectAndAvoidMCdnUrl(videoBaseUrl, videoBackupUrl);
|
||||
const { backupUrl: audioBackupUrl,baseUrl: audioBaseUrl } = audioData;
|
||||
const audioUrl = selectAndAvoidMCdnUrl(audioBaseUrl, audioBackupUrl);
|
||||
// 有部分视频可能存在没有音频,例如:https://www.bilibili.com/video/BV1CxvseRE8n/?p=1
|
||||
let audioUrl = null;
|
||||
if (audioData != null || audioData !== undefined) {
|
||||
const { backupUrl: audioBackupUrl, baseUrl: audioBaseUrl } = audioData;
|
||||
audioUrl = selectAndAvoidMCdnUrl(audioBaseUrl, audioBackupUrl);
|
||||
}
|
||||
return { videoUrl, audioUrl };
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user