podcast-dl 9.2.0 → 9.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/bin/async.js CHANGED
@@ -151,7 +151,7 @@ const download = async (options) => {
151
151
  }
152
152
  };
153
153
 
154
- let downloadItemsAsync = async ({
154
+ const downloadItemsAsync = async ({
155
155
  addMp3MetadataFlag,
156
156
  archive,
157
157
  archiveUrl,
package/bin/commander.js CHANGED
@@ -1,10 +1,11 @@
1
1
  import { AUDIO_ORDER_TYPES, ITEM_LIST_FORMATS } from "./util.js";
2
2
  import { createParseNumber, hasFfmpeg } from "./validate.js";
3
3
  import { logErrorAndExit } from "./logger.js";
4
+ import { version } from "./version.js";
4
5
 
5
6
  export const setupCommander = (commander, argv) => {
6
7
  commander
7
- .version("9.2.0")
8
+ .version(version)
8
9
  .option("--url <string>", "url to podcast rss feed")
9
10
  .option(
10
11
  "--out-dir <path>",
package/bin/util.js CHANGED
@@ -10,6 +10,22 @@ import { getArchiveFilename, getItemFilename } from "./naming.js";
10
10
 
11
11
  const execWithPromise = util.promisify(exec);
12
12
 
13
+ /*
14
+ Escape arguments for a shell command used with exec.
15
+ Borrowed from shell-escape: https://github.com/xxorax/node-shell-escape/
16
+ */
17
+ const escapeArgForShell = (arg) => {
18
+ let result = arg;
19
+ if (/[^A-Za-z0-9_/:=-]/.test(result)) {
20
+ result = "'" + result.replace(/'/g, "'\\''") + "'";
21
+ result = result
22
+ .replace(/^(?:'')+/g, "") // unduplicate single-quote at the beginning
23
+ .replace(/\\'''/g, "\\'"); // remove non-escaped single-quote if there are enclosed between 2 escaped
24
+ }
25
+
26
+ return result;
27
+ };
28
+
13
29
  const getTempPath = (path) => {
14
30
  return `${path}.tmp`;
15
31
  };
@@ -507,7 +523,7 @@ const runFfmpeg = async ({
507
523
  const metadataString = Object.keys(metaKeysToValues)
508
524
  .map((key) =>
509
525
  metaKeysToValues[key]
510
- ? `-metadata ${key}="${metaKeysToValues[key].replace(/"/g, '\\"')}"`
526
+ ? `-metadata ${key}=${escapeArgForShell(metaKeysToValues[key])}`
511
527
  : null
512
528
  )
513
529
  .filter((segment) => !!segment)
package/bin/version.js ADDED
@@ -0,0 +1,2 @@
1
+ // Generated by genversion.
2
+ export const version = "9.2.1";
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "podcast-dl",
3
- "version": "9.2.0",
3
+ "version": "9.2.1",
4
4
  "description": "A CLI for downloading podcasts.",
5
5
  "type": "module",
6
6
  "bin": "./bin/bin.js",
7
7
  "scripts": {
8
8
  "build": "rimraf ./binaries && rimraf ./dist && node build.cjs",
9
- "lint": "eslint ./bin"
9
+ "lint": "eslint ./bin",
10
+ "version:generate": "npx genversion --es6 --semi ./bin/version.js"
10
11
  },
11
12
  "lint-staged": {
12
13
  "*.{js,json,md}": [