/usr/bin/mythexport_addjob is in mythexport 2.2.4-0ubuntu5.
This file is owned by root:root, with mode 0o755.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | #!/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);}
|