Skip to content

Commit

Permalink
add eslint conf + apply formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
miraclx committed Oct 2, 2021
1 parent 14cd19a commit 0601faa
Show file tree
Hide file tree
Showing 8 changed files with 2,258 additions and 30 deletions.
41 changes: 41 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"parser": "babel-eslint",
"env": {
"browser": true,
"es6": true,
"node": true
},
"parserOptions": {
"sourceType": "module",
"ecmaVersion": 2021,
"ecmaFeatures": {
"modules": true
}
},
"extends": [
"eslint:recommended"
],
"plugins": [
"prettier"
],
"rules": {
"no-empty": 0,
"no-sparse-arrays": 0,
"prettier/prettier": [
1,
{
"trailingComma": "all",
"printWidth": 130,
"bracketSpacing": false,
"arrowParens": "avoid",
"singleQuote": true
}
],
"no-unused-vars": [
1,
{
"argsIgnorePattern": "^_"
}
]
}
}
47 changes: 26 additions & 21 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ function getRetryMessage({meta, ref, retryCount, maxRetries, bytesRead, totalByt
Number.isFinite(maxRetries) ? `/:{color(yellow)}${maxRetries}:{color:close(yellow)}` : ''
}}: `,
lastErr
? `${lastErr.code ? `[:{color(yellow)}${lastErr.code}:{color:close(yellow)}] ` : ''}(:{color(yellow)}${lastErr.message ||
lastErr}:{color:close(yellow)}) `
? `${lastErr.code ? `[:{color(yellow)}${lastErr.code}:{color:close(yellow)}] ` : ''}(:{color(yellow)}${
lastErr.message || lastErr
}:{color:close(yellow)}) `
: '',
totalBytes
? `(:{color(cyan)}${
Expand Down Expand Up @@ -618,20 +619,27 @@ async function init(queries, options) {
}
let {namespace} = Config.playlist;
namespace = namespace ? xurl.format(xurl.parse(namespace)).concat('/') : '';
validStats.forEach(({meta: {track: {uri, name, artists, duration}, service, outFilePath}}) =>
plStream.write(
[
'',
`#${service[symbols.meta].DESC} URI: ${uri}`,
`#EXTINF:${Math.round(duration / 1e3)},${artists[0]} - ${name}`,
`${namespace.concat(
(entry => (!Config.playlist.escape ? entry : encodeURI(entry).replace(/#/g, '%23')))(
xpath.relative(BASE_DIRECTORY, outFilePath),
),
)}`,
'',
].join('\n'),
),
validStats.forEach(
({
meta: {
track: {uri, name, artists, duration},
service,
outFilePath,
},
}) =>
plStream.write(
[
'',
`#${service[symbols.meta].DESC} URI: ${uri}`,
`#EXTINF:${Math.round(duration / 1e3)},${artists[0]} - ${name}`,
`${namespace.concat(
(entry => (!Config.playlist.escape ? entry : encodeURI(entry).replace(/#/g, '%23')))(
xpath.relative(BASE_DIRECTORY, outFilePath),
),
)}`,
'',
].join('\n'),
),
);
plStream.close();
logger.write('[done]\n');
Expand Down Expand Up @@ -990,10 +998,7 @@ async function init(queries, options) {
if (!audioFeeds || audioFeeds.err) return {meta, err: (audioFeeds || {}).err, code: 2};

const feedMeta = audioFeeds.formats.sort((meta1, meta2) => (meta1.abr > meta2.abr ? -1 : meta1.abr < meta2.abr ? 1 : 0))[0];
meta.fingerprint = crypto
.createHash('md5')
.update(`${audioSource.source.videoId} ${feedMeta.format_id}`)
.digest('hex');
meta.fingerprint = crypto.createHash('md5').update(`${audioSource.source.videoId} ${feedMeta.format_id}`).digest('hex');
const files = await downloadQueue
.push({track, meta, feedMeta, trackLogger})
.catch(errObject => Promise.reject({meta, code: 5, ...(errObject.code ? errObject : {err: errObject})}));
Expand Down Expand Up @@ -1520,7 +1525,7 @@ program
)
.option('-L, --filter-case', 'enable case sensitivity for glob matches on the filters (unimplemented)')
.option('--profile <PROFILE>', 'configuration context with which to process the search and download')
.action((args, cmd) => {
.action((_args, _cmd) => {
throw Error('Unimplemented: [CLI:search]');
})
.on('--help', () => {
Expand Down
Loading

0 comments on commit 0601faa

Please sign in to comment.