[mythtv-users] future episode and movie list

Bruce Markey bjm at lvcm.com
Wed Apr 7 23:39:39 EDT 2004


Chris Germano wrote:
> I heard about this cool feature on a Tivo where you can add a title of a
> movie or show and when it appears in the schedule it will record it. Would
> be cool to add support for this somewhere. Every so often it can match the
> list with the current downloaded schedule and if any are hits schedule a new
> recording. Then we could just list tv shows and movies that aren't currently
> showing up in this weeks schedule, and when they are found they will be
> recorded.

Hi, well, there are a few related things here and I can see
where this thread could fork off into different topics or
confuse one topic with another =). I'd like to start with
clarifying this 'cool feature' ;-) then focus on what appears
to be your objective of entering titles that are not in the
current listings.

TiVo has a keyword search mechanism that they call Wishlists.
This serves several purposes and one of the possibilities is
that you could type in a title, set it to auto record and hope
that it will eventually be shown and recorded. One minor
drawback is that the rule exists after the movie records and
may record again until you go back and remove the auto record
and/or the keyword yourself. Wishlists are more commonly used
for keyword searches like the name of a favorite sport team
or keyword of a hobby or interest, etc.

MythTV also has keyword searches in Schedule Recordings->Search
Listings->Titles/Descriptions. This can help find things but
there isn't yet a record type in myth for recording everything
that matches a keyword.

Myth also has Schedule Recordings->Manual Schedule which, unlike
other systems, allows you to type in the title(!) for your manual
record. I abuse this privilege regularly ;-).

For instance, I saw a promo last week that there will be a
second season of "The Restaurant" starting on the 19th. Being
impatient, I went to "Manual Schedule" choose NBC, set the
date and time to the 19th (doesn't matter if it's right because
mythfilldatabase will wipe out the temporary entry), cleared
the subtitle and description fields and entered the title "The
Restaurant". Next, I went to Recording Priorities, found The
Restaurant, hit "i" and changed the type to "Record at any
time on any channel" (NBC sometimes re-broadcasts on CNBC
otherwise I would have chosen "this channel"). I'm now set
to record this once it shows up in the listings. I've done
this successfully dozens of times.

You can do this same thing to enter movie titles. The only
trick is that you need to be sure the manual record fails.
you can either set the date more than two days ahead so the
the program entry will be wiped out by mythfilldatabase or
you can set the starttime for now, duration for 1min and
stay on the page for two minutes so that the manual record
time has passed. Once you've saved the title, you can change
the type and any of the attributes from the advanced options
page from Recording Priorities.

The idea of recording a future movie once and only once is
one of a few reasons for the new record type in myth (0.14
+ one week ;-) called "FindOne". Say I want to record "Get
Shorty" but it isn't currently scheduled. I could enter the
title with manual record and set the type to "Record one
showing of this program". This record rule can sit in the
record table for weeks or months until "Get Shorty" shows
up in the listings. Even then there may be a conflict and
it can't record. Once it finds a showing that it does record,
the rule is automatically removed.

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

--  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";

while(<CONF>)
{
	/(\S*)=(.*)/;
	$dbprm{$1} = $2;
}
close(CONF);

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

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

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

# do stuff
backend_notify_changes($dbh);

$dbh->disconnect;

exit 0;

###
### end of main
###

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

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

	# 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