mythexport/usr/ 0000775 0000000 0000000 00000000000 14766557364 011031 5 ustar mythexport/usr/bin/ 0000775 0000000 0000000 00000000000 14766557364 011601 5 ustar mythexport/usr/bin/mythexport-daemon 0000775 0000000 0000000 00000043362 14766557364 015223 0 ustar #!/usr/bin/perl
# mythexport-daemon v2.2.3
# By: John Baab
# Email: rhpot1991@ubuntu.com
# Purpose: daemon for exporting mythtv recordings into formats used by portable devices.
# Requirements: perl and the DBI & DBD::mysql modules, MythTV perl bindings, AtomicParsley
#
# License:
#
# This Package is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# On Debian & Ubuntu systems, a complete copy of the GPL can be found under
# /usr/share/common-licenses/GPL-3, or (at your option) any later version
use strict;
use POSIX qw(setsid);
use DBI;
use DBD::mysql;
use Config::Simple;
use MythTV;
use Proc::Daemon;
use Proc::PID::File;
use Log::Dispatch;
use Log::Dispatch::File;
use Date::Format;
use File::Spec;
use File::Copy;
use XML::Writer;
use IO::File;
use lib '/usr/share/mythexport';
use lib '/usr/share/mythexport/configs';
&startDaemon;
my $debug = "";
my $level = "notice";
foreach (@ARGV){
if ($_ =~ m/debug/) {
$debug = 1;
}
}
if($debug == 1){
$level = "debug";
}
use constant LOG_DIR => '/var/log/mythtv/';
use constant LOG_FILE => 'mythexport.log';
our $HOSTNAME = `hostname`;
chomp $HOSTNAME;
my $log = new Log::Dispatch(
callbacks => sub { my %h=@_; return Date::Format::time2str('%B %e %T', time)." ".$HOSTNAME." $0\[$$]: ".$h{message}."\n"; }
);
$log->add( Log::Dispatch::File->new( name => 'file1',
min_level => $level,
mode => 'append',
filename => File::Spec->catfile(LOG_DIR, LOG_FILE),
)
);
$log->warning("Starting Processing: ".time());
open STDERR, '>>', File::Spec->catfile(LOG_DIR, LOG_FILE);
my $connect = undef;
my $myth = undef;
my $tries = 5;
while ($connect == undef && --$tries > 0) {
eval {
$myth = new MythTV();
# connect to database
$connect = $myth->{'dbh'};
1;
} or do {
logerror("Can't connect to MythTV: $@");
logdebug("Sleeping 5 seconds...");
sleep(5);
};
}
if ($connect == undef) {
die "Couldn't connect to MythTV.";
}
my $keep_going = 1;
$SIG{HUP} = sub { $log->warning("Caught SIGHUP: exiting gracefully"); $keep_going = 0; };
$SIG{INT} = sub { $log->warning("Caught SIGINT: exiting gracefully"); $keep_going = 0; };
$SIG{QUIT} = sub { $log->warning("Caught SIGQUIT: exiting gracefully"); $keep_going = 0; };
$SIG{TERM} = sub { $log->warning("Caught SIGTERM: exiting gracefully"); $keep_going = 0; };
sub startDaemon{
Proc::Daemon::Init;
dienice("Already running!") if Proc::PID::File->running(dir => "/var/run/mythtv",name => "mythexport");
}
sub dienice($) {
my ($package, $filename, $line) = caller;
$log->critical("$_[0] at line $line in $filename");
die $_[0];
}
sub logerror($) {
my ($package, $filename, $line) = caller;
$log->critical("$_[0] at line $line in $filename");
}
sub logdebug($){
my ($package, $filename, $line) = caller;
$log->debug("$_[0] at line $line in $filename");
}
sub getExportDir(){
# Set default values
my $cfg = new Config::Simple();
$cfg->read('/etc/mythtv/mythexport/mythexport.cfg') || logerror("Cannot read config file: /etc/mythtv/mythexport/mythexport.cfg");
my $exportdir = $cfg->param("dir");
$exportdir =~ s/\/$//;
return $exportdir;
}
sub createXML($){
my @params = split('&',$_[0]);
my ($exportdir, @starttime, @chanid, $config, $sql_where) = "";
foreach (@params){
if ($_ =~ m/exportdir/) {
$exportdir = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/starttime/) {
@starttime = split('\|',(split(/\=/,$_))[1]);
}
elsif ($_ =~ m/chanid/) {
@chanid = split('\|',(split(/\=/,$_))[1]);
}
elsif ($_ =~ m/config/) {
$config = (split(/\=/,$_))[1];
}
}
# debugging logging
logdebug("exportdir = $exportdir");
logdebug("starttime = @starttime");
logdebug("chanid = @chanid");
logdebug("config = $config");
$exportdir =~ s/\/$//;
require "$config.pm";
my $object = new $config();
my $extension = $object->Extension;
#test that the directory has the correct permissions
-w $exportdir || logerror("ERROR: Directory $exportdir is not writeable.\n");
my $output = new IO::File(">$exportdir/mythimport.xml");
# create sql where clause
foreach my $i (0..scalar(@chanid)-1)
{
$sql_where .= "(rec.chanid=\'$chanid[$i]\' and rec.starttime=\'$starttime[$i]\') or ";
}
$sql_where =~ s/\sor\s$//;
print $output "";
my $writer = new XML::Writer(OUTPUT => $output);
$writer->startTag("channel");
my $query = "SELECT rec.title, rec.subtitle, rec.description, pg.syndicatedepisodenumber, pg.showtype, rec.programid, rec.basename, rec.chanid, rec.starttime
FROM recorded rec LEFT JOIN program pg ON pg.starttime = rec.starttime AND pg.chanid = rec.chanid WHERE $sql_where";
my $query_handle = $connect->prepare($query);
logdebug("query = $query");
$query_handle->execute() || logerror("Unable to query mythexport table");
$log->notice("Creating xml file");
while ( my ($title,$subtitle,$description,$syndicatedepisodenumber,$showtype,$programid,$basename,$currentchanid,$currentstarttime) = $query_handle->fetchrow_array() ) {
# FIND OUT THE CHANNEL NAME
my $subquery = "SELECT callsign FROM channel WHERE chanid=?";
my $subquery_handle = $connect->prepare($subquery);
$subquery_handle->execute($currentchanid) || logerror("ERROR: Unable to query settings table");
my $channame = $subquery_handle->fetchrow_array;
# replace non-word characters in channame with dashes
$channame =~ s/\W+/-/g;
# replace non-word characters in title with underscores
$title =~ s/\W+/_/g;
# replace non-word characters in subtitle with underscores
$subtitle =~ s/\W+/_/g;
# Remove non alphanumeric chars from $starttime & $endtime
$currentstarttime =~ s/[|^\W|\s|-|]//g;
my $newfilename = $channame."-".$title."-".$subtitle."-".$currentstarttime;
$newfilename =~ s/\..*?$//;
$writer->startTag("item");
$writer->startTag("title");
$writer->characters("$title - $subtitle");
$writer->endTag("title");
$writer->startTag("description");
$writer->characters("$description");
$writer->endTag("description");
$writer->startTag("link");
$writer->characters("$newfilename.$extension");
$writer->endTag("link");
$writer->startTag("guid");
$writer->characters("$newfilename");
$writer->endTag("guid");
$writer->endTag("item");
$log->notice("Creating mysql dump");
export("starttime=$currentstarttime&chanid=$currentchanid&config=$config&otg=true");
}
$writer->endTag("channel");
$writer->end();
$output->close();
copy("/usr/share/mythtv/mythimport.xslt","$exportdir/mythimport.xslt") || logerror("ERROR: Cannot copy /usr/share/mythtv/mythimport.xslt to $exportdir/mythimport.xslt");
}
sub createSQL($){
my @params = split('&',$_[0]);
my ($exportdir, @starttime, @chanid, $config, $sql_where) = "";
foreach (@params){
if ($_ =~ m/exportdir/) {
$exportdir = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/starttime/) {
@starttime = split('\|',(split(/\=/,$_))[1]);
}
elsif ($_ =~ m/chanid/) {
@chanid = split('\|',(split(/\=/,$_))[1]);
}
elsif ($_ =~ m/config/) {
$config = (split(/\=/,$_))[1];
}
}
# debugging logging
logdebug("exportdir = $exportdir");
logdebug("starttime = @starttime");
logdebug("chanid = @chanid");
logdebug("config = $config");
$exportdir =~ s/\/$//;
my $dbuser = $myth->{'db_user'};
my $dbpass = $myth->{'db_pass'};
my $dbhost = $myth->{'db_host'};
my $dbname = $myth->{'db_name'};
my $dbport = $myth->{'db_port'};
# debugging logging
logdebug("dbuser = $dbuser");
logdebug("dbpass = $dbpass");
logdebug("dbhost = $dbhost");
logdebug("dbname = $dbname");
logdebug("dbport = $dbport");
#test that the directory has the correct permissions
-w $exportdir || logerror("ERROR: Directory $exportdir is not writeable.\n");
# create sql where clause
foreach my $i (0..scalar(@chanid)-1)
{
$sql_where .= "(chanid=\'$chanid[$i]\' and starttime=\'$starttime[$i]\') or ";
}
$sql_where =~ s/\sor\s$//;
my $command = "mysqldump -h$dbhost -u$dbuser -p$dbpass -P$dbport $dbname recorded recordedseek recordedrating recordedprogram recordedmarkup recordedcredits --where=\"$sql_where\" --no-create-db --no-create-info > $exportdir/mythimport.sql 2>&1";
$log->notice("Creating mysql dump");
logdebug("mysqldump command = $command");
system($command) == 0 || logerror("ERROR: $command failed.");
my $query = "SELECT basename FROM recorded where $sql_where";
my $query_handle = $connect->prepare($query);
logdebug("query = $query");
$query_handle->execute() || logerror("Unable to query mythexport table");
my $schemaVer = $myth->backend_setting('DBSchemaVer');
#copy files
while ( my $basename = $query_handle->fetchrow_array() ) {
my $dir = 'UNKNOWN';
if ($schemaVer < 1171)
{
$dir = $myth->backend_setting('RecordFilePrefix');
}
else
{
my $storagegroup = new MythTV::StorageGroup();
$dir = $storagegroup->FindRecordingDir($basename);
}
$log->notice("Copying $dir/$basename to $exportdir/$basename");
copy("$dir/$basename","$exportdir/$basename") || logerror("Unable to copy $dir/$basename to $exportdir/$basename");
}
}
sub export($){
my @params = split("&",$_[0]);
my ($debug,$starttime,$chanid,$config,$deleteperiod,$otg,$podcastname) = "";
foreach (@params){
if ($_ =~ m/starttime/) {
$starttime = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/chanid/) {
$chanid = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/config/) {
$config = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/deleteperiod/) {
$deleteperiod = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/otg/) {
$otg = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/podcastname/) {
$podcastname = (split(/\=/,$_))[1];
}
}
my ($title, $subtitle, $description, $syndicatedepisodenumber, $showtype, $programid, $basename, $airdate) = "";
my $exportdir = getExportDir();
# debugging logging
logdebug("exportdir = $exportdir");
logdebug("starttime = $starttime");
logdebug("chanid = $chanid");
logdebug("config = $config");
#test that the directory has the correct permissions
-w $exportdir || logerror("ERROR: Directory $exportdir is not writeable.\n");
my $query = "SELECT rec.title, rec.subtitle, rec.description, pg.syndicatedepisodenumber, pg.showtype, rec.programid, rec.basename, rec.starttime
FROM recorded rec LEFT JOIN program pg ON pg.starttime = rec.starttime AND pg.chanid = rec.chanid
WHERE rec.chanid=? AND rec.starttime=?";
my $query_handle = $connect->prepare($query);
logdebug("query = $query");
$query_handle->execute($chanid,$starttime) || logerror("ERROR: Cannot connect to database \n");
$query_handle->bind_columns(undef, \$title, \$subtitle, \$description, \$syndicatedepisodenumber, \$showtype, \$programid, \$basename, \$airdate);
$query_handle->fetch();
my $schemaVer = $myth->backend_setting('DBSchemaVer');
# Storage Groups were added in DBSchemaVer 1171
# FIND WHERE THE RECORDINGS LIVE
my $dir = 'UNKNOWN';
if ($schemaVer < 1171)
{
logdebug("Using compatibility mode");
$dir = $myth->backend_setting('RecordFilePrefix');
}
else
{
logdebug("Going into new mode\n");
my $storagegroup = new MythTV::StorageGroup();
$dir = $storagegroup->FindRecordingDir($basename);
}
# FIND OUT THE CHANNEL NAME
$query = "SELECT callsign FROM channel WHERE chanid=?";
$query_handle = $connect->prepare($query);
logdebug("query = $query");
$query_handle->execute($chanid) || logerror("ERROR: Unable to query channel table");
my $channame = $query_handle->fetchrow_array;
# replace non-word characters in channame with dashes
$channame =~ s/\W+/-/g;
# replace non-word characters in title with underscores
my $title_old = $title;
$title =~ s/\W+/_/g;
# replace non-word characters in subtitle with underscores
my $subtitle_old = $subtitle;
$subtitle =~ s/\W+/_/g;
# Remove non alphanumeric chars from $starttime & $endtime
my $newstarttime = $starttime;
$newstarttime =~ s/[|^\W|\s|-|]//g;
my $filename = $dir."/".$basename;
my $newfilename = $exportdir."/".$channame."-".$title."-".$subtitle."-".$newstarttime;
$newfilename =~ s/\..*?$//;
$syndicatedepisodenumber =~ m/^.*?(\d*)(\d{2})$/;
my $seasonnumber = $1;
my $episodenumber = $2;
require "$config.pm";
# need the extension to calculate our file name
my $object = new $config();
my $extension = $object->Extension();
# Trim any characters over 63,
# it seems iTunes does not like files with lengths this long.
my $x = 63 - $extension;
$newfilename =~ s/^(.*\/(.{1,$x})).*$/$1/g;
my $webfilename = "$2";
if ($debug) {
print "\n\n Source filename:$filename \nDestination filename:$newfilename\n \n";
}
# move to the export directory incase any logs get written
chdir $exportdir;
# create new object with our file names
my $object = new $config($filename, $newfilename);
$object->export();
my $returnCode = $object->checkOutput();
# only continue if encoding didn't fail
if ($returnCode == 1){
if (!$debug){
# clean up any log files left behind by ffmpeg
system "rm *.log";
system "rm *.mbtree";
}
if($otg ne "true"){
# Save Data
$query = "INSERT into mythexport VALUES(NULL,?,?,?,?,NOW(),DATE_ADD(NOW(),INTERVAL ? DAY),?,?)";
$query_handle = $connect->prepare($query);
logdebug("query = $query");
$query_handle->execute("$webfilename$extension",$title_old,$subtitle,$description,$deleteperiod,$airdate,$podcastname) || logerror("ERROR: Unable to update table.");
}
}
else{
logerror("ERROR: No resulting file from ffmpeg, most likely your ffmpeg failed. Enable debugging and test by hand.");
}
}
sub delete($){
my $param = $_[0];
my $cfg = new Config::Simple();
$cfg->read('/etc/mythtv/mythexport/mythexport.cfg') || logerror("Cannot read config file: /etc/mythtv/mythexport/mythexport.cfg");
my $dir = $cfg->param("dir");
$dir =~ s/\/$//;
my $delete_query = "SELECT file FROM mythexport where id=?";
my $delete_query_handle = $connect->prepare($delete_query);
logdebug("query = $delete_query");
$delete_query_handle->execute($param) || logerror("ERROR: Unable to query mythexport table");
my $file = $delete_query_handle->fetchrow_array();
my $location = "$dir\/$file";
$log->notice("Deleting $file");
logdebug("file = $location");
unlink($location) || logerror("ERROR: Unable to find file: $location");
my $query = "delete from mythexport where id=?";
my $query_handle = $connect->prepare($query);
logdebug("query = $query");
$query_handle->execute($param) || logerror("Unable to delete from mythexport table");
}
# our infinite loop
while($keep_going) {
my $query = "select id, type, param from mythexport_job_queue order by id";
my $query_handle = $connect->prepare($query);
logdebug("query = $query");
$query_handle->execute() || logerror("Unable to query mythexport_job_queue table");
while(my ($id, $type, $param) = $query_handle->fetchrow_array()){
if($type eq "delete"){
&delete($param);
}
elsif($type eq "export"){
&export($param);
}
elsif($type eq "otg-lightweight"){
createXML($param);
}
elsif($type eq "otg-full"){
createSQL($param);
}
else{
logerror("ERROR: job type unknown.");
}
my $job_query = "delete from mythexport_job_queue where id=?";
my $job_query_handle = $connect->prepare($job_query);
logdebug("query = $job_query");
$job_query_handle->execute($id) || logerror("Unable to delete from mythexport_job_queue table");
# remove lock file so the userjob knows that it's work is done
my $lockfile = getExportDir() . "/mythexport.$id";
if (-e $lockfile){
unlink($lockfile);
}
}
# wait for 60 seconds
sleep(60);
}
$log->warning("Stopping Processing: ".time());
mythexport/usr/bin/mythexport_addjob 0000775 0000000 0000000 00000006643 14766557364 015266 0 ustar #!/usr/bin/perl
# mythexport_addjob v2.2.3
# By: John Baab
# Email: rhpot1991@ubuntu.com
# Purpose: Script for creating a mythexport job.
# Requirements: perl and the DBI & DBD::mysql modules, MythTV perl bindings
#
# License:
#
# This Package is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# On Debian & Ubuntu systems, a complete copy of the GPL can be found under
# /usr/share/common-licenses/GPL-3, or (at your option) any later version
use DBI;
use DBD::mysql;
use MythTV;
use Config::Simple;
use strict;
my $connect = undef;
my $debug = 0;
# Set default values
my $cfg = new Config::Simple();
$cfg->read('/etc/mythtv/mythexport/mythexport.cfg') || logerror("Cannot read config file: /etc/mythtv/mythexport/mythexport.cfg");
my $exportdir = $cfg->param("dir");
$exportdir =~ s/\/$//;
my ($starttime, $chanid, $config, $deleteperiod, $podcastname) = "";
my $usage = "\nHow to use mythexport : \n"
."\nchanid = Channel ID associated with the recording to export.\n"
."starttime = Recording start time in either 'yyyy-mm-dd hh:mm:ss' or 'yyyymmddhhmmss' format.\n"
."config = Name of configuration settings.\n"
."\nExample: mythexport_add starttime=20060803205900 chanid=1006 config=ipod\n";
# get this script's ARGS
my $num = $#ARGV + 1;
# if user hasn't passed enough arguments, die and print the usage info
if ($num <= 2) {
die "$usage";
}
# Get all the arguments
foreach (@ARGV){
if ($_ =~ m/debug/) {
$debug = 1;
}
elsif ($_ =~ m/starttime/) {
$starttime = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/chanid/) {
$chanid = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/config/) {
$config = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/deleteperiod/) {
$deleteperiod = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/podcastname/) {
$podcastname = (split(/\=/,$_))[1];
}
}
my $myth = new MythTV();
# connect to database
$connect = $myth->{'dbh'};
my $query = "SELECT title, subtitle from recorded where chanid=? and starttime=?";
my $query_handle = $connect->prepare($query);
$query_handle->execute($chanid,$starttime) || die("Unable to query recordings table");
my ($title, $subtitle) = $query_handle->fetchrow_array;
my $param = "starttime=$starttime&chanid=$chanid&config=$config&deleteperiod=$deleteperiod&podcastname=$podcastname";
# add export job
$query = "insert into mythexport_job_queue(type,param,id,description) values ('export',?,NULL,?)";
$query_handle = $connect->prepare($query);
$query_handle->execute($param,"$title:$subtitle") || die "Unable to query mythexport_job_queue table";
my $id = $query_handle->{mysql_insertid};
my $lockfile = "$exportdir/mythexport.$id";
# create a lock file and wait for it to be deleted by the daemon before we complete the user job
system("touch $lockfile");
while (-e $lockfile) {sleep(60);}
mythexport/usr/bin/mythimport 0000775 0000000 0000000 00000006033 14766557364 013745 0 ustar #!/usr/bin/perl
# mythimport v2.0
# By: John Baab
# Email: john.baab@gmail.com
# Purpose: Imports recordings into an On The Go backend.
# Requirements: MythTV perl bindings
#
#
# License:
#
# This Package is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public
# License as published by the Free Software Foundation; either
# version 3 of the License, or (at your option) any later version.
#
# This package is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public
# License along with this package; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#
# On Debian & Ubuntu systems, a complete copy of the GPL can be found under
# /usr/share/common-licenses/GPL-3, or (at your option) any later version
use MythTV;
use File::Copy;
use strict;
my ($input, $output, $cleanup) = "";
my $usage = "\nHow to use mythimport : \n"
."\ninput = Input directory where exported recordings and sql live. These are generated using MythExport. This option is mandatory.\n"
."output = Output directory, use this if you want to transfer the recordings to a different directory.\n"
."cleanup = Specify what files to delete upon success (available options: all, recordings, sql). Do not speficy to leave files in place.\n"
."\nExample: mythimport input=/mnt/usb/mythtv/ output=/var/lib/mythtv/recordings/ cleanup=all\n";
# get this script's ARGS
my $num = $#ARGV + 1;
# if user hasn't passed enough arguments, die and print the usage info
if ($num <= 0) {
die "$usage";
}
foreach (@ARGV){
if ($_ =~ m/input/) {
$input = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/output/) {
$output = (split(/\=/,$_))[1];
}
elsif ($_ =~ m/cleanup/) {
$cleanup = (split(/\=/,$_))[1];
}
}
#remove trailing /
$input =~ s/\/$//;
$output =~ s/\/$//;
my $myth = new MythTV();
#get mysql info
my $dbuser = $myth->{'db_user'};
my $dbpass = $myth->{'db_pass'};
my $dbhost = $myth->{'db_host'};
my $dbname = $myth->{'db_name'};
my $dbport = $myth->{'db_port'};
chdir $input || die "ERROR: input directory is not accessable.\n";
#build mysql command
my $command = "mysql -h$dbhost -u$dbuser -p$dbpass -P$dbport $dbname < mythimport.sql";
#test that the directory has the correct permissions
if($output ne ""){
-w $output || die "ERROR: $output is not writeable.\n";
}
system ("$command") == 0 || die "ERROR: MySQL command failed.\n";
if($output ne ""){
copy("*.mpg", "$output/.");
copy("*.nuv","$output/.");
print "Make sure that $output is in your MythTV storage groups, otherwise MythTV will not be able to find your files.";
}
if($cleanup eq "all"){
unlink("*");
}
elsif($cleanup eq "recordings"){
unlink("*.mpg");
unlink("*.nuv");
}
elsif($cleanup eq "sql"){
unlink("mythimport.sql");
}
mythexport/usr/share/ 0000775 0000000 0000000 00000000000 14766557364 012133 5 ustar mythexport/usr/share/mythexport/ 0000775 0000000 0000000 00000000000 14766557364 014356 5 ustar mythexport/usr/share/mythexport/ExportBase.pm 0000664 0000000 0000000 00000001752 14766557364 016775 0 ustar #!/usr/bin/perl
package ExportBase;
sub new
{
my $class = shift;
my $self = {
_inputFile => shift,
_outputFile => shift,
_description => shift,
_devices => shift,
_notes => shift,
_version => shift,
_extension => ".m4v",
};
bless $self, $class;
return $self;
}
sub checkOutput{
my( $self ) = @_;
if (-e "$self->{_outputFile}$self->{_extension}"){
return 1;
}
else{
return 0;
}
}
sub Description {
my $self = shift;
$self->{_description} = shift if @_;
return $self->{_description};
}
sub Devices {
my $self = shift;
$self->{_devices} = shift if @_;
return $self->{_devices};
}
sub Notes {
my $self = shift;
$self->{_notes} = shift if @_;
return $self->{_notes};
}
sub Extension {
my $self = shift;
$self->{_extension} = shift if @_;
return $self->{_extension};
}
sub Version {
my $self = shift;
$self->{_version} = shift if @_;
return $self->{_version};
}
1;
mythexport/usr/share/mythexport/configs/ 0000775 0000000 0000000 00000000000 14766557364 016006 5 ustar mythexport/usr/share/mythexport/configs/PortableH264HighRes.pm 0000664 0000000 0000000 00000002033 14766557364 021730 0 ustar #!/usr/bin/perl
package PortableH264HighRes;
use ExportBase;
our @ISA = qw(ExportBase);
my $description = "High Resolution (800x400) Portable H264 Settings.";
my $devices = "High Resolution Android Devices (example Droid, Evo, N1), iPod Touch, iPhone, iPad";
my $notes = "Requires AAC, activate Medibuntu";
my $version = "1.0";
sub new{
my $class = shift;
my $self = $class->SUPER::new(shift, shift, $description, $devices, $notes, $version);
bless $self, $class;
return $self;
}
sub export{
my( $self ) = @_;
system("avconv -i \'$self->{_inputFile}\' -y -pass 1 -an -vcodec libx264 -pre slow_firstpass -pre ipod640 -b 1500k -bt 1000k -threads 0 -s 800x480 -aspect 16:9 -f ipod \'$self->{_outputFile}$self->{_extension}\' && avconv -i \'$self->{_inputFile}\' -y -pass 2 -vcodec libx264 -pre medium -pre ipod640 -b 1500k -bt 1000k -threads 0 -s 800x480 -acodec libfaac -ab 192kb -ac 2 -aspect 16:9 -f ipod \'$self->{_outputFile}$self->{_extension}\'");
}
1;
mythexport/usr/share/mythexport/configs/PortableH264LowRes.pm 0000664 0000000 0000000 00000002021 14766557364 021607 0 ustar #!/usr/bin/perl
package PortableH264LowRes;
use ExportBase;
our @ISA = qw(ExportBase);
my $description = "Low Resolution (480x320) Portable H264 Settings.";
my $devices = "Low Resolution Android Devices (example HTC Hero), iPod Classic, iPod Nano";
my $notes = "Requires AAC, activate Medibuntu";
my $version = "1.0";
sub new{
my $class = shift;
my $self = $class->SUPER::new(shift, shift, $description, $devices, $notes, $version);
bless $self, $class;
return $self;
}
sub export{
my( $self ) = @_;
system("avconv -i \'$self->{_inputFile}\' -y -pass 1 -an -vcodec libx264 -pre slow_firstpass -pre ipod320 -b 1500k -bt 1000k -threads 0 -s 480x320 -aspect 16:9 -f ipod \'$self->{_outputFile}$self->{_extension}\' && avconv -i \'$self->{_inputFile}\' -y -pass 2 -vcodec libx264 -pre medium -pre ipod320 -b 1500k -bt 1000k -threads 0 -s 480x320 -acodec libfaac -ab 192kb -ac 2 -aspect 16:9 -f ipod \'$self->{_outputFile}$self->{_extension}\'");
}
1;
mythexport/usr/share/mythtv/ 0000775 0000000 0000000 00000000000 14766557364 013466 5 ustar mythexport/usr/share/mythtv/mythexport/ 0000775 0000000 0000000 00000000000 14766557364 015711 5 ustar mythexport/usr/share/mythtv/mythexport/deleteFile.cgi 0000775 0000000 0000000 00000002117 14766557364 020443 0 ustar #!/usr/bin/perl
use strict;
use CGI qw(:standard);
use HTML::Template;
use Config::Simple;
use MythTV;
require includes;
my $connect = undef;
my $id = param("id");
my $file = "/etc/mythtv/mythexport/mythexport.cfg";
my $cfg = new Config::Simple();
$cfg->read($file) || die $cfg->error();
my $dir = $cfg->param("dir");
$dir =~ s/\/$//;
my $myth = new MythTV();
# connect to database
$connect = $myth->{'dbh'};
my $template = HTML::Template->new(filename => 'template/template.tmpl');
my $query = "SELECT file FROM mythexport where id=?";
my $query_handle = $connect->prepare($query);
$query_handle->execute($id) || die "Unable to query mythexport table";
my $file = $query_handle->fetchrow_array();
# add delete job
$query = "insert into mythexport_job_queue(type,param,id,description) values ('delete',?,NULL,?)";
$query_handle = $connect->prepare($query);
$query_handle->execute($id,$file) || die "Unable to query mythexport table";
my $content = "DONE";
$template->param(CONTENT => $content);
$template->param(LOCATION => "file");
print generateContentType(), $template->output;
exit(0);
mythexport/usr/share/mythtv/mythexport/deleteJob.cgi 0000775 0000000 0000000 00000001236 14766557364 020277 0 ustar #!/usr/bin/perl
use strict;
use CGI qw(:standard);
use HTML::Template;
use Config::Simple;
use MythTV;
require includes;
my $connect = undef;
my $id = param("id");
my $myth = new MythTV();
# connect to database
$connect = $myth->{'dbh'};
my $template = HTML::Template->new(filename => 'template/template.tmpl');
# add delete job
my $query = "delete from mythexport_job_queue where id=?";
my $query_handle = $connect->prepare($query);
$query_handle->execute($id) || die "Unable to query mythexport table";
my $content = "DONE";
$template->param(CONTENT => $content);
$template->param(LOCATION => "file");
print generateContentType(), $template->output;
exit(0);
mythexport/usr/share/mythtv/mythexport/file.cgi 0000775 0000000 0000000 00000003715 14766557364 017325 0 ustar #!/usr/bin/perl
use strict;
use CGI qw(:standard);
use HTML::Template;
use Config::Simple;
use MythTV;
require includes;
my $connect = undef;
my $file = "/etc/mythtv/mythexport/mythexport.cfg";
my ($script,$content) = "";
my $template = HTML::Template->new(filename => 'template/template.tmpl');
# if we have a valid config
if(-e $file && -s $file > 5){
my $cfg = new Config::Simple();
$cfg->read($file) || die $cfg->error();
my $myth = new MythTV();
# connect to database
$connect = $myth->{'dbh'};
$script = "
";
# find the old recordings
my $query = "SELECT file, title, subtitle, airDate, podcastName, id, file FROM mythexport order by pubDate desc";
my $query_handle = $connect->prepare($query);
$query_handle->execute() || die "Unable to query mythexport table";
$content = "Exported Files
";
}
else{
$content = "Missing or Invalid configuration file, please create one.
";
}
$template->param(SCRIPT => $script);
$template->param(CONTENT => $content);
$template->param(LOCATION => "file");
print generateContentType(), $template->output;
exit(0);
mythexport/usr/share/mythtv/mythexport/images/ 0000775 0000000 0000000 00000000000 14766557364 017156 5 ustar mythexport/usr/share/mythtv/mythexport/images/powered_apache_80x15_2.png 0000664 0000000 0000000 00000007213 14766557364 023723 0 ustar PNG
IHDR P pHYs tIME 81u *IDATfff ggg f >>>$-( *)*zzz
*?7
YG
)) e e ef e e e e +.̴"L<9.
e e e e e d 234?ױ,)# 06="4";; e e e e E@=2/;. DY';< e !t»O ".68K e ff e e e e fff %1 fggg 7 f fff O* IENDB` mythexport/usr/share/mythtv/mythexport/images/powered_mysql_80x15_2.png 0000664 0000000 0000000 00000001440 14766557364 023643 0 ustar PNG
IHDR P gAMA OX2 tEXtSoftware Adobe ImageReadyqe<