mediasnacks 0.4.0 → 0.6.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.
- package/.zsh/completions/_mediasnacks +3 -1
- package/README.md +3 -1
- package/package.json +1 -1
- package/src/avif.js +2 -0
- package/src/cli.js +8 -11
- package/src/curltime.sh +14 -0
- package/src/dropdups.js +2 -0
- package/src/gif.sh +35 -0
- package/src/hev1tohvc1.js +2 -0
- package/src/moov2front.js +3 -1
- package/src/qdir.js +2 -0
- package/src/resize.js +2 -0
- package/src/seqcheck.js +2 -0
|
@@ -15,6 +15,8 @@ _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',
|
|
19
|
+
'gif:Video to GIF'
|
|
18
20
|
)
|
|
19
21
|
|
|
20
22
|
_mediasnacks() {
|
|
@@ -25,7 +27,7 @@ _mediasnacks() {
|
|
|
25
27
|
|
|
26
28
|
local cmd="$words[2]"
|
|
27
29
|
case "$cmd" in
|
|
28
|
-
avif|resize|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|videodiff|vconcat|dlaudio|dlvideo|unemoji|rmcover)
|
|
30
|
+
avif|resize|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|videodiff|vconcat|dlaudio|dlvideo|unemoji|rmcover|curltime|gif)
|
|
29
31
|
_files
|
|
30
32
|
;;
|
|
31
33
|
qdir)
|
package/README.md
CHANGED
package/package.json
CHANGED
package/src/avif.js
CHANGED
package/src/cli.js
CHANGED
|
@@ -17,14 +17,17 @@ 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'],
|
|
30
|
+
gif: ['gif.sh', 'Video to GIF'],
|
|
28
31
|
}
|
|
29
32
|
|
|
30
33
|
const USAGE = `
|
|
@@ -42,7 +45,6 @@ if (opt === '-v' || opt === '--version') {
|
|
|
42
45
|
console.log(pkgJSON.version)
|
|
43
46
|
process.exit(0)
|
|
44
47
|
}
|
|
45
|
-
|
|
46
48
|
if (opt === '-h' || opt === '--help') {
|
|
47
49
|
console.log(USAGE)
|
|
48
50
|
process.exit(0)
|
|
@@ -52,16 +54,11 @@ if (!opt) {
|
|
|
52
54
|
console.log(USAGE)
|
|
53
55
|
process.exit(1)
|
|
54
56
|
}
|
|
55
|
-
|
|
56
57
|
if (!Object.hasOwn(COMMANDS, opt)) {
|
|
57
58
|
console.error(`'${opt}' is not a command. See npx mediasnacks --help\n`)
|
|
58
59
|
process.exit(1)
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
const cmd = join(import.meta.dirname, COMMANDS[opt][0])
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
isShellScript ? cmd : process.execPath,
|
|
65
|
-
isShellScript ? args : [cmd, ...args],
|
|
66
|
-
{ stdio: 'inherit' }
|
|
67
|
-
).on('exit', process.exit)
|
|
63
|
+
spawn(cmd, args, { stdio: 'inherit' })
|
|
64
|
+
.on('exit', process.exit)
|
package/src/curltime.sh
ADDED
|
@@ -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
package/src/gif.sh
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/bin/zsh
|
|
2
|
+
|
|
3
|
+
# Convert to GIF
|
|
4
|
+
|
|
5
|
+
FPS=10
|
|
6
|
+
WIDTH=600
|
|
7
|
+
|
|
8
|
+
usage() {
|
|
9
|
+
echo "Usage: mediasnacks gif [--fps <number>] [--width <pixels>] <file>"
|
|
10
|
+
exit 1
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
while [[ $# -gt 0 ]]; do
|
|
14
|
+
case "$1" in
|
|
15
|
+
--fps)
|
|
16
|
+
FPS="$2";
|
|
17
|
+
shift 2 ;;
|
|
18
|
+
--width)
|
|
19
|
+
WIDTH="$2"
|
|
20
|
+
shift 2 ;;
|
|
21
|
+
--help|-h)
|
|
22
|
+
usage ;;
|
|
23
|
+
*)
|
|
24
|
+
file="$1"
|
|
25
|
+
shift ;;
|
|
26
|
+
esac
|
|
27
|
+
done
|
|
28
|
+
|
|
29
|
+
[[ -z "$file" ]] && usage
|
|
30
|
+
|
|
31
|
+
outfile="${file:r}.gif"
|
|
32
|
+
|
|
33
|
+
ffmpeg -v error -i "$file" \
|
|
34
|
+
-vf "fps=${FPS},scale=${WIDTH}:-1" \
|
|
35
|
+
"$outfile"
|
package/src/hev1tohvc1.js
CHANGED
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
|
|
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
package/src/resize.js
CHANGED