Mailing List Archive

Apple Trailer Downloader
I really liked the Myth Apple Trailers 'plugin' but I wanted to see
plot, cast, rating etc in the basic display, before I started the actual
trailer. Rather than try to write a real plugin I created an Apple
Trailer downloader that reads the list of current trailers and creates a
videometadata record in the DB with related cast & genre records, &
downloadsthe trailers in a subfolder of the video folder and the poster
in the standard posters directory.

The trailers can then be viewed with Mythvideo

At the moment the trailer & poster folders are hard coded so need to be
modified as required ($videoStore & $posterStore) and I don't seem to
get all the posters. I've set it up to run each night from mythtv's cron
and it uses the Apple id to check if the trailer's already been loaded -
I assume the id is unique.

It uses LWP::Simple, XML::Simple, File::Basename, DBI & DBIx:Perlish,
which is simplifies DB access without the usual DBI overhead.
ToDo:
- get the video & poster directories from the DB
- automatically remove old trailers
- add 'new' to the new trailers (and remove it from existing
trailers)(or when they have been viewed)
- use a standard DB interface (perl bindings? where are they documented?)
- make a dedicated plugin similar to the existing plugin but showing the
additional details - is it possible to write a plugin/addon in perl? I'm
too old to start learning C++

Perhaps someone might find it useful, or have some ideas for improvement....

John

Here it is
-------------------------------------------------------------------------------------
#!/usr/bin/perl

use strict;
use LWP::Simple;
use XML::Simple;
use File::Basename;

use DBI;
use DBIx::Perlish;

my $videoStore = "/storage500/videos/Trailers/";
my $posterStore = "/storage500/posters/";
my $logfile = "apple$$.log";
open LOG, ">$logfile";

my $dbh = DBI->connect('dbi:mysql:mythconverg', "mythtv", "mythtv");
DBIx::Perlish::init($dbh);

my $list = get 'http://www.apple.com/trailers/home/xml/current.xml';
#my $ref = XMLin($list, ForceArray => [ "name" ]);
my $ref = XMLin($list, ForceArray => [ "name" ]);

my $message;

my %Cast;
my %Movies;
foreach my $movie (keys %{$ref->{movieinfo}}){
next if(db_fetch {videometadata->inetref eq $movie}); # already go
this one
print LOG "Checking $ref->{movieinfo}{$movie}{info}{title}\n";
# fetch the trailer & images
print LOG "Adding...\n";
my $trailer = $ref->{movieinfo}{$movie}{preview}{large}{content};
my $trailersize = $ref->{movieinfo}{$movie}{preview}{large}{filesize};
my $localTrailer = $videoStore . File::Basename::basename($trailer);
my $rv = getstore($trailer, $localTrailer);
my $poster = $ref->{movieinfo}{$movie}{poster}{location};
my $localPoster = $posterStore . File::Basename::basename($poster);
$rv = getstore($poster, $localPoster);

# main data to videometadata
# build the 'plot'
my $plot = $ref->{movieinfo}{$movie}{info}{description};
$plot .= "\nRelease Date: " .
$ref->{movieinfo}{$movie}{info}{releasedate};
$plot .= "\nStudio: " . $ref->{movieinfo}{$movie}{info}{studio};
$plot .= "\n" . $ref->{movieinfo}{$movie}{info}{copyright};
$ref->{movieinfo}{$movie}{info}{runtime} =~ /^(\d+):(\d+)/;
my $length = ($1 * 60) + $2;
my $year = substr($ref->{movieinfo}{$movie}{info}{releasedate}, 0, 4);

# add the record

db_insert 'videometadata', {
title => $ref->{movieinfo}{$movie}{info}{title},
director => $ref->{movieinfo}{$movie}{info}{director},
plot => $plot,
rating => $ref->{movieinfo}{$movie}{info}{rating},
inetref => $movie,
year => $year,
showlevel => 1,
length => $length,
filename => $localTrailer,
coverfile => $localPoster,
};
my $videoid = $dbh->{'mysql_insertid'};

foreach my $actor (@{$ref->{movieinfo}{$movie}{cast}{name}}){
_addCast($actor, $videoid);
}
foreach my $genre (@{$ref->{movieinfo}{$movie}{genre}{name}}){
_addGenre($genre, $videoid);
}
}

# send me a mail

#my $cmd = "/bin/mailx pinthenet\@payne.ch -s 'Appletrailers' $message";
#system($cmd);

sub _addCast{
my($name, $idx) = @_;
my $castid;

# if new cast name add record else use existing record
if(!($castid = db_fetch {return videocast->intid; videocast->cast eq
$name})){
db_insert 'videocast', {cast => $name,};
$castid = $dbh->{'mysql_insertid'};
}

# now add n:n record

db_insert 'videometadatacast', {idvideo => $idx, idcast => $castid};

}

sub _addGenre{
my($name, $idx) = @_;
my $genreid;

# if new cast name add record else use existing record
if(!($genreid = db_fetch {return videogenre->intid;
videogenre->genre eq $name})){
db_insert 'videogenre', {genre => $name,};
$genreid = $dbh->{'mysql_insertid'};
}

# now add n:n record

db_insert 'videometadatagenre', {idvideo => $idx, idgenre => $genreid};

}


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
Looks good. It looks like the script pulls the "large" trailer from
the site. Would it be just as easy to pull the 720p version? (I
haven't looked at Apple's site.)

On Tue, Jun 24, 2008 at 2:34 PM, John Payne <mythtv@payne.ch> wrote:
> I really liked the Myth Apple Trailers 'plugin' but I wanted to see
> plot, cast, rating etc in the basic display, before I started the actual
> trailer. Rather than try to write a real plugin I created an Apple
> Trailer downloader that reads the list of current trailers and creates a
> videometadata record in the DB with related cast & genre records, &
> downloadsthe trailers in a subfolder of the video folder and the poster
> in the standard posters directory.
>
> The trailers can then be viewed with Mythvideo
>
> At the moment the trailer & poster folders are hard coded so need to be
> modified as required ($videoStore & $posterStore) and I don't seem to
> get all the posters. I've set it up to run each night from mythtv's cron
> and it uses the Apple id to check if the trailer's already been loaded -
> I assume the id is unique.
>
> It uses LWP::Simple, XML::Simple, File::Basename, DBI & DBIx:Perlish,
> which is simplifies DB access without the usual DBI overhead.
> ToDo:
> - get the video & poster directories from the DB
> - automatically remove old trailers
> - add 'new' to the new trailers (and remove it from existing
> trailers)(or when they have been viewed)
> - use a standard DB interface (perl bindings? where are they documented?)
> - make a dedicated plugin similar to the existing plugin but showing the
> additional details - is it possible to write a plugin/addon in perl? I'm
> too old to start learning C++
>
> Perhaps someone might find it useful, or have some ideas for improvement....
>
> John
>
> Here it is
> -------------------------------------------------------------------------------------
> #!/usr/bin/perl
>
> use strict;
> use LWP::Simple;
> use XML::Simple;
> use File::Basename;
>
> use DBI;
> use DBIx::Perlish;
>
> my $videoStore = "/storage500/videos/Trailers/";
> my $posterStore = "/storage500/posters/";
> my $logfile = "apple$$.log";
> open LOG, ">$logfile";
>
> my $dbh = DBI->connect('dbi:mysql:mythconverg', "mythtv", "mythtv");
> DBIx::Perlish::init($dbh);
>
> my $list = get 'http://www.apple.com/trailers/home/xml/current.xml';
> #my $ref = XMLin($list, ForceArray => [ "name" ]);
> my $ref = XMLin($list, ForceArray => [ "name" ]);
>
> my $message;
>
> my %Cast;
> my %Movies;
> foreach my $movie (keys %{$ref->{movieinfo}}){
> next if(db_fetch {videometadata->inetref eq $movie}); # already go
> this one
> print LOG "Checking $ref->{movieinfo}{$movie}{info}{title}\n";
> # fetch the trailer & images
> print LOG "Adding...\n";
> my $trailer = $ref->{movieinfo}{$movie}{preview}{large}{content};
> my $trailersize = $ref->{movieinfo}{$movie}{preview}{large}{filesize};
> my $localTrailer = $videoStore . File::Basename::basename($trailer);
> my $rv = getstore($trailer, $localTrailer);
> my $poster = $ref->{movieinfo}{$movie}{poster}{location};
> my $localPoster = $posterStore . File::Basename::basename($poster);
> $rv = getstore($poster, $localPoster);
>
> # main data to videometadata
> # build the 'plot'
> my $plot = $ref->{movieinfo}{$movie}{info}{description};
> $plot .= "\nRelease Date: " .
> $ref->{movieinfo}{$movie}{info}{releasedate};
> $plot .= "\nStudio: " . $ref->{movieinfo}{$movie}{info}{studio};
> $plot .= "\n" . $ref->{movieinfo}{$movie}{info}{copyright};
> $ref->{movieinfo}{$movie}{info}{runtime} =~ /^(\d+):(\d+)/;
> my $length = ($1 * 60) + $2;
> my $year = substr($ref->{movieinfo}{$movie}{info}{releasedate}, 0, 4);
>
> # add the record
>
> db_insert 'videometadata', {
> title => $ref->{movieinfo}{$movie}{info}{title},
> director => $ref->{movieinfo}{$movie}{info}{director},
> plot => $plot,
> rating => $ref->{movieinfo}{$movie}{info}{rating},
> inetref => $movie,
> year => $year,
> showlevel => 1,
> length => $length,
> filename => $localTrailer,
> coverfile => $localPoster,
> };
> my $videoid = $dbh->{'mysql_insertid'};
>
> foreach my $actor (@{$ref->{movieinfo}{$movie}{cast}{name}}){
> _addCast($actor, $videoid);
> }
> foreach my $genre (@{$ref->{movieinfo}{$movie}{genre}{name}}){
> _addGenre($genre, $videoid);
> }
> }
>
> # send me a mail
>
> #my $cmd = "/bin/mailx pinthenet\@payne.ch -s 'Appletrailers' $message";
> #system($cmd);
>
> sub _addCast{
> my($name, $idx) = @_;
> my $castid;
>
> # if new cast name add record else use existing record
> if(!($castid = db_fetch {return videocast->intid; videocast->cast eq
> $name})){
> db_insert 'videocast', {cast => $name,};
> $castid = $dbh->{'mysql_insertid'};
> }
>
> # now add n:n record
>
> db_insert 'videometadatacast', {idvideo => $idx, idcast => $castid};
>
> }
>
> sub _addGenre{
> my($name, $idx) = @_;
> my $genreid;
>
> # if new cast name add record else use existing record
> if(!($genreid = db_fetch {return videogenre->intid;
> videogenre->genre eq $name})){
> db_insert 'videogenre', {genre => $name,};
> $genreid = $dbh->{'mysql_insertid'};
> }
>
> # now add n:n record
>
> db_insert 'videometadatagenre', {idvideo => $idx, idgenre => $genreid};
>
> }
>
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>



--
James Sumners
http://james.roomfullofmirrors.com/

"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."

Missionaria Protectiva, Text QIV (decto)
CH:D 59
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
James Sumners wrote:
Looks good. It looks like the script pulls the "large" trailer from the site. Would it be just as easy to pull the 720p version? (I haven't looked at Apple's site.) On Tue, Jun 24, 2008 at 2:34 PM, John Payne <mythtv@payne.ch> wrote:
I really liked the Myth Apple Trailers 'plugin' but I wanted to see plot, cast, rating etc in the basic display, before I started the actual trailer. Rather than try to write a real plugin I created an Apple Trailer downloader that reads the list of current trailers and creates a videometadata record in the DB with related cast & genre records, & downloadsthe trailers in a subfolder of the video folder and the poster in the standard posters directory. The trailers can then be viewed with Mythvideo At the moment the trailer & poster folders are hard coded so need to be modified as required ($videoStore & $posterStore) and I don't seem to get all the posters. I've set it up to run each night from mythtv's cron and it uses the Apple id to check if the trailer's already been loaded - I assume the id is unique. It uses LWP::Simple, XML::Simple, File::Basename, DBI & DBIx:Perlish, which is simplifies DB access without the usual DBI overhead. ToDo: - get the video & poster directories from the DB - automatically remove old trailers - add 'new' to the new trailers (and remove it from existing trailers)(or when they have been viewed) - use a standard DB interface (perl bindings? where are they documented?) - make a dedicated plugin similar to the existing plugin but showing the additional details - is it possible to write a plugin/addon in perl? I'm too old to start learning C++ Perhaps someone might find it useful, or have some ideas for improvement.... John Here it is ------------------------------------------------------------------------------------- #!/usr/bin/perl use strict; use LWP::Simple; use XML::Simple; use File::Basename; use DBI; use DBIx::Perlish; my $videoStore = "/storage500/videos/Trailers/"; my $posterStore = "/storage500/posters/"; my $logfile = "apple$$.log"; open LOG, ">$logfile"; my $dbh = DBI->connect('dbi:mysql:mythconverg', "mythtv", "mythtv"); DBIx::Perlish::init($dbh); my $list = get 'http://www.apple.com/trailers/home/xml/current.xml"]http://www.apple.com/trailers/home/xml/current.xml'; #my $ref = XMLin($list, ForceArray => [ "name" ]); my $ref = XMLin($list, ForceArray => [ "name" ]); my $message; my %Cast; my %Movies; foreach my $movie (keys %{$ref->{movieinfo}}){ next if(db_fetch {videometadata->inetref eq $movie}); # already go this one print LOG "Checking $ref->{movieinfo}{$movie}{info}{title}\n"; # fetch the trailer & images print LOG "Adding...\n"; my $trailer = $ref->{movieinfo}{$movie}{preview}{large}{content}; my $trailersize = $ref->{movieinfo}{$movie}{preview}{large}{filesize}; my $localTrailer = $videoStore . File::Basename::basename($trailer); my $rv = getstore($trailer, $localTrailer); my $poster = $ref->{movieinfo}{$movie}{poster}{location}; my $localPoster = $posterStore . File::Basename::basename($poster); $rv = getstore($poster, $localPoster); # main data to videometadata # build the 'plot' my $plot = $ref->{movieinfo}{$movie}{info}{description}; $plot .= "\nRelease Date: " . $ref->{movieinfo}{$movie}{info}{releasedate}; $plot .= "\nStudio: " . $ref->{movieinfo}{$movie}{info}{studio}; $plot .= "\n" . $ref->{movieinfo}{$movie}{info}{copyright}; $ref->{movieinfo}{$movie}{info}{runtime} =~ /^(\d+):(\d+)/; my $length = ($1 * 60) + $2; my $year = substr($ref->{movieinfo}{$movie}{info}{releasedate}, 0, 4); # add the record db_insert 'videometadata', { title => $ref->{movieinfo}{$movie}{info}{title}, director => $ref->{movieinfo}{$movie}{info}{director}, plot => $plot, rating => $ref->{movieinfo}{$movie}{info}{rating}, inetref => $movie, year => $year, showlevel => 1, length => $length, filename => $localTrailer, coverfile => $localPoster, }; my $videoid = $dbh->{'mysql_insertid'}; foreach my $actor (@{$ref->{movieinfo}{$movie}{cast}{name}}){ _addCast($actor, $videoid); } foreach my $genre (@{$ref->{movieinfo}{$movie}{genre}{name}}){ _addGenre($genre, $videoid); } } # send me a mail #my $cmd = "/bin/mailx pinthenet\@payne.ch -s 'Appletrailers' $message"; #system($cmd); sub _addCast{ my($name, $idx) = @_; my $castid; # if new cast name add record else use existing record if(!($castid = db_fetch {return videocast->intid; videocast->cast eq $name})){ db_insert 'videocast', {cast => $name,}; $castid = $dbh->{'mysql_insertid'}; } # now add n:n record db_insert 'videometadatacast', {idvideo => $idx, idcast => $castid}; } sub _addGenre{ my($name, $idx) = @_; my $genreid; # if new cast name add record else use existing record if(!($genreid = db_fetch {return videogenre->intid; videogenre->genre eq $name})){ db_insert 'videogenre', {genre => $name,}; $genreid = $dbh->{'mysql_insertid'}; } # now add n:n record db_insert 'videometadatagenre', {idvideo => $idx, idgenre => $genreid}; } _______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
The list http://www.apple.com/trailers/home/xml/current.xml"]http://www.apple.com/trailers/home/xml/current.xml only includes one preview - identified as <large>. I got the URL from the Apple Trailer plugin - do you know of another? I seem to remember that there are 2 version of the plugin - one downloads & the other just makes a list and I think they use different URLs - I'll check again
Re: Apple Trailer Downloader [ In reply to ]
Ah, I see. There is a modification to the "Apple Trailers" plugin that
replaces "h640w" in the file URL with "720p".

On Tue, Jun 24, 2008 at 2:57 PM, John Payne <mythtv@payne.ch> wrote:
> James Sumners wrote:
>
> Looks good. It looks like the script pulls the "large" trailer from
> the site. Would it be just as easy to pull the 720p version? (I
> haven't looked at Apple's site.)
>
> On Tue, Jun 24, 2008 at 2:34 PM, John Payne <mythtv@payne.ch> wrote:
>
>
> I really liked the Myth Apple Trailers 'plugin' but I wanted to see
> plot, cast, rating etc in the basic display, before I started the actual
> trailer. Rather than try to write a real plugin I created an Apple
> Trailer downloader that reads the list of current trailers and creates a
> videometadata record in the DB with related cast & genre records, &
> downloadsthe trailers in a subfolder of the video folder and the poster
> in the standard posters directory.
>
> The trailers can then be viewed with Mythvideo
>
> At the moment the trailer & poster folders are hard coded so need to be
> modified as required ($videoStore & $posterStore) and I don't seem to
> get all the posters. I've set it up to run each night from mythtv's cron
> and it uses the Apple id to check if the trailer's already been loaded -
> I assume the id is unique.
>
> It uses LWP::Simple, XML::Simple, File::Basename, DBI & DBIx:Perlish,
> which is simplifies DB access without the usual DBI overhead.
> ToDo:
> - get the video & poster directories from the DB
> - automatically remove old trailers
> - add 'new' to the new trailers (and remove it from existing
> trailers)(or when they have been viewed)
> - use a standard DB interface (perl bindings? where are they documented?)
> - make a dedicated plugin similar to the existing plugin but showing the
> additional details - is it possible to write a plugin/addon in perl? I'm
> too old to start learning C++
>
> Perhaps someone might find it useful, or have some ideas for improvement....
>
> John
>
> Here it is
> -------------------------------------------------------------------------------------
> #!/usr/bin/perl
>
> use strict;
> use LWP::Simple;
> use XML::Simple;
> use File::Basename;
>
> use DBI;
> use DBIx::Perlish;
>
> my $videoStore = "/storage500/videos/Trailers/";
> my $posterStore = "/storage500/posters/";
> my $logfile = "apple$$.log";
> open LOG, ">$logfile";
>
> my $dbh = DBI->connect('dbi:mysql:mythconverg', "mythtv", "mythtv");
> DBIx::Perlish::init($dbh);
>
> my $list = get 'http://www.apple.com/trailers/home/xml/current.xml';
> #my $ref = XMLin($list, ForceArray => [ "name" ]);
> my $ref = XMLin($list, ForceArray => [ "name" ]);
>
> my $message;
>
> my %Cast;
> my %Movies;
> foreach my $movie (keys %{$ref->{movieinfo}}){
> next if(db_fetch {videometadata->inetref eq $movie}); # already go
> this one
> print LOG "Checking $ref->{movieinfo}{$movie}{info}{title}\n";
> # fetch the trailer & images
> print LOG "Adding...\n";
> my $trailer = $ref->{movieinfo}{$movie}{preview}{large}{content};
> my $trailersize = $ref->{movieinfo}{$movie}{preview}{large}{filesize};
> my $localTrailer = $videoStore . File::Basename::basename($trailer);
> my $rv = getstore($trailer, $localTrailer);
> my $poster = $ref->{movieinfo}{$movie}{poster}{location};
> my $localPoster = $posterStore . File::Basename::basename($poster);
> $rv = getstore($poster, $localPoster);
>
> # main data to videometadata
> # build the 'plot'
> my $plot = $ref->{movieinfo}{$movie}{info}{description};
> $plot .= "\nRelease Date: " .
> $ref->{movieinfo}{$movie}{info}{releasedate};
> $plot .= "\nStudio: " . $ref->{movieinfo}{$movie}{info}{studio};
> $plot .= "\n" . $ref->{movieinfo}{$movie}{info}{copyright};
> $ref->{movieinfo}{$movie}{info}{runtime} =~ /^(\d+):(\d+)/;
> my $length = ($1 * 60) + $2;
> my $year = substr($ref->{movieinfo}{$movie}{info}{releasedate}, 0, 4);
>
> # add the record
>
> db_insert 'videometadata', {
> title => $ref->{movieinfo}{$movie}{info}{title},
> director => $ref->{movieinfo}{$movie}{info}{director},
> plot => $plot,
> rating => $ref->{movieinfo}{$movie}{info}{rating},
> inetref => $movie,
> year => $year,
> showlevel => 1,
> length => $length,
> filename => $localTrailer,
> coverfile => $localPoster,
> };
> my $videoid = $dbh->{'mysql_insertid'};
>
> foreach my $actor (@{$ref->{movieinfo}{$movie}{cast}{name}}){
> _addCast($actor, $videoid);
> }
> foreach my $genre (@{$ref->{movieinfo}{$movie}{genre}{name}}){
> _addGenre($genre, $videoid);
> }
> }
>
> # send me a mail
>
> #my $cmd = "/bin/mailx pinthenet\@payne.ch -s 'Appletrailers' $message";
> #system($cmd);
>
> sub _addCast{
> my($name, $idx) = @_;
> my $castid;
>
> # if new cast name add record else use existing record
> if(!($castid = db_fetch {return videocast->intid; videocast->cast eq
> $name})){
> db_insert 'videocast', {cast => $name,};
> $castid = $dbh->{'mysql_insertid'};
> }
>
> # now add n:n record
>
> db_insert 'videometadatacast', {idvideo => $idx, idcast => $castid};
>
> }
>
> sub _addGenre{
> my($name, $idx) = @_;
> my $genreid;
>
> # if new cast name add record else use existing record
> if(!($genreid = db_fetch {return videogenre->intid;
> videogenre->genre eq $name})){
> db_insert 'videogenre', {genre => $name,};
> $genreid = $dbh->{'mysql_insertid'};
> }
>
> # now add n:n record
>
> db_insert 'videometadatagenre', {idvideo => $idx, idgenre => $genreid};
>
> }
>
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>
>
>
>
>
> The list http://www.apple.com/trailers/home/xml/current.xml only includes
> one preview - identified as <large>. I got the URL from the Apple Trailer
> plugin - do you know of another? I seem to remember that there are 2 version
> of the plugin - one downloads & the other just makes a list and I think they
> use different URLs - I'll check again
>
>
>
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>
>



--
James Sumners
http://james.roomfullofmirrors.com/

"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."

Missionaria Protectiva, Text QIV (decto)
CH:D 59
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
On 06/24/2008 02:34 PM, John Payne wrote:
> I really liked the Myth Apple Trailers 'plugin' but I wanted to see
> plot, cast, rating etc in the basic display, before I started the actual
> trailer.

Speaking of which, has anyone actually checked to see if such scripts
are allowed? It seems from the Apple Terms of Service (
http://www.apple.com/legal/terms/site.html ) linked from
http://www.apple.com/trailers/ that it's not allowed:

Your Use of the Site
You may not use any “deep-link”, “page-scrape”, “robot”, “spider” or
other automatic device, program, algorithm or methodology, or any
similar or equivalent manual process, to access, acquire, copy or
monitor any portion of the Site or any Content, or in any way reproduce
or circumvent the navigational structure or presentation of the Site or
any Content, to obtain or attempt to obtain any materials, documents or
information through any means not purposely made available through the
Site. Apple reserves the right to bar any such activity.

Did anyone actually contact Apple to request permission?

Mike
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
He isn't doing any such thing. Apple is providing the XML data stream
for people to use. All he is doing is parsing the data, and using it.

On Tue, Jun 24, 2008 at 3:42 PM, Michael T. Dean
<mtdean@thirdcontact.com> wrote:
> On 06/24/2008 02:34 PM, John Payne wrote:
>> I really liked the Myth Apple Trailers 'plugin' but I wanted to see
>> plot, cast, rating etc in the basic display, before I started the actual
>> trailer.
>
> Speaking of which, has anyone actually checked to see if such scripts
> are allowed? It seems from the Apple Terms of Service (
> http://www.apple.com/legal/terms/site.html ) linked from
> http://www.apple.com/trailers/ that it's not allowed:
>
> Your Use of the Site
> You may not use any "deep-link", "page-scrape", "robot", "spider" or
> other automatic device, program, algorithm or methodology, or any
> similar or equivalent manual process, to access, acquire, copy or
> monitor any portion of the Site or any Content, or in any way reproduce
> or circumvent the navigational structure or presentation of the Site or
> any Content, to obtain or attempt to obtain any materials, documents or
> information through any means not purposely made available through the
> Site. Apple reserves the right to bar any such activity.
>
> Did anyone actually contact Apple to request permission?
>
> Mike
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>



--
James Sumners
http://james.roomfullofmirrors.com/

"All governments suffer a recurring problem: Power attracts
pathological personalities. It is not that power corrupts but that it
is magnetic to the corruptible. Such people have a tendency to become
drunk on violence, a condition to which they are quickly addicted."

Missionaria Protectiva, Text QIV (decto)
CH:D 59
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
On Wed, Jun 25, 2008 at 6:34 AM, John Payne <mythtv@payne.ch> wrote:
>
> It uses LWP::Simple, XML::Simple, File::Basename, DBI & DBIx:Perlish,
> which is simplifies DB access without the usual DBI overhead.

Using ubuntu, can you tell me which package to apt-get to obtain
DBIx::Perlish? running your script gives me:

Can't locate DBIx/Perlish.pm in @INC (@INC contains: /etc/perl
/usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5
/usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8
/usr/local/lib/site_perl .) at bin/apple_trailer_download.pl line 9.
BEGIN failed--compilation aborted at bin/apple_trailer_download.pl line 9.


Can't seem to find it in ubuntu.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
Nick Rout wrote:
On Wed, Jun 25, 2008 at 6:34 AM, John Payne <mythtv@payne.ch> wrote:
It uses LWP::Simple, XML::Simple, File::Basename, DBI & DBIx:Perlish, which is simplifies DB access without the usual DBI overhead.
Using ubuntu, can you tell me which package to apt-get to obtain DBIx::Perlish? running your script gives me: Can't locate DBIx/Perlish.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at bin/apple_trailer_download.pl line 9. BEGIN failed--compilation aborted at bin/apple_trailer_download.pl line 9. Can't seem to find it in ubuntu. _______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
I'm afraid I can't help you there - I'm on fedora using the Mythdora distributon. On this and other Unixes I install modules using the Perl CPAN module.
I assume there''ll be a Ubuntu package for CPAN - install that then run (as root) "perl -MCPAN -e shell" - you'll have to go through the initial configuration and select you local CPAN mirrors, then just "install DBIx::Perlish".

Anyone else know another solution for ubuntu?

John
Re: Apple Trailer Downloader [ In reply to ]
On Wed, Jun 25, 2008 at 8:11 PM, John Payne <mythtv@payne.ch> wrote:
> Nick Rout wrote:
>
> On Wed, Jun 25, 2008 at 6:34 AM, John Payne <mythtv@payne.ch> wrote:
>
>
> It uses LWP::Simple, XML::Simple, File::Basename, DBI & DBIx:Perlish,
> which is simplifies DB access without the usual DBI overhead.
>
>
> Using ubuntu, can you tell me which package to apt-get to obtain
> DBIx::Perlish? running your script gives me:
>
> Can't locate DBIx/Perlish.pm in @INC (@INC contains: /etc/perl
> /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5
> /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8
> /usr/local/lib/site_perl .) at bin/apple_trailer_download.pl line 9.
> BEGIN failed--compilation aborted at bin/apple_trailer_download.pl line 9.
>
>
> Can't seem to find it in ubuntu.
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>
>
>
> I'm afraid I can't help you there - I'm on fedora using the Mythdora
> distributon. On this and other Unixes I install modules using the Perl CPAN
> module.
> I assume there''ll be a Ubuntu package for CPAN - install that then run (as
> root) "perl -MCPAN -e shell" - you'll have to go through the initial
> configuration and select you local CPAN mirrors, then just "install
> DBIx::Perlish".
>
> Anyone else know another solution for ubuntu?
>

yeah I did that in the end. many perl modules that can be installed
via CPAN are also available as ubuntu packages and I like to keep
everything within the deb packaging system if I can, but I will make
exceptions like this where necessary.

a little comment: if the download of the movie file fails (say eg the
user running the script doesn't have write permissions in the
destination directory (oops) then the database entry still gets
written. Thats a bit annoying, particularly when you run it again
(properly this time) it doesn't download the failed files as it thinks
it already has them. Therefore some error checking is needed. But I am
no perl programmer, so who am i to comment anyway!

anyway, happily watching trailers.

> John
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>
>
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
Nick Rout wrote:
On Wed, Jun 25, 2008 at 8:11 PM, John Payne <mythtv@payne.ch> wrote:
Nick Rout wrote: On Wed, Jun 25, 2008 at 6:34 AM, John Payne <mythtv@payne.ch> wrote: It uses LWP::Simple, XML::Simple, File::Basename, DBI & DBIx:Perlish, which is simplifies DB access without the usual DBI overhead. Using ubuntu, can you tell me which package to apt-get to obtain DBIx::Perlish? running your script gives me: Can't locate DBIx/Perlish.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.8.8 /usr/local/share/perl/5.8.8 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.8 /usr/share/perl/5.8 /usr/local/lib/site_perl .) at bin/apple_trailer_download.pl line 9. BEGIN failed--compilation aborted at bin/apple_trailer_download.pl line 9. Can't seem to find it in ubuntu. _______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users I'm afraid I can't help you there - I'm on fedora using the Mythdora distributon. On this and other Unixes I install modules using the Perl CPAN module. I assume there''ll be a Ubuntu package for CPAN - install that then run (as root) "perl -MCPAN -e shell" - you'll have to go through the initial configuration and select you local CPAN mirrors, then just "install DBIx::Perlish". Anyone else know another solution for ubuntu?
yeah I did that in the end. many perl modules that can be installed via CPAN are also available as ubuntu packages and I like to keep everything within the deb packaging system if I can, but I will make exceptions like this where necessary. a little comment: if the download of the movie file fails (say eg the user running the script doesn't have write permissions in the destination directory (oops) then the database entry still gets written. Thats a bit annoying, particularly when you run it again (properly this time) it doesn't download the failed files as it thinks it already has them. Therefore some error checking is needed. But I am no perl programmer, so who am i to comment anyway! anyway, happily watching trailers.
John _______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
_______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Hmm, good point. Error checking was never one of my strong points.....
I'll check that out - I need to add a check for the poster download anyway as I don't seem to get all of them

Pleased to hear you got it working
Re: Apple Trailer Downloader [ In reply to ]
2008/6/24 James Sumners <james.sumners@gmail.com>:
> Ah, I see. There is a modification to the "Apple Trailers" plugin that
> replaces "h640w" in the file URL with "720p".
>
> On Tue, Jun 24, 2008 at 2:57 PM, John Payne <mythtv@payne.ch> wrote:
>> James Sumners wrote:
>>
>> Looks good. It looks like the script pulls the "large" trailer from
>> the site. Would it be just as easy to pull the 720p version? (I
>> haven't looked at Apple's site.)
>>
>> On Tue, Jun 24, 2008 at 2:34 PM, John Payne <mythtv@payne.ch> wrote:
>>
>>
>> I really liked the Myth Apple Trailers 'plugin' but I wanted to see
>> plot, cast, rating etc in the basic display, before I started the actual
>> trailer. Rather than try to write a real plugin I created an Apple
>> Trailer downloader that reads the list of current trailers and creates a
>> videometadata record in the DB with related cast & genre records, &
>> downloadsthe trailers in a subfolder of the video folder and the poster
>> in the standard posters directory.
>>
>> The trailers can then be viewed with Mythvideo
>>
>> At the moment the trailer & poster folders are hard coded so need to be
>> modified as required ($videoStore & $posterStore) and I don't seem to
>> get all the posters. I've set it up to run each night from mythtv's cron
>> and it uses the Apple id to check if the trailer's already been loaded -
>> I assume the id is unique.
>>
>> It uses LWP::Simple, XML::Simple, File::Basename, DBI & DBIx:Perlish,
>> which is simplifies DB access without the usual DBI overhead.
>> ToDo:
>> - get the video & poster directories from the DB
>> - automatically remove old trailers
>> - add 'new' to the new trailers (and remove it from existing
>> trailers)(or when they have been viewed)
>> - use a standard DB interface (perl bindings? where are they documented?)
>> - make a dedicated plugin similar to the existing plugin but showing the
>> additional details - is it possible to write a plugin/addon in perl? I'm
>> too old to start learning C++
>>
>> Perhaps someone might find it useful, or have some ideas for improvement....
>>
>> John
>>
>> Here it is
>> -------------------------------------------------------------------------------------
>> #!/usr/bin/perl
>>
>> use strict;
>> use LWP::Simple;
>> use XML::Simple;
>> use File::Basename;
>>
>> use DBI;
>> use DBIx::Perlish;
>>
>> my $videoStore = "/storage500/videos/Trailers/";
>> my $posterStore = "/storage500/posters/";
>> my $logfile = "apple$$.log";
>> open LOG, ">$logfile";
>>
>> my $dbh = DBI->connect('dbi:mysql:mythconverg', "mythtv", "mythtv");
>> DBIx::Perlish::init($dbh);
>>
>> my $list = get 'http://www.apple.com/trailers/home/xml/current.xml';
>> #my $ref = XMLin($list, ForceArray => [ "name" ]);
>> my $ref = XMLin($list, ForceArray => [ "name" ]);
>>
>> my $message;
>>
>> my %Cast;
>> my %Movies;
>> foreach my $movie (keys %{$ref->{movieinfo}}){
>> next if(db_fetch {videometadata->inetref eq $movie}); # already go
>> this one
>> print LOG "Checking $ref->{movieinfo}{$movie}{info}{title}\n";
>> # fetch the trailer & images
>> print LOG "Adding...\n";
>> my $trailer = $ref->{movieinfo}{$movie}{preview}{large}{content};
>> my $trailersize = $ref->{movieinfo}{$movie}{preview}{large}{filesize};
>> my $localTrailer = $videoStore . File::Basename::basename($trailer);
>> my $rv = getstore($trailer, $localTrailer);
>> my $poster = $ref->{movieinfo}{$movie}{poster}{location};
>> my $localPoster = $posterStore . File::Basename::basename($poster);
>> $rv = getstore($poster, $localPoster);
>>
>> # main data to videometadata
>> # build the 'plot'
>> my $plot = $ref->{movieinfo}{$movie}{info}{description};
>> $plot .= "\nRelease Date: " .
>> $ref->{movieinfo}{$movie}{info}{releasedate};
>> $plot .= "\nStudio: " . $ref->{movieinfo}{$movie}{info}{studio};
>> $plot .= "\n" . $ref->{movieinfo}{$movie}{info}{copyright};
>> $ref->{movieinfo}{$movie}{info}{runtime} =~ /^(\d+):(\d+)/;
>> my $length = ($1 * 60) + $2;
>> my $year = substr($ref->{movieinfo}{$movie}{info}{releasedate}, 0, 4);
>>
>> # add the record
>>
>> db_insert 'videometadata', {
>> title => $ref->{movieinfo}{$movie}{info}{title},
>> director => $ref->{movieinfo}{$movie}{info}{director},
>> plot => $plot,
>> rating => $ref->{movieinfo}{$movie}{info}{rating},
>> inetref => $movie,
>> year => $year,
>> showlevel => 1,
>> length => $length,
>> filename => $localTrailer,
>> coverfile => $localPoster,
>> };
>> my $videoid = $dbh->{'mysql_insertid'};
>>
>> foreach my $actor (@{$ref->{movieinfo}{$movie}{cast}{name}}){
>> _addCast($actor, $videoid);
>> }
>> foreach my $genre (@{$ref->{movieinfo}{$movie}{genre}{name}}){
>> _addGenre($genre, $videoid);
>> }
>> }
>>
>> # send me a mail
>>
>> #my $cmd = "/bin/mailx pinthenet\@payne.ch -s 'Appletrailers' $message";
>> #system($cmd);
>>
>> sub _addCast{
>> my($name, $idx) = @_;
>> my $castid;
>>
>> # if new cast name add record else use existing record
>> if(!($castid = db_fetch {return videocast->intid; videocast->cast eq
>> $name})){
>> db_insert 'videocast', {cast => $name,};
>> $castid = $dbh->{'mysql_insertid'};
>> }
>>
>> # now add n:n record
>>
>> db_insert 'videometadatacast', {idvideo => $idx, idcast => $castid};
>>
>> }
>>
>> sub _addGenre{
>> my($name, $idx) = @_;
>> my $genreid;
>>
>> # if new cast name add record else use existing record
>> if(!($genreid = db_fetch {return videogenre->intid;
>> videogenre->genre eq $name})){
>> db_insert 'videogenre', {genre => $name,};
>> $genreid = $dbh->{'mysql_insertid'};
>> }
>>
>> # now add n:n record
>>
>> db_insert 'videometadatagenre', {idvideo => $idx, idgenre => $genreid};
>>
>> }
>>
>>
>> _______________________________________________
>> mythtv-users mailing list
>> mythtv-users@mythtv.org
>> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>>
>>
>>
>>
>>
>> The list http://www.apple.com/trailers/home/xml/current.xml only includes
>> one preview - identified as <large>. I got the URL from the Apple Trailer
>> plugin - do you know of another? I seem to remember that there are 2 version
>> of the plugin - one downloads & the other just makes a list and I think they
>> use different URLs - I'll check again
>>
>>
>>
>>
>> _______________________________________________
>> mythtv-users mailing list
>> mythtv-users@mythtv.org
>> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>>
>>
>
>
>
> --
> James Sumners
> http://james.roomfullofmirrors.com/
>
> "All governments suffer a recurring problem: Power attracts
> pathological personalities. It is not that power corrupts but that it
> is magnetic to the corruptible. Such people have a tendency to become
> drunk on violence, a condition to which they are quickly addicted."
>
> Missionaria Protectiva, Text QIV (decto)
> CH:D 59
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>

Well, you could do it the same way in perl the same way. You are
already using LWP::Simple, so this should be enough:

$ref->{movieinfo}{$movie}{preview}{large}{content} = s/_h640w\./_720\./g;
if (head($ref->{movieinfo}{$movie}{preview}{large}{content})) {
# new file exists, overwrite $trailer again
$trailer = $ref->{movieinfo}{$movie}{preview}{large}{content};
}

head() should be at least as fast as php's get_header() function.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
2008/6/26 Ma Begaj <derliebegott@gmail.com>:
> 2008/6/24 James Sumners <james.sumners@gmail.com>:
>> Ah, I see. There is a modification to the "Apple Trailers" plugin that
>> replaces "h640w" in the file URL with "720p".
>>
>> On Tue, Jun 24, 2008 at 2:57 PM, John Payne <mythtv@payne.ch> wrote:
>>> James Sumners wrote:
>>>
>>> Looks good. It looks like the script pulls the "large" trailer from
>>> the site. Would it be just as easy to pull the 720p version? (I
>>> haven't looked at Apple's site.)
>>>
>>> On Tue, Jun 24, 2008 at 2:34 PM, John Payne <mythtv@payne.ch> wrote:
>>>
>>>
>>> I really liked the Myth Apple Trailers 'plugin' but I wanted to see
>>> plot, cast, rating etc in the basic display, before I started the actual
>>> trailer. Rather than try to write a real plugin I created an Apple
>>> Trailer downloader that reads the list of current trailers and creates a
>>> videometadata record in the DB with related cast & genre records, &
>>> downloadsthe trailers in a subfolder of the video folder and the poster
>>> in the standard posters directory.
>>>
>>> The trailers can then be viewed with Mythvideo
>>>
>>> At the moment the trailer & poster folders are hard coded so need to be
>>> modified as required ($videoStore & $posterStore) and I don't seem to
>>> get all the posters. I've set it up to run each night from mythtv's cron
>>> and it uses the Apple id to check if the trailer's already been loaded -
>>> I assume the id is unique.
>>>
>>> It uses LWP::Simple, XML::Simple, File::Basename, DBI & DBIx:Perlish,
>>> which is simplifies DB access without the usual DBI overhead.
>>> ToDo:
>>> - get the video & poster directories from the DB
>>> - automatically remove old trailers
>>> - add 'new' to the new trailers (and remove it from existing
>>> trailers)(or when they have been viewed)
>>> - use a standard DB interface (perl bindings? where are they documented?)
>>> - make a dedicated plugin similar to the existing plugin but showing the
>>> additional details - is it possible to write a plugin/addon in perl? I'm
>>> too old to start learning C++
>>>
>>> Perhaps someone might find it useful, or have some ideas for improvement....
>>>
>>> John
>>>
>>> Here it is
>>> -------------------------------------------------------------------------------------
>>> #!/usr/bin/perl
>>>
>>> use strict;
>>> use LWP::Simple;
>>> use XML::Simple;
>>> use File::Basename;
>>>
>>> use DBI;
>>> use DBIx::Perlish;
>>>
>>> my $videoStore = "/storage500/videos/Trailers/";
>>> my $posterStore = "/storage500/posters/";
>>> my $logfile = "apple$$.log";
>>> open LOG, ">$logfile";
>>>
>>> my $dbh = DBI->connect('dbi:mysql:mythconverg', "mythtv", "mythtv");
>>> DBIx::Perlish::init($dbh);
>>>
>>> my $list = get 'http://www.apple.com/trailers/home/xml/current.xml';
>>> #my $ref = XMLin($list, ForceArray => [ "name" ]);
>>> my $ref = XMLin($list, ForceArray => [ "name" ]);
>>>
>>> my $message;
>>>
>>> my %Cast;
>>> my %Movies;
>>> foreach my $movie (keys %{$ref->{movieinfo}}){
>>> next if(db_fetch {videometadata->inetref eq $movie}); # already go
>>> this one
>>> print LOG "Checking $ref->{movieinfo}{$movie}{info}{title}\n";
>>> # fetch the trailer & images
>>> print LOG "Adding...\n";
>>> my $trailer = $ref->{movieinfo}{$movie}{preview}{large}{content};
>>> my $trailersize = $ref->{movieinfo}{$movie}{preview}{large}{filesize};
>>> my $localTrailer = $videoStore . File::Basename::basename($trailer);
>>> my $rv = getstore($trailer, $localTrailer);
>>> my $poster = $ref->{movieinfo}{$movie}{poster}{location};
>>> my $localPoster = $posterStore . File::Basename::basename($poster);
>>> $rv = getstore($poster, $localPoster);
>>>
>>> # main data to videometadata
>>> # build the 'plot'
>>> my $plot = $ref->{movieinfo}{$movie}{info}{description};
>>> $plot .= "\nRelease Date: " .
>>> $ref->{movieinfo}{$movie}{info}{releasedate};
>>> $plot .= "\nStudio: " . $ref->{movieinfo}{$movie}{info}{studio};
>>> $plot .= "\n" . $ref->{movieinfo}{$movie}{info}{copyright};
>>> $ref->{movieinfo}{$movie}{info}{runtime} =~ /^(\d+):(\d+)/;
>>> my $length = ($1 * 60) + $2;
>>> my $year = substr($ref->{movieinfo}{$movie}{info}{releasedate}, 0, 4);
>>>
>>> # add the record
>>>
>>> db_insert 'videometadata', {
>>> title => $ref->{movieinfo}{$movie}{info}{title},
>>> director => $ref->{movieinfo}{$movie}{info}{director},
>>> plot => $plot,
>>> rating => $ref->{movieinfo}{$movie}{info}{rating},
>>> inetref => $movie,
>>> year => $year,
>>> showlevel => 1,
>>> length => $length,
>>> filename => $localTrailer,
>>> coverfile => $localPoster,
>>> };
>>> my $videoid = $dbh->{'mysql_insertid'};
>>>
>>> foreach my $actor (@{$ref->{movieinfo}{$movie}{cast}{name}}){
>>> _addCast($actor, $videoid);
>>> }
>>> foreach my $genre (@{$ref->{movieinfo}{$movie}{genre}{name}}){
>>> _addGenre($genre, $videoid);
>>> }
>>> }
>>>
>>> # send me a mail
>>>
>>> #my $cmd = "/bin/mailx pinthenet\@payne.ch -s 'Appletrailers' $message";
>>> #system($cmd);
>>>
>>> sub _addCast{
>>> my($name, $idx) = @_;
>>> my $castid;
>>>
>>> # if new cast name add record else use existing record
>>> if(!($castid = db_fetch {return videocast->intid; videocast->cast eq
>>> $name})){
>>> db_insert 'videocast', {cast => $name,};
>>> $castid = $dbh->{'mysql_insertid'};
>>> }
>>>
>>> # now add n:n record
>>>
>>> db_insert 'videometadatacast', {idvideo => $idx, idcast => $castid};
>>>
>>> }
>>>
>>> sub _addGenre{
>>> my($name, $idx) = @_;
>>> my $genreid;
>>>
>>> # if new cast name add record else use existing record
>>> if(!($genreid = db_fetch {return videogenre->intid;
>>> videogenre->genre eq $name})){
>>> db_insert 'videogenre', {genre => $name,};
>>> $genreid = $dbh->{'mysql_insertid'};
>>> }
>>>
>>> # now add n:n record
>>>
>>> db_insert 'videometadatagenre', {idvideo => $idx, idgenre => $genreid};
>>>
>>> }
>>>
>>>
>>> _______________________________________________
>>> mythtv-users mailing list
>>> mythtv-users@mythtv.org
>>> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>>>
>>>
>>>
>>>
>>>
>>> The list http://www.apple.com/trailers/home/xml/current.xml only includes
>>> one preview - identified as <large>. I got the URL from the Apple Trailer
>>> plugin - do you know of another? I seem to remember that there are 2 version
>>> of the plugin - one downloads & the other just makes a list and I think they
>>> use different URLs - I'll check again
>>>
>>>
>>>
>>>
>>> _______________________________________________
>>> mythtv-users mailing list
>>> mythtv-users@mythtv.org
>>> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>>>
>>>
>>
>>
>>
>> --
>> James Sumners
>> http://james.roomfullofmirrors.com/
>>
>> "All governments suffer a recurring problem: Power attracts
>> pathological personalities. It is not that power corrupts but that it
>> is magnetic to the corruptible. Such people have a tendency to become
>> drunk on violence, a condition to which they are quickly addicted."
>>
>> Missionaria Protectiva, Text QIV (decto)
>> CH:D 59
>> _______________________________________________
>> mythtv-users mailing list
>> mythtv-users@mythtv.org
>> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>>
>
> Well, you could do it the same way in perl the same way. You are
> already using LWP::Simple, so this should be enough:
>
> $ref->{movieinfo}{$movie}{preview}{large}{content} = s/_h640w\./_720\./g;
> if (head($ref->{movieinfo}{$movie}{preview}{large}{content})) {
> # new file exists, overwrite $trailer again
> $trailer = $ref->{movieinfo}{$movie}{preview}{large}{content};
> }
>
> head() should be at least as fast as php's get_header() function.
>


but it would be maybe even much better if you could put the $trailer
in DB for "filename" instead of $localTrailer, and let mplayer stream
all *.mov files instead of downloading all before someone even knows
whether s/he wants to watch it.

mplayer or a shell script with mplayer command could cache trailers
and save them for the further watching. but this is more complicated
than your script and I even do not know whether "filename" can contain
absolute paths. this would probably be a "misuse" of this field.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
On Thu, Jun 26, 2008 at 9:23 PM, Ma Begaj <derliebegott@gmail.com> wrote:
>
> but it would be maybe even much better if you could put the $trailer
> in DB for "filename" instead of $localTrailer, and let mplayer stream
> all *.mov files instead of downloading all before someone even knows
> whether s/he wants to watch it.
>
> mplayer or a shell script with mplayer command could cache trailers
> and save them for the further watching. but this is more complicated
> than your script and I even do not know whether "filename" can contain
> absolute paths. this would probably be a "misuse" of this field.

You could have the scraping script write the network address of the
file to the database and a custom playing script to the database. The
custom playing script would stream the file and write it to the hard
drive at the same time, and then remove the custom viewing script from
the database (so that subsequent plays use the "default" player.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
2008/6/26 Nick Rout <nick.rout@gmail.com>:
> On Thu, Jun 26, 2008 at 9:23 PM, Ma Begaj <derliebegott@gmail.com> wrote:
>>
>> but it would be maybe even much better if you could put the $trailer
>> in DB for "filename" instead of $localTrailer, and let mplayer stream
>> all *.mov files instead of downloading all before someone even knows
>> whether s/he wants to watch it.
>>
>> mplayer or a shell script with mplayer command could cache trailers
>> and save them for the further watching. but this is more complicated
>> than your script and I even do not know whether "filename" can contain
>> absolute paths. this would probably be a "misuse" of this field.
>
> You could have the scraping script write the network address of the
> file to the database and a custom playing script to the database. The
> custom playing script would stream the file and write it to the hard
> drive at the same time, and then remove the custom viewing script from
> the database (so that subsequent plays use the "default" player.

That could also be done if someone only uses "default" player. Nice idea.

But I do not use it for MythVideo because of some problems with subtitles and
because mplayer is much more configurable (position of subtitles,
using of core-avc-for-linux, less cpu...)
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
On Thu, Jun 26, 2008 at 11:02 PM, Ma Begaj <derliebegott@gmail.com> wrote:
> 2008/6/26 Nick Rout <nick.rout@gmail.com>:
>> On Thu, Jun 26, 2008 at 9:23 PM, Ma Begaj <derliebegott@gmail.com> wrote:
>>>
>>> but it would be maybe even much better if you could put the $trailer
>>> in DB for "filename" instead of $localTrailer, and let mplayer stream
>>> all *.mov files instead of downloading all before someone even knows
>>> whether s/he wants to watch it.
>>>
>>> mplayer or a shell script with mplayer command could cache trailers
>>> and save them for the further watching. but this is more complicated
>>> than your script and I even do not know whether "filename" can contain
>>> absolute paths. this would probably be a "misuse" of this field.
>>
>> You could have the scraping script write the network address of the
>> file to the database and a custom playing script to the database. The
>> custom playing script would stream the file and write it to the hard
>> drive at the same time, and then remove the custom viewing script from
>> the database (so that subsequent plays use the "default" player.
>
> That could also be done if someone only uses "default" player. Nice idea.
>
> But I do not use it for MythVideo because of some problems with subtitles and
> because mplayer is much more configurable (position of subtitles,
> using of core-avc-for-linux, less cpu...)

If playcommand is set to NULL in the database then the system default
player is used, that depends on what you have set it to be, not
necessarily "Internal" - mine is set to mplayer.

what I am saying though is you could easily set up a logic for:

1. not downloading the video file unless someone wants to watch it;

2. after someone has watched (and downloaded) it once, it doesn't need
to be downloaded next time.

this can be done by manipulating the filename and playcommand fields
in the database.



> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
>
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
2008/6/26 Nick Rout <nick.rout@gmail.com>:
> On Thu, Jun 26, 2008 at 11:02 PM, Ma Begaj <derliebegott@gmail.com> wrote:
>> 2008/6/26 Nick Rout <nick.rout@gmail.com>:
>>> On Thu, Jun 26, 2008 at 9:23 PM, Ma Begaj <derliebegott@gmail.com> wrote:
>>>>
>>>> but it would be maybe even much better if you could put the $trailer
>>>> in DB for "filename" instead of $localTrailer, and let mplayer stream
>>>> all *.mov files instead of downloading all before someone even knows
>>>> whether s/he wants to watch it.
>>>>
>>>> mplayer or a shell script with mplayer command could cache trailers
>>>> and save them for the further watching. but this is more complicated
>>>> than your script and I even do not know whether "filename" can contain
>>>> absolute paths. this would probably be a "misuse" of this field.
>>>
>>> You could have the scraping script write the network address of the
>>> file to the database and a custom playing script to the database. The
>>> custom playing script would stream the file and write it to the hard
>>> drive at the same time, and then remove the custom viewing script from
>>> the database (so that subsequent plays use the "default" player.
>>
>> That could also be done if someone only uses "default" player. Nice idea.
>>
>> But I do not use it for MythVideo because of some problems with subtitles and
>> because mplayer is much more configurable (position of subtitles,
>> using of core-avc-for-linux, less cpu...)
>
> If playcommand is set to NULL in the database then the system default
> player is used, that depends on what you have set it to be, not
> necessarily "Internal" - mine is set to mplayer.
>
> what I am saying though is you could easily set up a logic for:
>
> 1. not downloading the video file unless someone wants to watch it;
>
> 2. after someone has watched (and downloaded) it once, it doesn't need
> to be downloaded next time.
>
> this can be done by manipulating the filename and playcommand fields
> in the database.
>

Sorry, I thought you are talking about "Internal" when you said "default" :)
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
Ma Begaj wrote:
2008/6/26 Nick Rout <nick.rout@gmail.com>:
On Thu, Jun 26, 2008 at 11:02 PM, Ma Begaj <derliebegott@gmail.com> wrote:
2008/6/26 Nick Rout <nick.rout@gmail.com>:
On Thu, Jun 26, 2008 at 9:23 PM, Ma Begaj <derliebegott@gmail.com> wrote:
but it would be maybe even much better if you could put the $trailer in DB for "filename" instead of $localTrailer, and let mplayer stream all *.mov files instead of downloading all before someone even knows whether s/he wants to watch it. mplayer or a shell script with mplayer command could cache trailers and save them for the further watching. but this is more complicated than your script and I even do not know whether "filename" can contain absolute paths. this would probably be a "misuse" of this field.
You could have the scraping script write the network address of the file to the database and a custom playing script to the database. The custom playing script would stream the file and write it to the hard drive at the same time, and then remove the custom viewing script from the database (so that subsequent plays use the "default" player.
That could also be done if someone only uses "default" player. Nice idea. But I do not use it for MythVideo because of some problems with subtitles and because mplayer is much more configurable (position of subtitles, using of core-avc-for-linux, less cpu...)
If playcommand is set to NULL in the database then the system default player is used, that depends on what you have set it to be, not necessarily "Internal" - mine is set to mplayer. what I am saying though is you could easily set up a logic for: 1. not downloading the video file unless someone wants to watch it; 2. after someone has watched (and downloaded) it once, it doesn't need to be downloaded next time. this can be done by manipulating the filename and playcommand fields in the database.
Sorry, I thought you are talking about "Internal" when you said "default" :) _______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users

Quite like the stream/cache idea - I'll look into that as I wasn't too happy about downloading everything, especially as I haven't worked out a delete mechanism yet..

I'll have to put it on hold for a day or so - my BE has started failing with out-of-memory errors regularly since yesterday and I need to sort that out first.

John
Re: Apple Trailer Downloader [ In reply to ]
John Payne wrote:
Ma Begaj wrote:
2008/6/26 Nick Rout <nick.rout@gmail.com>:
On Thu, Jun 26, 2008 at 11:02 PM, Ma Begaj <derliebegott@gmail.com> wrote:
2008/6/26 Nick Rout <nick.rout@gmail.com>:
On Thu, Jun 26, 2008 at 9:23 PM, Ma Begaj <derliebegott@gmail.com> wrote:
but it would be maybe even much better if you could put the $trailer in DB for "filename" instead of $localTrailer, and let mplayer stream all *.mov files instead of downloading all before someone even knows whether s/he wants to watch it. mplayer or a shell script with mplayer command could cache trailers and save them for the further watching. but this is more complicated than your script and I even do not know whether "filename" can contain absolute paths. this would probably be a "misuse" of this field.
You could have the scraping script write the network address of the file to the database and a custom playing script to the database. The custom playing script would stream the file and write it to the hard drive at the same time, and then remove the custom viewing script from the database (so that subsequent plays use the "default" player.
That could also be done if someone only uses "default" player. Nice idea. But I do not use it for MythVideo because of some problems with subtitles and because mplayer is much more configurable (position of subtitles, using of core-avc-for-linux, less cpu...)
If playcommand is set to NULL in the database then the system default player is used, that depends on what you have set it to be, not necessarily "Internal" - mine is set to mplayer. what I am saying though is you could easily set up a logic for: 1. not downloading the video file unless someone wants to watch it; 2. after someone has watched (and downloaded) it once, it doesn't need to be downloaded next time. this can be done by manipulating the filename and playcommand fields in the database.
Sorry, I thought you are talking about "Internal" when you said "default" :) _______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users

Quite like the stream/cache idea - I'll look into that as I wasn't too happy about downloading everything, especially as I haven't worked out a delete mechanism yet..

I'll have to put it on hold for a day or so - my BE has started failing with out-of-memory errors regularly since yesterday and I need to sort that out first.

John


_______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Sorry for the delay.
I've made some changes in the last couple of days and hope to get them tested over the weekend.

The script now runs in 2 modes:
batch - will function as now, but with an option to save the URL of the trailer rather than the trailer itself. In this case the playcommand is set to call the script in the other mode (player) with the ID of the newly created record.

In the player mode the script fetches the URL and starts mplayer with the dump options. When completed it updates the filename to point to the newly downloaded file and clears the playercommand entry.

I thought it would be simpler to use the same script but then realised that if the BE & FE are on different machines then the script needs to be on all (and in the same place)

There also needs be some checking in case the user cancels the streaming before it's finished I guess. Not sure how to check that - I'll need to experiment with mplayer for return codes etc. If it is cancelled (or fails) I won't change anything as the download is probably incomplete or unwanted.

Hope to be able to post over the weekend

John
Re: Apple Trailer Downloader [ In reply to ]
On Fri, Jul 4, 2008 at 3:34 AM, John Payne <mythtv@payne.ch> wrote:


Nice to see this idea come to fruition, I am not enough of a coder to
do more than a rough hack of it, and too lazy ooops I mean busy to
have even started!


> There also needs be some checking in case the user cancels the streaming
> before it's finished I guess. Not sure how to check that - I'll need to
> experiment with mplayer for return codes etc. If it is cancelled (or fails)
> I won't change anything as the download is probably incomplete or unwanted.


The movie file size is in the apple xml file I think.

<preview>
<large filesize="15590852">
http://movies.apple.com/movies/fox/australia/australia-tlrc_h640w.mov
</large>
</preview>

Could this be used to test the file on your machine?

Not sure where you would store it.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
Nick Rout wrote:
On Fri, Jul 4, 2008 at 3:34 AM, John Payne <mythtv@payne.ch> wrote: Nice to see this idea come to fruition, I am not enough of a coder to do more than a rough hack of it, and too lazy ooops I mean busy to have even started!
There also needs be some checking in case the user cancels the streaming before it's finished I guess. Not sure how to check that - I'll need to experiment with mplayer for return codes etc. If it is cancelled (or fails) I won't change anything as the download is probably incomplete or unwanted.
The movie file size is in the apple xml file I think. <preview> <large filesize="15590852"> http://movies.apple.com/movies/fox/australia/australia-tlrc_h640w.mov"]http://movies.apple.com/movies/fox/australia/australia-tlrc_h640w.mov </large> </preview> Could this be used to test the file on your machine? Not sure where you would store it. _______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Of course, yes, thanks for the reminder - I only looked at length (minutes) which I save in the DB.
I think I need a slight change - looks like I'll have to stream then download - mplayer doesn't seem to be able to do both at the same time.
However I assume I can then check for a premature completion and assume that the user doesn't want to save it
Re: Apple Trailer Downloader [ In reply to ]
John Payne wrote:
Nick Rout wrote:
On Fri, Jul 4, 2008 at 3:34 AM, John Payne <mythtv@payne.ch> wrote: Nice to see this idea come to fruition, I am not enough of a coder to do more than a rough hack of it, and too lazy ooops I mean busy to have even started!
There also needs be some checking in case the user cancels the streaming before it's finished I guess. Not sure how to check that - I'll need to experiment with mplayer for return codes etc. If it is cancelled (or fails) I won't change anything as the download is probably incomplete or unwanted.
The movie file size is in the apple xml file I think. <preview> <large filesize="15590852"> http://movies.apple.com/movies/fox/australia/australia-tlrc_h640w.mov"]http://movies.apple.com/movies/fox/australia/australia-tlrc_h640w.mov </large> </preview> Could this be used to test the file on your machine? Not sure where you would store it. _______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Of course, yes, thanks for the reminder - I only looked at length (minutes) which I save in the DB.
I think I need a slight change - looks like I'll have to stream then download - mplayer doesn't seem to be able to do both at the same time.
However I assume I can then check for a premature completion and assume that the user doesn't want to save it

_______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Hmm, size does matter....
Unfortunately I can get the filesize when I read in the list of trailers, but when the player runs (and downloads) I don't have the XML structure anymore, and I don't see a suitable column in the videometadata to (mis)use...

Back to the drawing board
Re: Apple Trailer Downloader [ In reply to ]
John Payne wrote:
John Payne wrote:
Nick Rout wrote:
On Fri, Jul 4, 2008 at 3:34 AM, John Payne <mythtv@payne.ch> wrote: Nice to see this idea come to fruition, I am not enough of a coder to do more than a rough hack of it, and too lazy ooops I mean busy to have even started!
There also needs be some checking in case the user cancels the streaming before it's finished I guess. Not sure how to check that - I'll need to experiment with mplayer for return codes etc. If it is cancelled (or fails) I won't change anything as the download is probably incomplete or unwanted.
The movie file size is in the apple xml file I think. <preview> <large filesize="15590852"> http://movies.apple.com/movies/fox/australia/australia-tlrc_h640w.mov"]http://movies.apple.com/movies/fox/australia/australia-tlrc_h640w.mov </large> </preview> Could this be used to test the file on your machine? Not sure where you would store it. _______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Of course, yes, thanks for the reminder - I only looked at length (minutes) which I save in the DB.
I think I need a slight change - looks like I'll have to stream then download - mplayer doesn't seem to be able to do both at the same time.
However I assume I can then check for a premature completion and assume that the user doesn't want to save it

_______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Hmm, size does matter....
Unfortunately I can get the filesize when I read in the list of trailers, but when the player runs (and downloads) I don't have the XML structure anymore, and I don't see a suitable column in the videometadata to (mis)use...

Back to the drawing board


_______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Now we see the fundamental problem inherent in the system....
I assumed that if I create a nice record in the videometadata table then it will appear in the Video library. Unfortunately Mythvideo seems to scan the video folders then gets the metadata from the table. As a result I can't select the new trailers as thee are no files....

All that work for nowt. Thinks: perhaps I could create a dummy file with touch?

:-(

John
Re: Apple Trailer Downloader [ In reply to ]
On Sat, Jul 5, 2008 at 4:06 AM, John Payne <mythtv@payne.ch> wrote:
> John Payne wrote:
>
>
>
> Now we see the fundamental problem inherent in the system....
> I assumed that if I create a nice record in the videometadata table then it
> will appear in the Video library. Unfortunately Mythvideo seems to scan the
> video folders then gets the metadata from the table. As a result I can't
> select the new trailers as thee are no files....
>
> All that work for nowt. Thinks: perhaps I could create a dummy file with
> touch?
>
> :-(
>
> John
>

Yes you can use a dummy file. At one stage I had a dummy file with a
custom play command to get NASATv streamed.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Re: Apple Trailer Downloader [ In reply to ]
Nick Rout wrote:
On Sat, Jul 5, 2008 at 4:06 AM, John Payne <mythtv@payne.ch> wrote:
John Payne wrote: Now we see the fundamental problem inherent in the system.... I assumed that if I create a nice record in the videometadata table then it will appear in the Video library. Unfortunately Mythvideo seems to scan the video folders then gets the metadata from the table. As a result I can't select the new trailers as thee are no files.... All that work for nowt. Thinks: perhaps I could create a dummy file with touch? :-( John
Yes you can use a dummy file. At one stage I had a dummy file with a custom play command to get NASATv streamed. _______________________________________________ mythtv-users mailing list mythtv-users@mythtv.org http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users"]http://mythtv.org/cgi-bin/mailman/listinfo/mythtv-users
Probably the last reply on this thread. I've attached the latest version (I assume the attachment stays).

If it's run in batch mode with streaming option, ie -b -s it creates a dummy video file containing the URL of the trailer - this ensures that the entry is shown in Mythvideo. It also sets the palcommand to call this script with options -p -i <intid>, where <intid> is the primary key of the videometadata record.
When the user selects the trailer in Mythvideo the script gets the URL from the file, streams it with mplayer, then downloads the trailer (I couldn't stream and download with 1 command). Finally it clears the playcommand so future selection will run with the Internal player (or the player defined for mov files).

BUT: at the moment I'm running the batch without the -s option ie download each trailer during the nightly cron trigger. The stream/download is nice space wise, but not very user-friendly at the moment as you have to wait for the download to complete after watching the trailer before you can move to another selection. I need t kick off the download in the background, which implies a more complex monitoring in case it fails. Ideally it should be a real plugin rather than a mis-use of Mythvideo

So if any one wants to give it a go let me know how you get on. The video & poster directories are still hard-coded. It was interesting to implement

John