diff --git a/README.md b/README.md index 2d26695..a9ae991 100644 --- a/README.md +++ b/README.md @@ -111,6 +111,7 @@ spotifydl https://open.spotify.com/track/xyz | --v | --version | returns current version | | --h | --help | outputs help text | | --dl | --download-lyrics | enables downloading of lyrics | +| --oft | --output-file-type | choose which type of file to be output as |
## Notes diff --git a/config.js b/config.js index c9c6ed2..c19fd7d 100644 --- a/config.js +++ b/config.js @@ -20,6 +20,7 @@ export default { searchFormat: '', outputFormat: '{artistName}___{albumName}___{itemName}', exclusionFilters: '', + outputFileType: 'mp3' }, spotifyApi: { clientId: 'acc6302297e040aeb6e4ac1fbdfd62c3', diff --git a/lib/downloader.js b/lib/downloader.js index 7ea8b97..111e5ae 100644 --- a/lib/downloader.js +++ b/lib/downloader.js @@ -120,6 +120,7 @@ const getYoutubeDLConfig = () => { * @param {string} output path/name of file to be downloaded(songname.mp3) */ const downloader = async (youtubeLinks, output) => { + const { outputFileType } = cliInputs(); let attemptCount = 0; let downloadSuccess = false; while (attemptCount < youtubeLinks.length && !downloadSuccess) { @@ -144,7 +145,7 @@ const downloader = async (youtubeLinks, output) => { .input(download) .audioBitrate(256) .save(`${output}`) - .format('mp3'); + .format(outputFileType); }; try { diff --git a/lib/setup.js b/lib/setup.js index d0dc2c7..141d9f0 100644 --- a/lib/setup.js +++ b/lib/setup.js @@ -285,6 +285,18 @@ export function cliInputs() { 'eg. $ spotifydl --ef "live,concert"', ], }, + outputFileType: { + alias: 'oft', + default: flagsConfig.outputFileType, + type: 'string', + choices: ['mp3','flac', 'wav', 'aac'], + helpText: [ + '--output-file-type or --oft', + '* lets you decide what type of file to output as', + '* defaults to mp3', + 'eg. $ spotifydl --oft "mp3"', + ], + }, }; const helpText = @@ -368,5 +380,6 @@ export function cliInputs() { password: inputFlags.password, downloadLyrics: inputFlags.downloadLyrics, outputFormat: inputFlags.outputFormat, + outputFileType: inputFlags.outputFileType, }; } diff --git a/util/runner.js b/util/runner.js index 14c76d0..a474640 100644 --- a/util/runner.js +++ b/util/runner.js @@ -37,6 +37,7 @@ const { searchFormat, exclusionFilters, outputFormat, + outputFileType } = cliInputs(); const itemOutputPath = (itemName, albumName, artistName) => { @@ -47,7 +48,7 @@ const itemOutputPath = (itemName, albumName, artistName) => { return `${path.join( path.normalize(output), ...(outputOnly ? [itemName] : generatedPathSegments), - )}.mp3`; + )}.${outputFileType}`; }; const downloadList = async list => {