Skip to content

Commit

Permalink
Merge pull request th-ch#118 from th-ch/dl-custom-audio-format
Browse files Browse the repository at this point in the history
Downloader plugin - custom audio format
  • Loading branch information
th-ch committed Jan 12, 2021
2 parents 77e24f4 + a9a840b commit 0fafed7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
11 changes: 7 additions & 4 deletions plugins/downloader/youtube-dl.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const toMP3 = async (
options
) => {
const safeVideoName = randomBytes(32).toString("hex");
const extension = options.extension || "mp3";

try {
if (!ffmpeg.isLoaded()) {
Expand All @@ -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();
Expand Down

0 comments on commit 0fafed7

Please sign in to comment.