initial commit of bin scripts into git
This commit is contained in:
120
convert_myth_afl_vid_to_plex
Executable file
120
convert_myth_afl_vid_to_plex
Executable file
@@ -0,0 +1,120 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
function fix_desc()
|
||||
{
|
||||
if [ "$description" == "None" ]
|
||||
then
|
||||
echo "#################################Need to fix empty description (y:$year - r:$round)"
|
||||
/home/ddp/bin/gfc-date.tcl $year $round -update
|
||||
fi
|
||||
}
|
||||
|
||||
function fix_team()
|
||||
{
|
||||
if [[ "$team" =~ "Nth" ]]
|
||||
then
|
||||
team="North Melbourne"
|
||||
fi
|
||||
}
|
||||
|
||||
function munge_title()
|
||||
{
|
||||
# if we already have year in the title, dont try to add it
|
||||
if [[ ! "$title" =~ "$year" ]]
|
||||
then
|
||||
title="$year $title"
|
||||
fi
|
||||
|
||||
# if we already have Geelong in the title, dont try to munge it
|
||||
if [[ "$title" =~ "Geelong" ]]
|
||||
then
|
||||
echo "SKIP munging as Geelong is in it already ------------"
|
||||
return 0
|
||||
fi
|
||||
# if filename contains home, append : team"
|
||||
if [[ "$filename" =~ "Home" ]]
|
||||
then
|
||||
[[ ${filename} =~ Home-(.*)\.[a-z]* ]]
|
||||
team=${BASH_REMATCH[1]}
|
||||
fix_team
|
||||
title="$title: Geelong vs $team"
|
||||
fi
|
||||
|
||||
# if filename contains away, append : team"
|
||||
if [[ "$filename" =~ "Away" ]]
|
||||
then
|
||||
[[ ${filename} =~ Away-(.*)\.[a-z]* ]]
|
||||
team=${BASH_REMATCH[1]}
|
||||
fix_team
|
||||
title="$title: $team vs Geelong"
|
||||
fi
|
||||
}
|
||||
|
||||
ids=$(echo -n "select intid from videometadata where filename like 'Football%'" | 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 director 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)
|
||||
[[ ${filename} =~ Football/(.*)/.* ]]
|
||||
year=${BASH_REMATCH[1]}
|
||||
echo "processing ($filename) -- $id: $year - $title"
|
||||
|
||||
munge_title "$title"
|
||||
|
||||
input_filename="/myth/videos/$filename"
|
||||
input_basename=`basename $input_filename`
|
||||
input_base="${input_basename%.*}"
|
||||
|
||||
|
||||
if [[ ${filename} =~ Football/$year/Rd0([0-9])-.* ]]
|
||||
then
|
||||
round=${BASH_REMATCH[1]}
|
||||
elif [[ ${filename} =~ Football/$year/Rd([0-9][0-9])-.* ]]
|
||||
then
|
||||
round=${BASH_REMATCH[1]}
|
||||
else
|
||||
[[ ${filename} =~ Football/$year/(..)-.* ]]
|
||||
round=${BASH_REMATCH[1]}
|
||||
fi
|
||||
|
||||
if [[ ${filename} =~ rownlow ]]
|
||||
then
|
||||
if [ $year == "2007" ]; then date="24 Sep 2007"; echo $title ; fi
|
||||
if [ $year == "2009" ]; then date="21 Sep 2009"; fi
|
||||
if [ $year == "2016" ]; then date="26 Sep 2016"; fi
|
||||
elif [ ${filename} = "Football/2009/NAB_CUP_Grand_Final_2009.mpg" ]
|
||||
then
|
||||
date="13 Mar 2009"
|
||||
elif [ ${filename} = "Football/2009/gfc-150-years.iso" ]
|
||||
then
|
||||
date="10 Aug 2009"
|
||||
elif [ ${filename} = "Football/2011/2-hours.mpg" ]
|
||||
then
|
||||
date="01 Oct 2011"
|
||||
elif [ ${filename} = "Football/2012/VFL-Grand-Final-Port-Melbourne.mpg" ]
|
||||
then
|
||||
date="23 Sep 2012"
|
||||
else
|
||||
date=`~/bin/gfc-date.tcl $year $round`
|
||||
# normal game, if the desc is empty, fix it with gfc data
|
||||
fix_desc
|
||||
fi
|
||||
|
||||
if [ $? != 0 ]; then
|
||||
echo "Failed date for (filename=$filename, y=$year, r=$round -- make it 01/01/$year"
|
||||
date="$year-01-01"
|
||||
fi
|
||||
category="afl-$year"
|
||||
|
||||
echo "ffmpeg -i $input_filename -codec copy -metadata title=\"$title\" -metadata description=\"$description\" -metadata album=\"$category\" -metadata date=\"$date\" /myth/opt/storage/other-videos/AFL/$year/$input_base.mp4"
|
||||
if [ ! -f /myth/opt/storage/other-videos/AFL/$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/AFL/$year/$input_base.mp4
|
||||
else
|
||||
echo "Skip: /myth/opt/storage/other-videos/AFL/$year/$input_base.mp4 -- Already exists!"
|
||||
fi
|
||||
done
|
||||
Reference in New Issue
Block a user