[mythtv-users] Android TV boxes
Brian J. Murrell
brian at interlinx.bc.ca
Sat Aug 26 16:43:19 UTC 2017
On Sat, 2017-08-26 at 11:02 -0500, Gerald Brandt wrote:
>
> Hi,
>
> I'm interested in your post-recording job. I assume you rename the
> file
> and move it to where Kodi can find it?
Yup. Something like:
#!/bin/bash
set -e
# list all of your storage dirs here
# this could be extracted from teh DB's storagegroup table with
# a bit of acrobatics to get them for "this" host
storage_dirs="/video/mythtv/ /storage1 /storage2"
MySQL() {
local q="$1"
local t=${2:-'\t'}
echo "$q" | mysql -h $DBHostName -P $DBPort -N -u $DBUserName -p$DBPassword $DBName | tr '\t' "$t"
}
# get the database connection values
. <(sed -ne 's/.*<\(DB.*\)>\(.*\)<.*/\1=\2/p' $HOME/.mythtv/config.xml)
if [ -z "$DBHostName" ]; then
# must be new format
. <(sed -ne '/<Database>/,/<\/Database>/s/ *<\(.*\)>\(..*\)<\/.*/\1=\2/p' $HOME/.mythtv/config.xml)
DBHostName="$Host"
DBPort="$Port"
DBUserName="$UserName"
DBPassword="$Password"
DBName="$DatabaseName"
fi
if [ -z "$DBHostName" ]; then
echo "Could not get database configuration"
exit 1
fi
file="$1"
# fully qualify the path of the source file
for d in $storage_dirs; do
if [ -f "$d/$file" ]; then
dir="$d"
break
fi
done
if [ -z "$dir" ]; then
echo "Could not find $file in any storage directory"
exit 1
fi
file="$dir/$file"
outfile="$file"
# don't need path names from here on out
file=${file##*/}
outfile_fqpn=$outfile
outfile=${outfile##*/}
IFS='~' read title subtitle season episode recgroup < <(MySQL "select title,subtitle,season,episode,recgroup from recorded where basename = \"$outfile\";" '~')
outfile_dir=${outfile_fqpn%/*}
if [ "$outfile_dir" = "/video/mythtv" ]; then
tdir="/video/mythvideo/Television"
else
tdir="$outfile_dir"
fi
nfo_needed=false
if [ -z "$subtitle" ]; then
subtitle="$starttime"
fi
if [ $season = 0 -a $episode = 0 ]; then
nfo_needed=true
fi
if [ $season = 0 ]; then
season=$(date -d "$starttime" +%Y)
else
season=$(printf %02d $season)
fi
if [ $episode = 0 ]; then
episode=$(date -d "$starttime" +%j)
else
episode=$(printf %02d $episode)
fi
mkdir -p "$tdir"/"$recgroup"/"$title"/
ln "$outfile_fqpn" "$tdir"/"$recgroup"/"$title"/"S${season}E${episode} - $subtitle.${outfile_fqpn##*.}"
# let kodi know about the new file
curl --data-binary "{ \"jsonrpc\": \"2.0\", \"method\": \"VideoLibrary.Scan\", \"params\": { \"directory\": \"/net/pvr$tdir/$recgroup/$title/\" }, \"id\": \"mybash\" }" -H 'content-type: application/json;' http://kodi:8080/jsonrpc
This was extracted from a larger script so there might be some
redundancies and/or missing details, but it's the general idea.
There is probably already a script on the wiki that does something like
this also. Worth checking out.
b.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 488 bytes
Desc: This is a digitally signed message part
URL: <http://lists.mythtv.org/pipermail/mythtv-users/attachments/20170826/715351fe/attachment.sig>
More information about the mythtv-users
mailing list