summaryrefslogtreecommitdiff
path: root/batch.sh
blob: 5673e18a2a663df43444506479b0783654eb2e8d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/bash
# Shell script to convert VDR recordings in todo.txt to mpeg4 files. No upload
#------------------------------------------------------------------------------
# Revision History
#------------------------------------------------------------------------------
#
# $Log: batch.sh,v $
# Revision 2.1  2017/04/09 12:51:15  richard
# update
#
# Revision 1.3  2016/09/01 13:08:06  richard
# Pass multiple vdr-convert flags
# Update VDR afterwards
#
# Revision 1.2  2014/12/11 15:24:41  richard
# Improvements
#
# Revision 1.1  2014/12/10 10:44:19  richard
# Initial import - as used in BKK 2014
#
#------------------------------------------------------------------------------

# Usual way to create a "todo" list is as follows:
# find $DIR -type d | grep -i '.rec$' > $DIR/todo.txt

#Default directory where we work
input='/mnt/lvm/TV'
root=$input

function usage {
    echo "usage: $0 <vdr-convert args>"
}

function logit() {
  logger -s -p local2.warn -t batch "$1"
}

#------------------------------------------------------------------------------
# Start of script
#------------------------------------------------------------------------------

[ $# -eq 0 ] && usage && exit 1

for arg in "$@";
do
  args="$args '$arg'"
done

# Timeout req'd for troublesome conversions where ffmpeg sometimes get stuck. 
# (NOTE Causes issues when run interactively.)
NAMES="$(< $(pwd)/todo.txt)" #names from todo.txt file in this directory
for NAME in $NAMES; do
#   /bin/su vdr -c vdr-convert -i "\"$NAME"\" $args"
  timeout -k 4h 3h sh -c "vdr-convert -i "\"$NAME"\" $args"
  [ $? -ne 0 ] &&  logit "vdr-convert failed: problem converting $NAME"
done

#Ask VDR to re-read the files
touch "$root/.update"

# --------- $Id: batch.sh,v 2.1 2017/04/09 12:51:15 richard Exp $ ---------- END