mirror of
https://github.com/Equicord/Equicord.git
synced 2025-06-07 13:43:03 -04:00
This commit is contained in:
parent
ffbc286b4b
commit
94dc90a773
1 changed files with 19 additions and 7 deletions
|
@ -103,12 +103,21 @@ export async function stop(_: IpcMainInvokeEvent) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function metadata(options: DownloadOptions) {
|
async function metadata(options: DownloadOptions) {
|
||||||
|
try {
|
||||||
stdout_global = "";
|
stdout_global = "";
|
||||||
const metadata = JSON.parse(await ytdlp(["-J", options.url, "--no-warnings"]));
|
const output = await ytdlp(["-J", options.url, "--no-warnings"]);
|
||||||
if (metadata.is_live) throw "Live streams are not supported.";
|
const metadata = JSON.parse(output);
|
||||||
|
|
||||||
|
if (metadata.is_live) throw new Error("Live streams are not supported.");
|
||||||
|
|
||||||
stdout_global = "";
|
stdout_global = "";
|
||||||
return { videoTitle: `${metadata.title || "video"} (${metadata.id})` };
|
return { videoTitle: `${metadata.title || "video"} (${metadata.id})` };
|
||||||
|
|
||||||
|
} catch (err) {
|
||||||
|
throw err;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function genFormat({ videoTitle }: { videoTitle: string; }, { maxFileSize, format }: DownloadOptions) {
|
function genFormat({ videoTitle }: { videoTitle: string; }, { maxFileSize, format }: DownloadOptions) {
|
||||||
const HAS_LIMIT = !!maxFileSize;
|
const HAS_LIMIT = !!maxFileSize;
|
||||||
const MAX_VIDEO_SIZE = HAS_LIMIT ? maxFileSize * 0.8 : 0;
|
const MAX_VIDEO_SIZE = HAS_LIMIT ? maxFileSize * 0.8 : 0;
|
||||||
|
@ -161,8 +170,11 @@ async function download({ format, videoTitle }: { format: string; videoTitle: st
|
||||||
: []
|
: []
|
||||||
: [];
|
: [];
|
||||||
const customArgs = ytdlpArgs?.filter(Boolean) || [];
|
const customArgs = ytdlpArgs?.filter(Boolean) || [];
|
||||||
|
try {
|
||||||
await ytdlp([url, ...baseArgs, ...remuxArgs, ...customArgs]);
|
await ytdlp([url, ...baseArgs, ...remuxArgs, ...customArgs]);
|
||||||
|
} catch (err) {
|
||||||
|
console.error("Error during yt-dlp execution:", err);
|
||||||
|
}
|
||||||
const file = fs.readdirSync(getdir()).find(f => f.startsWith("download."));
|
const file = fs.readdirSync(getdir()).find(f => f.startsWith("download."));
|
||||||
if (!file) throw "No video file was found!";
|
if (!file) throw "No video file was found!";
|
||||||
return { file, videoTitle };
|
return { file, videoTitle };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue