#!/bin/bash ids=$(echo -n "select intid from videometadata where filename like 'Local%'" | mysql --host=mara.ddp.net --user=mythtv --password=mythtv mythconverg 2>&1 | grep -v 'Using a password' | tail -n+2) echo $ids for id in $ids; do title=$(echo -n "select title from videometadata where intid = '$id'" | mysql --host=mara.ddp.net --user=mythtv --password=mythtv mythconverg 2>&1 | grep -v 'Using a password' | tail -n1) subtitle=$(echo -n "select subtitle from videometadata where intid = '$id'" | mysql --host=mara.ddp.net --user=mythtv --password=mythtv mythconverg 2>&1 | grep -v 'Using a password' | tail -n1) description=$(echo -n "select plot from videometadata where intid = '$id'" | mysql --host=mara.ddp.net --user=mythtv --password=mythtv mythconverg 2>&1 | grep -v 'Using a password' | tail -n1) filename=$(echo -n "select filename from videometadata where intid = '$id'" | mysql --host=mara.ddp.net --user=mythtv --password=mythtv mythconverg 2>&1 | grep -v 'Using a password' | tail -n1) date=$(echo -n "select insertdate from videometadata where intid = '$id'" | mysql --host=mara.ddp.net --user=mythtv --password=mythtv mythconverg 2>&1 | grep -v 'Using a password' | tail -n1) echo "processing ($filename) -- $id: $title ($sub_title): $plot" if [ x"$subtitle" != x"" ]; then title="$title: $subtitle" fi input_filename="/myth/videos/$filename" input_basename=`basename $input_filename` input_base="${input_basename%.*}" category="localtv" echo "ffmpeg -i $input_filename -codec copy -metadata title=\"$title\" -metadata description=\"$description\" -metadata album=\"$category\" -metadata date=\"$date\" /myth/opt/storage/other-videos/Local\ TV/$input_base.mp4" if [ ! -f /myth/opt/storage/other-videos/Local\ TV/$year/$input_base.mp4 ] then ffmpeg -i $input_filename -codec copy -metadata title="$title" -metadata description="$description" -metadata album="$category" -metadata date="$date" /myth/opt/storage/other-videos/Local\ TV/$input_base.mp4 else echo "Skip: /myth/opt/storage/other-videos/Local\ TV/$input_base.mp4 -- Already exists!" fi done