mirror of
https://github.com/Jerryplusy/rc-plugin.git
synced 2025-10-14 16:19:18 +00:00
确保tiktok和youtube视频文件被删除
This commit is contained in:
parent
3abb3b1fa6
commit
63d24efd6b
@ -88,12 +88,14 @@ export function ytDlpGetTilt(url, isOversea, proxy, cookiePath = "") {
|
|||||||
* @param isOversea
|
* @param isOversea
|
||||||
* @param proxy
|
* @param proxy
|
||||||
* @param cookiePath
|
* @param cookiePath
|
||||||
|
* @param thumbnailFilenamePrefix 缩略图文件名前缀 (不含扩展名)
|
||||||
*/
|
*/
|
||||||
export function ytDlpGetThumbnail(path, url, isOversea, proxy, cookiePath = "") {
|
export function ytDlpGetThumbnail(path, url, isOversea, proxy, cookiePath = "", thumbnailFilenamePrefix = "thumbnail") {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
// 构造 cookie 参数
|
// 构造 cookie 参数
|
||||||
const cookieParam = constructCookiePath(url, cookiePath);
|
const cookieParam = constructCookiePath(url, cookiePath);
|
||||||
const command = `yt-dlp --write-thumbnail --convert-thumbnails png --skip-download ${cookieParam} ${constructProxyParam(isOversea, proxy)} ${url} -P "${path}" -o "thumbnail.%(ext)s"`;
|
const finalThumbnailName = thumbnailFilenamePrefix || "thumbnail"; // 确保有默认值
|
||||||
|
const command = `yt-dlp --write-thumbnail --convert-thumbnails png --skip-download ${cookieParam} ${constructProxyParam(isOversea, proxy)} ${url} -P "${path}" -o "${finalThumbnailName}.%(ext)s"`;
|
||||||
exec(command, (error, stdout, stderr) => {
|
exec(command, (error, stdout, stderr) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
logger.error(`[R插件][yt-dlp审计] Error executing ytDlpGetThumbnail: ${error}. Stderr: ${stderr}`);
|
logger.error(`[R插件][yt-dlp审计] Error executing ytDlpGetThumbnail: ${error}. Stderr: ${stderr}`);
|
||||||
@ -116,22 +118,26 @@ export function ytDlpGetThumbnail(path, url, isOversea, proxy, cookiePath = "")
|
|||||||
* @param graphics YouTube画质参数
|
* @param graphics YouTube画质参数
|
||||||
* @param timeRange 截取时间段
|
* @param timeRange 截取时间段
|
||||||
* @param maxThreads 最大并发
|
* @param maxThreads 最大并发
|
||||||
|
* @param outputFilename 输出文件名 (不含扩展名)
|
||||||
* @param cookiePath Cookie所在位置
|
* @param cookiePath Cookie所在位置
|
||||||
*/
|
*/
|
||||||
export async function ytDlpHelper(path, url, isOversea, proxy, maxThreads, merge = false, graphics, timeRange, cookiePath = "") {
|
export async function ytDlpHelper(path, url, isOversea, proxy, maxThreads, outputFilename, merge = false, graphics, timeRange, cookiePath = "") {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
let command = "";
|
let command = "";
|
||||||
// 构造 cookie 参数
|
// 构造 cookie 参数
|
||||||
const cookieParam = constructCookiePath(url, cookiePath);
|
const cookieParam = constructCookiePath(url, cookiePath);
|
||||||
|
// 确保 outputFilename 不为空,提供一个默认值以防万一
|
||||||
|
const finalOutputFilename = outputFilename || "temp_download";
|
||||||
|
|
||||||
if (url.includes("music")) {
|
if (url.includes("music")) {
|
||||||
// 这里是 YouTube Music的处理逻辑
|
// 这里是 YouTube Music的处理逻辑
|
||||||
// e.g yt-dlp -x --audio-format mp3 https://youtu.be/5wEtefq9VzM -o test.mp3
|
// e.g yt-dlp -x --audio-format mp3 https://youtu.be/5wEtefq9VzM -o test.mp3
|
||||||
command = `yt-dlp -x --audio-format flac -f ba ${cookieParam} ${constructProxyParam(isOversea, proxy)} -P ${path} -o "temp.flac" ${url}`;
|
command = `yt-dlp -x --audio-format flac -f ba ${cookieParam} ${constructProxyParam(isOversea, proxy)} -P "${path}" -o "${finalOutputFilename}.flac" ${url}`;
|
||||||
} else {
|
} else {
|
||||||
// 正常情况下的处理逻辑
|
// 正常情况下的处理逻辑
|
||||||
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]" ` : "";
|
||||||
|
|
||||||
command = `yt-dlp -N ${maxThreads} ${fParam} --concurrent-fragments ${maxThreads} ${cookieParam} ${constructProxyParam(isOversea, proxy)} -P ${path} -o "temp.%(ext)s" ${url}`;
|
command = `yt-dlp -N ${maxThreads} ${fParam} --concurrent-fragments ${maxThreads} ${cookieParam} ${constructProxyParam(isOversea, proxy)} -P "${path}" -o "${finalOutputFilename}.%(ext)s" ${url}`;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`[R插件][yt-dlp审计] ${command}`);
|
logger.info(`[R插件][yt-dlp审计] ${command}`);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user