@joaodotwork/finder-video-thumbnails 1.0.0 → 1.1.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/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # finder-video-thumbnails
2
2
 
3
- [![npm version](https://img.shields.io/npm/v/@joaodotwork/finder-video-thumbnails.svg)](https://www.npmjs.com/package/@joaodotwork/finder-video-thumbnails)
4
- [![npm downloads](https://img.shields.io/npm/dm/@joaodotwork/finder-video-thumbnails.svg)](https://www.npmjs.com/package/@joaodotwork/finder-video-thumbnails)
5
- [![license](https://img.shields.io/npm/l/@joaodotwork/finder-video-thumbnails.svg)](LICENSE)
3
+ [![npm version](https://img.shields.io/npm/v/@joaodotwork%2Ffinder-video-thumbnails.svg)](https://www.npmjs.com/package/@joaodotwork/finder-video-thumbnails)
4
+ [![license](https://img.shields.io/github/license/joaodotwork/finder-video-thumbnails.svg)](LICENSE)
6
5
  [![platform](https://img.shields.io/badge/platform-macOS-lightgrey.svg)](https://www.apple.com/macos)
7
6
 
8
7
  Generate macOS Finder thumbnails for video files that don't have one, using `ffmpeg` and [`fileicon`](https://github.com/mklement0/fileicon).
@@ -30,13 +29,20 @@ npx @joaodotwork/finder-video-thumbnails <folder>
30
29
  ## Usage
31
30
 
32
31
  ```sh
33
- finder-video-thumbnails [--force] <folder> [seek_seconds]
32
+ finder-video-thumbnails [options] <folder> [seek_seconds]
34
33
  ```
35
34
 
35
+ **Arguments**
36
+
36
37
  - `<folder>` — folder to process (recursive)
37
- - `--force` — re-generate icons even if a custom icon is already set
38
38
  - `seek_seconds` — timestamp (in seconds) to grab the frame from. Defaults to `1`
39
39
 
40
+ **Options**
41
+
42
+ - `-h, --help` — show help and exit
43
+ - `-V, --version` — print version and exit
44
+ - `--force` — re-generate icons even if a custom icon is already set
45
+
40
46
  ### Examples
41
47
 
42
48
  Add thumbnails to every video in `~/Movies` (recursive):
@@ -1,21 +1,95 @@
1
1
  #!/usr/bin/env bash
2
2
  # finder-video-thumbnails
3
3
  # Generate macOS Finder thumbnails for video files using ffmpeg + fileicon.
4
- #
5
- # Usage: finder-video-thumbnails [--force] <folder> [seek_seconds]
6
- # --force re-generate icons even if one is already set
7
- # seek_seconds timestamp (in seconds) to grab the frame from. defaults to 1
8
4
 
9
5
  set -euo pipefail
10
6
 
7
+ # Resolve the script's real directory (following symlinks) so we can locate
8
+ # the package.json that ships alongside it.
9
+ _src="${BASH_SOURCE[0]}"
10
+ while [[ -h "$_src" ]]; do
11
+ _dir="$( cd -P "$( dirname "$_src" )" && pwd )"
12
+ _src="$( readlink "$_src" )"
13
+ [[ $_src != /* ]] && _src="$_dir/$_src"
14
+ done
15
+ _script_dir="$( cd -P "$( dirname "$_src" )" && pwd )"
16
+ _pkg_json="$_script_dir/../package.json"
17
+
18
+ read_version() {
19
+ if [[ -f "$_pkg_json" ]]; then
20
+ grep '"version"' "$_pkg_json" | head -1 \
21
+ | sed -E 's/.*"version"[[:space:]]*:[[:space:]]*"([^"]+)".*/\1/'
22
+ else
23
+ echo "unknown"
24
+ fi
25
+ }
26
+
27
+ print_version() {
28
+ echo "finder-video-thumbnails $(read_version)"
29
+ }
30
+
31
+ print_help() {
32
+ cat <<'EOF'
33
+ finder-video-thumbnails — Generate macOS Finder thumbnails for video files
34
+
35
+ Usage:
36
+ finder-video-thumbnails [options] <folder> [seek_seconds]
37
+
38
+ Arguments:
39
+ <folder> folder to process (recursive)
40
+ seek_seconds timestamp (in seconds) to grab the frame from (default: 1)
41
+
42
+ Options:
43
+ -h, --help show this help and exit
44
+ -V, --version print version and exit
45
+ --force re-generate icons even if one is already set
46
+
47
+ Examples:
48
+ finder-video-thumbnails ~/Movies
49
+ finder-video-thumbnails ~/Movies 5
50
+ finder-video-thumbnails --force ~/Movies
51
+
52
+ Supported formats:
53
+ .mov .mp4 .m4v .avi .mkv .webm
54
+
55
+ Requires:
56
+ ffmpeg, fileicon (brew install ffmpeg fileicon)
57
+ EOF
58
+ }
59
+
11
60
  force=0
12
- if [[ "${1:-}" == "--force" ]]; then
13
- force=1
14
- shift
15
- fi
61
+ while [[ $# -gt 0 ]]; do
62
+ case "$1" in
63
+ -h|--help)
64
+ print_help
65
+ exit 0
66
+ ;;
67
+ -V|--version)
68
+ print_version
69
+ exit 0
70
+ ;;
71
+ --force)
72
+ force=1
73
+ shift
74
+ ;;
75
+ --)
76
+ shift
77
+ break
78
+ ;;
79
+ -*)
80
+ echo "error: unknown option: $1" >&2
81
+ echo "run 'finder-video-thumbnails --help' for usage" >&2
82
+ exit 1
83
+ ;;
84
+ *)
85
+ break
86
+ ;;
87
+ esac
88
+ done
16
89
 
17
90
  if [[ $# -lt 1 ]]; then
18
- echo "usage: finder-video-thumbnails [--force] <folder> [seek_seconds]" >&2
91
+ echo "usage: finder-video-thumbnails [options] <folder> [seek_seconds]" >&2
92
+ echo "run 'finder-video-thumbnails --help' for details" >&2
19
93
  exit 1
20
94
  fi
21
95
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joaodotwork/finder-video-thumbnails",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },