mediasnacks 0.5.0 → 0.7.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 +4 -2
- package/README.md +3 -0
- package/package.json +1 -1
- package/src/cli.js +2 -0
- package/src/flattendir.py +23 -0
- package/src/gif.sh +35 -0
|
@@ -15,7 +15,9 @@ _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
|
+
'curltime:Measures request response timings',
|
|
19
|
+
'gif:Video to GIF',
|
|
20
|
+
'flattendir:Moves all files to top dir and deletes dirs'
|
|
19
21
|
)
|
|
20
22
|
|
|
21
23
|
_mediasnacks() {
|
|
@@ -26,7 +28,7 @@ _mediasnacks() {
|
|
|
26
28
|
|
|
27
29
|
local cmd="$words[2]"
|
|
28
30
|
case "$cmd" in
|
|
29
|
-
avif|resize|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|videodiff|vconcat|dlaudio|dlvideo|unemoji|rmcover|curltime)
|
|
31
|
+
avif|resize|moov2front|dropdups|seqcheck|hev1tohvc1|framediff|videodiff|vconcat|dlaudio|dlvideo|unemoji|rmcover|curltime|gif|flattendir)
|
|
30
32
|
_files
|
|
31
33
|
;;
|
|
32
34
|
qdir)
|
package/README.md
CHANGED
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -27,6 +27,8 @@ const COMMANDS = {
|
|
|
27
27
|
rmcover: ['rmcover.sh', 'Removes cover art'],
|
|
28
28
|
|
|
29
29
|
curltime: ['curltime.sh', 'Measures request response timings'],
|
|
30
|
+
gif: ['gif.sh', 'Video to GIF'],
|
|
31
|
+
flattendir: ['flattendir.py', 'Moves all files to top dir and deletes dirs']
|
|
30
32
|
}
|
|
31
33
|
|
|
32
34
|
const USAGE = `
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
|
|
3
|
+
import shutil
|
|
4
|
+
from pathlib import Path
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def flatten_dir(folder=Path().cwd()):
|
|
8
|
+
"""Moves all files to top dir and deletes dirs"""
|
|
9
|
+
|
|
10
|
+
for path in folder.rglob('*'):
|
|
11
|
+
if path.is_file():
|
|
12
|
+
dest = folder / path.name
|
|
13
|
+
if dest.exists():
|
|
14
|
+
dest = folder / f'{path.stem}__{path.stat().st_mtime_ns}{path.suffix}'
|
|
15
|
+
shutil.move(str(path), str(dest))
|
|
16
|
+
|
|
17
|
+
for sub in sorted(folder.rglob('*'), reverse=True):
|
|
18
|
+
if sub.is_dir() and not any(sub.iterdir()):
|
|
19
|
+
sub.rmdir()
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
if __name__ == '__main__':
|
|
23
|
+
flatten_dir()
|
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"
|