Some Codestyle fixes

This commit is contained in:
magicalunicorn 2019-03-15 17:20:42 +01:00
parent 351cfa43ed
commit ee57c4059c
1 changed files with 41 additions and 41 deletions

View File

@ -49,27 +49,27 @@ let DOWNLOAD_MODE = 'single';
const log = new Log('debug', fs.createWriteStream('SMLoadr.log')); const log = new Log('debug', fs.createWriteStream('SMLoadr.log'));
const musicQualities = { const musicQualities = {
MP3_128: { MP3_128: {
id: 1, id: 1,
name: 'MP3 - 128 kbps', name: 'MP3 - 128 kbps',
aproxMaxSizeMb: '100' aproxMaxSizeMb: '100'
}, },
MP3_256: { MP3_256: {
id: 5, id: 5,
name: 'MP3 - 256 kbps' name: 'MP3 - 256 kbps'
}, },
MP3_320: { MP3_320: {
id: 3, id: 3,
name: 'MP3 - 320 kbps', name: 'MP3 - 320 kbps',
aproxMaxSizeMb: '200' aproxMaxSizeMb: '200'
}, },
FLAC: { FLAC: {
id: 9, id: 9,
name: 'FLAC - 1411 kbps', name: 'FLAC - 1411 kbps',
aproxMaxSizeMb: '700' aproxMaxSizeMb: '700'
}, },
MP3_MISC: { MP3_MISC: {
id: 0, id: 0,
name: 'User uploaded song' name: 'User uploaded song'
} }
}; };
@ -78,37 +78,37 @@ let selectedMusicQuality = musicQualities.MP3_320;
const cliOptionDefinitions = [ const cliOptionDefinitions = [
{ {
name: 'help', name: 'help',
alias: 'h', alias: 'h',
description: 'Print this usage guide :)' description: 'Print this usage guide :)'
}, },
{ {
name: 'quality', name: 'quality',
alias: 'q', alias: 'q',
type: String, type: String,
defaultValue: 'MP3_320', defaultValue: 'MP3_320',
description: 'The quality of the files to download: MP3_128/MP3_320/FLAC' description: 'The quality of the files to download: MP3_128/MP3_320/FLAC'
}, },
{ {
name: 'path', name: 'path',
alias: 'p', alias: 'p',
type: String, type: String,
defaultValue: DOWNLOAD_DIR, defaultValue: DOWNLOAD_DIR,
description: 'The path to download the files to: path with / in the end' description: 'The path to download the files to: path with / in the end'
}, },
{ {
name: 'url', name: 'url',
alias: 'u', alias: 'u',
type: String, type: String,
defaultOption: true, defaultOption: true,
description: 'Downloads single deezer url: album/artist/playlist/profile/track url' description: 'Downloads single deezer url: album/artist/playlist/profile/track url'
}, },
{ {
name: 'downloadmode', name: 'downloadmode',
alias: 'd', alias: 'd',
type: String, type: String,
defaultValue: 'single', defaultValue: 'single',
description: 'Downloads multiple urls from list: "all" for downloadLinks.txt' description: 'Downloads multiple urls from list: "all" for downloadLinks.txt'
} }
]; ];
@ -118,12 +118,12 @@ const isCli = process.argv.length > 2;
const downloadSpinner = new ora({ const downloadSpinner = new ora({
spinner: { spinner: {
interval: 400, interval: 400,
frames: [ frames: [
'♫', '♫',
' ' ' '
] ]
}, },
color: 'white' color: 'white'
}); });
const unofficialApiUrl = 'https://www.deezer.com/ajax/gw-light.php'; const unofficialApiUrl = 'https://www.deezer.com/ajax/gw-light.php';
@ -131,8 +131,8 @@ const ajaxActionUrl = 'https://www.deezer.com/ajax/action.php';
let unofficialApiQueries = { let unofficialApiQueries = {
api_version: '1.0', api_version: '1.0',
api_token: '', api_token: '',
input: 3 input: 3
}; };
let httpHeaders; let httpHeaders;
@ -147,7 +147,7 @@ function initRequest() {
'accept-language': 'en-US,en;q=0.9,en-US;q=0.8,en;q=0.7', 'accept-language': 'en-US,en;q=0.9,en-US;q=0.8,en;q=0.7',
'accept-charset': 'utf-8,ISO-8859-1;q=0.8,*;q=0.7', 'accept-charset': 'utf-8,ISO-8859-1;q=0.8,*;q=0.7',
'content-type': 'text/plain;charset=UTF-8', 'content-type': 'text/plain;charset=UTF-8',
'cookie': 'arl=' + configService.get('arl') 'cookie': 'arl=' + configService.get('arl')
}; };
let requestConfig = { let requestConfig = {
@ -1562,7 +1562,7 @@ function downloadSingleTrack(id, trackInfos = {}, albumInfos = {}, isAlternative
const error = { const error = {
message: trackInfos.ALB_ART_NAME + ' - ' + trackInfos.SNG_TITLE_VERSION + ' \n Song already exists', message: trackInfos.ALB_ART_NAME + ' - ' + trackInfos.SNG_TITLE_VERSION + ' \n Song already exists',
name: 'songAlreadyExists' name: 'songAlreadyExists'
}; };
errorHandling(error); errorHandling(error);
@ -2205,7 +2205,7 @@ function downloadAlbumCover(trackInfos, saveFilePath, numberRetry = 0) {
if (!trackInfos.ALB_PICTURE) { if (!trackInfos.ALB_PICTURE) {
reject(); reject();
} else { } else {
if (!fs.existsSync(albumCoverSavePath)) { if (!fs.existsSync(albumCoverSavePath)) {
log.debug('Started downloading album cover for "track/' + trackInfos.SNG_ID + '". Album cover url: "' + albumCoverUrl + '"'); log.debug('Started downloading album cover for "track/' + trackInfos.SNG_ID + '". Album cover url: "' + albumCoverUrl + '"');
requestWithoutCache({ requestWithoutCache({
@ -2247,12 +2247,12 @@ function downloadAlbumCover(trackInfos, saveFilePath, numberRetry = 0) {
reject(); reject();
} }
}); });
} else { } else {
log.debug('Album cover for "track/' + trackInfos.SNG_ID + '" already exists'); log.debug('Album cover for "track/' + trackInfos.SNG_ID + '" already exists');
resolve(albumCoverSavePath); resolve(albumCoverSavePath);
}
} }
}
}); });
} }