Project

General

Profile

RE: Re-Import Existing Recordings ยป importall.sh

Hiro Protagonist, 2020-05-08 05:58

 
1
#!/bin/bash
2
#
3
# Modify to suit
4
CONFIGDIR='/volume1/@appstore/tvheadend-testing/var'
5
RECORDINGS='/volume1/TV/'
6

    
7
echo "Scanning logs and recordings"
8

    
9
COUNT=0
10

    
11
for FILE in $(find $RECORDINGS -type f -name "*.ts" -o -name "*.mkv") ; do
12
    FILENAME=$(basename $FILE)
13
    FTYPE=""
14
    NAME=${FILENAME%.ts}
15
    if [ "$FILENAME" = "$NAME" ]; then
16
      NAME=${FILENAME%.mkv}
17
      if [ "$FILENAME" != "$NAME" ]; then
18
        FTYPE=mkv
19
      fi
20
    else
21
      FTYPE=ts
22
    fi
23
    if [ "$FTYPE" = "ts" ] || [ "$FTYPE" = "mkv" ]; then
24
      LOGFILE=$(grep ${FILE} $CONFIGDIR/dvr/log/* | cut -d ':' -f 1)
25
      if [ "$LOGFILE" ]
26
      then
27
        echo "Preparing to import $(basename ${FILE}) with log $(basename ${LOGFILE})"
28
        #tvhimport.sh "${FILE}" -l $LOGFILE
29
      else
30
        echo "Preparing to import $(basename ${FILE}) with no log"
31
        #tvhimport.sh $COMMAND "${FILE}"
32
      fi
33
      let COUNT++
34
      if [ $COUNT -gt 5 ]; then
35
        exit 0
36
      fi
37
    fi
38
done
    (1-1/1)