std/c/README.md: Add section skeletons and don't indent lists
[sunny256-utils.git] / ydc
blob8d8d69fd51bf614fc3764a36d5cdf785486bf26d
1 #!/bin/sh
3 #==============================================================================
4 # ydc
5 # File ID: cc9e58bc-9e74-11e8-ae29-db5caa6d21d3
7 # Wrapper around the yd* youtube-dl / yt-dlp scripts, checks that the video
8 # hasn't been downloaded before.
10 # Author: Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later.
12 #==============================================================================
14 progname=ydc
15 VERSION=0.3.0
17 T_BOLD=$(tput bold)
18 T_RED=$(tput setaf 1)
19 T_RESET=$(tput sgr0)
21 # FIXME: Hardcoding
22 dellog=/tmp/musikk-del.log
23 delloglock="$dellog.lock"
24 repo=/home/annex/musikk
26 if test "$1" = "--version"; then
27 echo $progname $VERSION
28 exit 0
31 if test "$1" = "-h" -o "$1" = "--help"; then
32 cat <<END
34 Wrapper around the yd* youtube-dl / yt-dlp scripts, checks that the
35 video hasn't been downloaded before. Works with links understood by the
36 ydid(1) script.
38 Usage: $progname [options] YDPROG
40 Options:
42 -h, --help
43 Show this help.
44 --version
45 Print version information.
47 END
48 exit 0
51 ydprog=$1
52 if [ -z "$ydprog" ]; then
53 echo $progname: Missing ydprog argument >&2
54 exit 1
57 until mkdir "$delloglock" 2>/dev/null; do
58 echo $progname: $delloglock: Waiting for lockdir >&2
59 sleep 1
60 done
62 cd "$repo" && (
63 git log --name-status --format= | grep ^D >"$dellog" || true
66 rmdir "$delloglock" || exit 1
68 while :; do
69 read -p "$ydprog URL: " orig_gr
70 test -z "$orig_gr" && continue
71 gr=$(ydid "$orig_gr")
72 test -z "$gr" && continue
73 echo grep -- $gr
74 (cd "$repo" \
75 && (find *; cat "$dellog" $repo/transp/1/hent.sh)) \
76 | grep --color=always -- $gr || ($ydprog -- $(ydid -c "$orig_gr") &)
77 if ls | grep -q -- -$gr\\.temp\\.; then
78 echo -n "$T_RED$T_BOLD"
79 rm -v *-$gr*.temp.*
80 echo -n "$T_RESET"
82 done
84 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :