Merge pull request #118 from th-ch/dl-custom-audio-format

Downloader plugin - custom audio format
This commit is contained in:
th-ch
2021-01-12 21:35:55 +01:00
committed by GitHub
2 changed files with 8 additions and 5 deletions

View File

@ -1,7 +1,7 @@
{
"name": "youtube-music",
"productName": "YouTube Music",
"version": "1.8.0",
"version": "1.8.1",
"description": "YouTube Music Desktop App - including custom plugins",
"license": "MIT",
"repository": "th-ch/youtube-music",

View File

@ -73,6 +73,7 @@ const toMP3 = async (
options
) => {
const safeVideoName = randomBytes(32).toString("hex");
const extension = options.extension || "mp3";
try {
if (!ffmpeg.isLoaded()) {
@ -87,15 +88,17 @@ const toMP3 = async (
await ffmpeg.run(
"-i",
safeVideoName,
...options.ffmpegArgs,
safeVideoName + ".mp3"
...(options.ffmpegArgs || []),
safeVideoName + "." + extension
);
const folder = options.downloadFolder || downloadsFolder();
const filename = filenamify(videoName + ".mp3", { replacement: "_" });
const filename = filenamify(videoName + "." + extension, {
replacement: "_",
});
writeFileSync(
join(folder, filename),
ffmpeg.FS("readFile", safeVideoName + ".mp3")
ffmpeg.FS("readFile", safeVideoName + "." + extension)
);
reinit();