sumdur: New script, calculates duration for multiple media files
[sunny256-utils.git] / ydc
blobe6d34b622bbd9a4221840855818780b2c4f18a49
1 #!/bin/sh
3 #==============================================================================
4 # ydc
5 # File ID: cc9e58bc-9e74-11e8-ae29-db5caa6d21d3
7 # Wrapper around the yd* youtube-dl scripts, checks that the video hasn't been
8 # 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.2.0
17 # FIXME: Hardcoding
18 dellog=/tmp/musikk-del.log
19 delloglock="$dellog.lock"
20 repo=/home/annex/musikk
22 if test "$1" = "--version"; then
23 echo $progname $VERSION
24 exit 0
27 if test "$1" = "-h" -o "$1" = "--help"; then
28 cat <<END
30 Wrapper around the yd* youtube-dl scripts, checks that the video hasn't
31 been downloaded before. Works only with standard Youtube links atm.
33 Usage: $progname [options] YDPROG YOUTUBE_URL
35 Options:
37 -h, --help
38 Show this help.
39 --version
40 Print version information.
42 END
43 exit 0
46 ydprog=$1
47 if [ -z "$ydprog" ]; then
48 echo $progname: Missing ydprog argument >&2
49 exit 1
52 until mkdir "$delloglock" 2>/dev/null; do
53 echo $progname: $delloglock: Waiting for lockdir >&2
54 sleep 1
55 done
57 cd "$repo" && (
58 git log --name-status --format= | grep ^D >"$dellog" || true
61 rmdir "$delloglock" || exit 1
63 while :; do
64 read -p "URL: " orig_gr
65 test -z "$orig_gr" && continue
66 gr=$(ydid "$orig_gr")
67 test -z "$gr" && continue
68 echo grep -- $gr
69 (cd "$repo" && (find *; cat "$dellog")) | grep -- $gr ||
70 ($ydprog -- $(ydid -c "$orig_gr") &)
71 done
73 # vim: set ts=8 sw=8 sts=8 noet fo+=w tw=79 fenc=UTF-8 :