[mythtv-users] schedule programs before they show in listings

Bruce Markey bjm at lvcm.com
Tue Sep 7 17:45:25 EDT 2004

Harondel J. Sibble wrote:
> Anyone know a way to have mythtv schedule a program even before it shows up 
> in the listings? Other than manually scheduling the date/time.

Actually, I do abuse Manual Schedule for this purpose often.
Myth's manual allows you to type in any title(!) you'd like.
Therefore, you can choose "Space Channel", set the title to
"Star Trek", save, go to the priorities page and change the
type to Channel record. You're now set to record "Star Trek"
whenever it happens to appear on "Space Channel".

> Ie, you know that say the Space Channel here in Canada will be showing say 
> the oringal Star Trek series starting 6 months from now, you don't know what 
> date it will start, you just know it's in the future, so you enter star trek 
> and tell myth to record any star trek shows.

I usually add titles like this manually, however, I also
wrote a script (okay, I hacked up a script by Hirobumi
Shimada to suit my purposes ;-) that you can feed a file
with one title per line and it will create a FindOne
record rule for each. I only used this once for multiple
entries 'cause I usually don't have ten movies that I'd
like to see come to mind all at once ;-). You can also
add a single title on a command line with:

echo "Get Shorty" | addrecord

Normally this would be used to add movies that you'd like
to record someday if they ever show up in the listing. However,
you could add "Star Trek", find it on the priorities page and
change the record type.

In 0.16, the "Search Words" page now includes a "Record" button
that will set a special pattern matching record type thanks to
gigem. If you chose Search Words->Titles you could add "Star Trek"
then click "Record" on the popup. However, this may be a bit
broader than you'd like in this specific case as this would
record every show that has %Star Trek% anywhere in the title
on any station. Title search rules are more useful for things
like "Junkyard%Wars" to match "Junkyard Wars", "Junkyard Mega-Wars"
and "Junkyard Mega-Wars: The Great Race".

--  bjm
-------------- next part --------------
#!/usr/bin/perl -w
# addrecord: insert titles into MythTVs record table -- bjm at lvcm.com
# Based on MythMail by Hirobumi Shimada <shimada at systemcreate-inc.com>
# MythMail is distributed under GPL, version 2 only.
# If you don't have a copy of the GPL, get one at:
#      http://www.gnu.org/licenses/gpl.txt

use DBI;

%settings = (
	# mythtv's configulation file
	# please edit configulation path
	# 'configfile'	=> '/usr/local/share/mythtv/mysql.txt',
	'configfile'	=> $ENV{HOME} . '/.mythtv/mysql.txt',

	# 0	kNotRecording
	# 1	kSingleRecord
	# 2	kTimeslotRecord
	# 3	kChannelRecord
	# 4	kAllRecord
	# 5	kWeekslotRecord
	# 6	kFindOneRecord
	'type' 		=> 6,

	# set MythTV recording profile
	'profile' 	=> 'Default',

	# any settings 
	'chanid'	=> '1003',
	'recpriority' 	=> 0,
	'autoexpire' 	=> 1,

my %blank_prg = (
	'starttime'	=> '',
	'startdate'	=> '',
	'endtime'	=> '',
	'enddate'	=> '',
	'title' 	=> '',

my $verbose = 1;
my $noupdate = 0;
my $dbprm;

# load database connecting parameters from mythtv's config file
open(CONF, "< $settings{configfile}") or die "cannot open config file:$settings{configfile}\n";

	$dbprm{$1} = $2;

# connecting db
$dbh = DBI->connect("DBI:mysql:$dbprm{DBName}:$dbprm{DBHostName}",
		$dbprm{DBPassword}) or die $dbh->errstr;

while (<>)
        my %prg = %blank_prg;

	$prg{title} = $_;
	insert_record($dbh, %prg);

# do stuff


exit 0;

### end of main

sub insert_record
	my ($dbh, %prg) = @_;

	if ($prg{title} eq '')
		warn "No valid title.\n";

	# non alphabet strings required utf8
	$prg{subtitle} = '' if (!$prg{subtitle});
	$prg{desc} = '' if (!$prg{desc});
	$prg{category} = '' if (!$prg{category});

	$sql = "INSERT INTO record(type, chanid, starttime, startdate" .
			", endtime, enddate, title" .
			", profile, recpriority, autoexpire)" .
		"VALUES($settings{type}" .
			", $settings{chanid}" .
			", CURTIME()" .
			", CURDATE()" .
			", CURTIME()" .
			", CURDATE()" .
			", '$prg{title}'" .
			", '$settings{profile}'" .
			", '$settings{recpriority}'".
			", '$settings{autoexpire}')";
	warn "set_recording:$sql\n" if ($verbose);

	if (!$noupdate && !$dbh->do($sql))
		warn "$dbh->errstr\n";
		return FALSE;

	return TRUE;

sub backend_notify_changes
	my ($dbh) = @_;
	my $sql = "UPDATE settings SET data='yes' WHERE value='RecordChanged'";
	warn "backend_notify_changes:$sql\n" if ($verbose);

	if (!$dbh->do($sql))
		warn "$dbh->errstr";
		return FALSE;
	return TRUE;

# end

More information about the mythtv-users mailing list