mediasnacks 0.4.0 → 0.5.0

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.
@@ -15,6 +15,7 @@ _mediasnacks_commands=(
15
15
  'dlvideo: yt-dlp best video',
16
16
  'unemoji:Removes emojis from filenames'
17
17
  'rmcover:Removes cover art'
18
+ 'curltime:Measures request response timings'
18
19
  )
19
20
 
20
21
  _mediasnacks() {
@@ -25,7 +26,7 @@ _mediasnacks() {
25
26
 
26
27
  local cmd="$words[2]"
27
28
  case "$cmd" in
28
- avif|resize|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|videodiff|vconcat|dlaudio|dlvideo|unemoji|rmcover)
29
+ avif|resize|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|videodiff|vconcat|dlaudio|dlvideo|unemoji|rmcover|curltime)
29
30
  _files
30
31
  ;;
31
32
  qdir)
package/README.md CHANGED
@@ -28,7 +28,8 @@ Commands:
28
28
 
29
29
  - `unemoji`: Removes emojis from filenames
30
30
  - `rmcover`: Removes cover art
31
-
31
+
32
+ - `curltime`: Measures request response timings
32
33
  <br/>
33
34
 
34
35
  ### Converting Images to AVIF
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasnacks",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "Utilities for preparing videos, images, and audio for the web",
5
5
  "license": "MIT",
6
6
  "author": "Eric Fortis",
package/src/avif.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { join } from 'node:path'
2
4
  import { parseArgs } from 'node:util'
3
5
 
package/src/cli.js CHANGED
@@ -17,14 +17,16 @@ const COMMANDS = {
17
17
 
18
18
  framediff: ['framediff.sh', 'Plays a video of adjacent frames diff'],
19
19
  videodiff: ['videodiff.sh', 'Plays a video with the difference of two videos'],
20
-
20
+
21
21
  vconcat: ['vconcat.sh', 'Concatenates videos'],
22
-
22
+
23
23
  dlaudio: ['dlaudio.sh', 'yt-dlp best audio'],
24
24
  dlvideo: ['dlvideo.sh', 'yt-dlp best video'],
25
-
25
+
26
26
  unemoji: ['unemoji.sh', 'Removes emojis from filenames'],
27
27
  rmcover: ['rmcover.sh', 'Removes cover art'],
28
+
29
+ curltime: ['curltime.sh', 'Measures request response timings'],
28
30
  }
29
31
 
30
32
  const USAGE = `
@@ -42,7 +44,6 @@ if (opt === '-v' || opt === '--version') {
42
44
  console.log(pkgJSON.version)
43
45
  process.exit(0)
44
46
  }
45
-
46
47
  if (opt === '-h' || opt === '--help') {
47
48
  console.log(USAGE)
48
49
  process.exit(0)
@@ -52,16 +53,11 @@ if (!opt) {
52
53
  console.log(USAGE)
53
54
  process.exit(1)
54
55
  }
55
-
56
56
  if (!Object.hasOwn(COMMANDS, opt)) {
57
57
  console.error(`'${opt}' is not a command. See npx mediasnacks --help\n`)
58
58
  process.exit(1)
59
59
  }
60
60
 
61
61
  const cmd = join(import.meta.dirname, COMMANDS[opt][0])
62
- const isShellScript = cmd.endsWith('.sh')
63
- spawn(
64
- isShellScript ? cmd : process.execPath,
65
- isShellScript ? args : [cmd, ...args],
66
- { stdio: 'inherit' }
67
- ).on('exit', process.exit)
62
+ spawn(cmd, args, { stdio: 'inherit' })
63
+ .on('exit', process.exit)
@@ -0,0 +1,14 @@
1
+ #!/bin/sh
2
+
3
+ # https://stackoverflow.com/a/47944496
4
+
5
+ curl -so /dev/null -w "\
6
+ DNS Lookup %{time_namelookup}
7
+ TCP Handshake %{time_connect}
8
+ TLS Handshake %{time_appconnect}
9
+ Wait %{time_pretransfer}
10
+ Redirect %{time_redirect}
11
+ First Byte %{time_starttransfer}
12
+ ───────────────────────
13
+ TOTAL %{time_total}
14
+ " "$@"
package/src/dropdups.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { spawn } from 'node:child_process'
2
4
  import { parseArgs } from 'node:util'
3
5
  import { resolve, parse, format } from 'node:path'
package/src/hev1tohvc1.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { parseArgs } from 'node:util'
2
4
  import { unlink, rename } from 'node:fs/promises'
3
5
 
package/src/moov2front.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { parseArgs } from 'node:util'
2
4
  import { unlink, rename } from 'node:fs/promises'
3
5
 
@@ -20,7 +22,7 @@ async function main() {
20
22
  throw new Error(USAGE)
21
23
 
22
24
  await assertUserHasFFmpeg()
23
- console.log('Optimizing videos for progressive download…')
25
+ console.log('Optimizing video for progressive download…')
24
26
 
25
27
  for (const g of positionals)
26
28
  for (const file of await glob(g))
package/src/qdir.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { spawn } from 'node:child_process'
2
4
  import { parseArgs } from 'node:util'
3
5
  import { resolve, join } from 'node:path'
package/src/resize.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { join } from 'node:path'
2
4
  import { rename } from 'node:fs/promises'
3
5
  import { parseArgs } from 'node:util'
package/src/seqcheck.js CHANGED
@@ -1,3 +1,5 @@
1
+ #!/usr/bin/env node
2
+
1
3
  import { resolve } from 'node:path'
2
4
  import { parseArgs } from 'node:util'
3
5
  import { readdirSync } from 'node:fs'