mediasnacks 0.3.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.
@@ -13,6 +13,9 @@ _mediasnacks_commands=(
13
13
  'vconcat:Concatenates videos',
14
14
  'dlaudio: yt-dlp best audio',
15
15
  'dlvideo: yt-dlp best video',
16
+ 'unemoji:Removes emojis from filenames'
17
+ 'rmcover:Removes cover art'
18
+ 'curltime:Measures request response timings'
16
19
  )
17
20
 
18
21
  _mediasnacks() {
@@ -23,7 +26,7 @@ _mediasnacks() {
23
26
 
24
27
  local cmd="$words[2]"
25
28
  case "$cmd" in
26
- avif|resize|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|videodiff|vconcat)
29
+ avif|resize|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|videodiff|vconcat|dlaudio|dlvideo|unemoji|rmcover|curltime)
27
30
  _files
28
31
  ;;
29
32
  qdir)
package/README.md CHANGED
@@ -22,9 +22,14 @@ Commands:
22
22
  - `framediff`: Plays a video of adjacent frames diff
23
23
  - `videodiff`: Plays a video with the difference of two videos
24
24
  - `vconcat`: Concatenates videos
25
+
25
26
  - `dlaudio`: yt-dlp best audio
26
27
  - `dlvideo`: yt-dlp best video
27
-
28
+
29
+ - `unemoji`: Removes emojis from filenames
30
+ - `rmcover`: Removes cover art
31
+
32
+ - `curltime`: Measures request response timings
28
33
  <br/>
29
34
 
30
35
  ### Converting Images to AVIF
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mediasnacks",
3
- "version": "0.3.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,11 +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
+
26
+ unemoji: ['unemoji.sh', 'Removes emojis from filenames'],
27
+ rmcover: ['rmcover.sh', 'Removes cover art'],
28
+
29
+ curltime: ['curltime.sh', 'Measures request response timings'],
25
30
  }
26
31
 
27
32
  const USAGE = `
@@ -39,7 +44,6 @@ if (opt === '-v' || opt === '--version') {
39
44
  console.log(pkgJSON.version)
40
45
  process.exit(0)
41
46
  }
42
-
43
47
  if (opt === '-h' || opt === '--help') {
44
48
  console.log(USAGE)
45
49
  process.exit(0)
@@ -49,16 +53,11 @@ if (!opt) {
49
53
  console.log(USAGE)
50
54
  process.exit(1)
51
55
  }
52
-
53
56
  if (!Object.hasOwn(COMMANDS, opt)) {
54
57
  console.error(`'${opt}' is not a command. See npx mediasnacks --help\n`)
55
58
  process.exit(1)
56
59
  }
57
60
 
58
61
  const cmd = join(import.meta.dirname, COMMANDS[opt][0])
59
- const isShellScript = cmd.endsWith('.sh')
60
- spawn(
61
- isShellScript ? cmd : process.execPath,
62
- isShellScript ? args : [cmd, ...args],
63
- { stdio: 'inherit' }
64
- ).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/rmcover.sh ADDED
@@ -0,0 +1,8 @@
1
+ #!/bin/sh
2
+
3
+ file="$1"
4
+
5
+ tmp="_no_cover_$file"
6
+ ffmpeg -v error -i "$file" -vn -c:a copy "$tmp"
7
+ mv "$file" "$file.bak"
8
+ mv "$tmp" "$file"
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'
package/src/unemoji.sh ADDED
@@ -0,0 +1,26 @@
1
+ #!/bin/sh
2
+
3
+ # Removes emoji's from filenames
4
+
5
+ find . -depth | while IFS= read -r file; do
6
+ dir=$(dirname "$file")
7
+ base=$(basename "$file")
8
+
9
+ # Remove emojis using Perl's Unicode-aware regex
10
+ newbase=$(printf '%s' "$base" | perl -CSD -pe '
11
+ s/[\x{1F600}-\x{1F64F}]//g; # Emoticons
12
+ s/[\x{1F300}-\x{1F5FF}]//g; # Misc Symbols and Pictographs
13
+ s/[\x{1F680}-\x{1F6FF}]//g; # Transport and Map
14
+ s/[\x{2600}-\x{26FF}]//g; # Misc symbols
15
+ s/[\x{2700}-\x{27BF}]//g; # Dingbats
16
+ s/[\x{1F900}-\x{1F9FF}]//g; # Supplemental Symbols and Pictographs
17
+ s/[\x{1FA70}-\x{1FAFF}]//g; # Symbols and Pictographs Extended-A
18
+ s/[\x{1F1E6}-\x{1F1FF}]//g; # Regional Indicator Symbols
19
+ ')
20
+
21
+ if [ "$base" != "$newbase" ]; then
22
+ newpath="$dir/$newbase"
23
+ echo "Renaming: $file -> $newpath"
24
+ mv -n "$file" "$newpath"
25
+ fi
26
+ done