Skip to content

Commit

Permalink
Merge pull request #262 from phyzical/feature/add-logging-to-ffmpeg-l…
Browse files Browse the repository at this point in the history
…oader

attempt to log the error when ffmpeg fails
  • Loading branch information
phyzical authored Aug 29, 2024
2 parents 8118ae4 + e8332e2 commit 6ea6596
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 27 deletions.
41 changes: 15 additions & 26 deletions lib/setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,38 +9,27 @@ import versionChecker from '../util/version-checker.js';
import { logFailure } from '../util/log-helper.js';

const ffmpegSetup = function (platform_name) {
switch (platform_name) {
case 'win32': {
try {
const ffmpeg_paths = execSync('where ffmpeg');
if (ffmpeg_paths.includes('Could not find file')) {
try {
switch (platform_name) {
case 'win32': {
if (execSync('where ffmpeg').includes('Could not find file')) {
process.env.PATH = path.resolve(__dirname, 'bin;') + process.env.PATH;
}
break;
} catch (err) {
logFailure("Couldn't find ffmpeg. Please install https://ffmpeg.org");
}
break;
}
case 'linux':
case 'android':
case 'darwin':
try {
const ffmpeg_paths = execSync('which ffmpeg');
if (ffmpeg_paths == null) {
logFailure(
"ERROR: Cannot find ffmpeg! Install it first, \
why don't you read README.md on git!"
);
process.exit(-1);
} else {
case 'linux':
case 'android':
case 'darwin':
if (execSync('which ffmpeg')) {
execSync('export FFMPEG_PATH=$(which ffmpeg)');
} else {
process.exit(-1);
}

break;
} catch (error) {
logFailure("Couldn't find ffmpeg. Please install https://ffmpeg.org");
}
}
} catch (err) {
logFailure(`Couldn't find ffmpeg. Please install https://ffmpeg.org (Error:${err.message})`);
process.exit(-1);
}
};

Expand Down Expand Up @@ -289,7 +278,7 @@ export function cliInputs() {
alias: 'oft',
default: flagsConfig.outputFileType,
type: 'string',
choices: ['mp3','flac', 'wav', 'aac'],
choices: ['mp3', 'flac', 'wav', 'aac'],
helpText: [
'--output-file-type or --oft',
'* lets you decide what type of file to output as',
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@swapnilsoni1999/spotify-dl",
"productName": "Spotify Downloader",
"version": "1.2.5",
"version": "1.2.6",
"description": "Spotify Songs, Playlist & Album Downloader",
"main": "app.js",
"bin": {
Expand Down

0 comments on commit 6ea6596

Please sign in to comment.