This a way to to add your videos
Add Channel for each year
Make a link to you video dir in your recordings video
Make sure every video you want to export has a category
Every year that has a video need to have a channel ,this allows the display of the year data ,no channel then video will not be shown
Code:
mysql -umythtv mythconverg -B --exec "INSERT INTO channel SET chanid = 2004, channum ='Year' , callsign = 2004 , visible =0;"
make a link in your recordings dir to your videos , in this example I have used the link name of 'video' , you need to rember this
Code:
ln -s /myth/video /myth/tv/video
Edit every video so it has a category ,when browsing your recordings I group videos like you would normaly do with a tv series . This stops the recordings list becoming very full !
Code:
mysql -umythtv mythconverg -B --exec "SELECT * FROM `videocategory`;"
Be warned this script dose not do any error control.. it just quits. This meand that you need to remove any videos that are in the recorded tableor you will endup with a key error .
Code:
#!/usr/bin/perl
#
# Mythtv
# Adds video's to recording table
# No error control !
# by chris <mailme@chrisjoyce.id.au>
#
# To use: ./addvideos.pl
#
use strict;
use warnings;
use DBI;
use Time::Local;
use Getopt::Long;
my $path = "video";
my $embed;
my $dsn = 'dbi:mysql:mythconverg';
my $user = 'mythtv';
my $pass;
my $mySQL = "";
my $hostname ="mythtv";
my $i;
my $test_mode =0;
my $inumber = 0 ;
# get database password
unless (defined $pass) {
$pass = `grep DBPassword /usr/share/mythtv/mysql.txt | cut -f2 -d'='`;
chomp($pass);
}
my $dbh = DBI->connect($dsn, $user, $pass) || die "$DBI::errstr";
my $host_query = "SELECT SUM(CHAR_LENGTH(data)+1) as LenData FROM settings ";
my $host_query = "$host_query where value like 'VideoStartupDir' and hostname like '$hostname';";
my $sth;
my $LenData;
$sth = $dbh->prepare( $host_query );
$sth->execute || die "Could not execute ($host_query)";
if (my @row = $sth->fetchrow_array) {
$LenData = $row[0];
}
$mySQL = "SELECT videometadata.year as chanid ,QUOTE(CONCAT('Video ',videocategory.category)) as title, ";
$mySQL = "$mySQL QUOTE(videometadata.title) as subtitle , ";
$mySQL = "$mySQL QUOTE(videometadata.plot) as description, videometadata.length as length, ";
$mySQL = "$mySQL QUOTE(CONCAT('$path',SUBSTRING(videometadata.filename FROM $LenData))) as filename , ";
$mySQL = "$mySQL videometadata.userrating as stars ";
$mySQL = "$mySQL FROM videometadata, videocategory,channel WHERE ";
$mySQL = "$mySQL videometadata.category = videocategory.intid ";
$mySQL = "$mySQL AND videometadata.year = channel.chanid ORDER by title , subtitle;";
$sth = $dbh->prepare( $mySQL );
$sth->execute || die "Unable to execute query: $dbh->errstr\n";
my $isth;
while(my $row = $sth->fetchrow_arrayref()) {
my ($chanid, $title, $subtitle, $description, $length, $filename, $stars) =@$row;
## add records to db
$i = "INSERT INTO recorded SET chanid ='$chanid' , starttime= DATE_ADD('$chanid-01-01 01:00:00', INTERVAL '$inumber' HOUR), ";
$i = "$i endtime= DATE_ADD('$chanid-01-01 01:00:00', INTERVAL '$inumber:$length' HOUR_MINUTE), title=$title, ";
$i = "$i subtitle=$subtitle,description= $description, category='video',hostname='$hostname', ";
$i = "$i autoexpire= 0, basename = $filename,stars='$stars'; ";
print " $i \n\n";
if ($test_mode=="0") {
$isth = $dbh->prepare($i);
$isth->execute || die "Could not execute ($i)\n";
} else {
print("Test mode: insert would have been done\n");
print(" Query: '$i'\n");
}
$inumber++ ;
next unless -f $filename;
}
Last think .. yep will will fall over often , the video types supported is ver limited , so concider transcoding .
This script will only work with videos that have been setup with the video manager.
Just remebered , you will need to remove any videos if you are running the script for a second time , as you will see it prefix's each category with "Video " , you could try the following ( un tested )
Code:
mysql -umythtv mythconverg -B --exec "DELETE FROM category WHERE title like 'Video %';"