std.c: Improve some comments
[sunny256-utils.git] / til-kron
blob13db19748996bb3d92a0eb252aaed31edcfb7f40
1 #!/bin/sh
3 #==============================================================================
4 # til-kron
5 # File ID: b4f0f5ce-4564-11ef-bb0e-83850402c3ce
7 # [Description]
9 # Author: Øyvind A. Holm <sunny@sunbase.org>
10 # License: GNU General Public License version 2 or later.
11 #==============================================================================
13 progname=til-kron
14 VERSION=0.0.0
16 opt_help=0
17 opt_quiet=0
18 opt_verbose=0
19 while test -n "$1"; do
20 case "$1" in
21 -h|--help) opt_help=1; shift ;;
22 -q|--quiet) opt_quiet=$(($opt_quiet + 1)); shift ;;
23 -v|--verbose) opt_verbose=$(($opt_verbose + 1)); shift ;;
24 --version) echo $progname $VERSION; exit 0 ;;
25 --) shift; break ;;
27 if printf '%s\n' "$1" | grep -q ^-; then
28 echo "$progname: $1: Unknown option" >&2
29 exit 1
30 else
31 break
33 break ;;
34 esac
35 done
36 opt_verbose=$(($opt_verbose - $opt_quiet))
38 GIT=git
40 if test "$opt_help" = "1"; then
41 test $opt_verbose -gt 0 && { echo; echo $progname $VERSION; }
42 cat <<END
44 Move files downloaded by yt-dlp and youtube-dl to Kron/YYYY/MM/DD/.
46 Usage: $progname [options]
48 Options:
50 -h, --help
51 Show this help.
52 -q, --quiet
53 Be more quiet. Can be repeated to increase silence.
54 -v, --verbose
55 Increase level of verbosity. Can be repeated.
56 --version
57 Print version information.
59 END
60 exit 0
63 topdir="$($GIT rev-parse --show-toplevel)"
64 tmpfile=".$progname.tmp"
65 ls -1N *.json | sort >"$tmpfile"
67 cmd="SELECT printf("
68 cmd="$cmd'unset y m d;"
69 cmd="$cmd y=%s; m=%s; d=%s;"
70 cmd="$cmd if [ -n \"\$y\" -a -n \"\$m\" -a -n \"\$d\" ]; then"
71 cmd="$cmd mkdir -p \"$topdir/Kron/\$y/\$m/\$d\";"
72 cmd="$cmd $GIT mv -v"
73 cmd="$cmd *\"%s\"*"
74 cmd="$cmd \"$topdir/Kron/\$y/\$m/\$d/\";"
75 cmd="$cmd fi;',"
76 cmd="$cmd substr(upload_date, 1, 4),"
77 cmd="$cmd substr(upload_date, 6, 2),"
78 cmd="$cmd substr(upload_date, 9, 2),"
79 cmd="$cmd ytid"
80 cmd="$cmd)"
81 cmd="$cmd FROM yt;"
83 list-youtube -F "$tmpfile" -S "$cmd" | sh
84 rm -f "$tmpfile"
86 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :