Ticket #6264: tmdb.pl.diff

File tmdb.pl.diff, 2.9 KB (added by paul [at] planar.id.au, 17 years ago)

diff file for tmdb.pl

Line 
188,91c88
2<
3< # there can be multiple movies with the same imdbid, movie also has an id attribute. Force xml to ignore this id
4< # attribute, and always create an array of movies
5< my $xml = $xs->XMLin($response, forcearray => ['movie'], KeyAttr=>[ ]);
6---
7> my $xml = $xs->XMLin($response);
896d92
9< # there may be multiple movies with this id - assume the first one is the one we want
1098c94
11< my $tmdbid = $xml->{moviematches}->{movie}->[0]->{id};
12---
13> my $tmdbid = $xml->{moviematches}->{movie}->{id};
14146,164c142,159
15< if (exists $xml->{moviematches}->{movie}->{people}->{person}) {
16< my @castlist = @{$xml->{moviematches}->{movie}->{people}->{person}};
17< for (my $i = 0; $i < @castlist; $i++)
18< {
19< if ($castlist[$i]->{job} eq "actor")
20< {
21< $lcast[$cc++] = $castlist[$i]->{name};
22< }
23<
24< if ($castlist[$i]->{job} eq "director")
25< {
26< $ldirector[$dc++] = $castlist[$i]->{name};
27< }
28<
29< if ($castlist[$i]->{job} eq "writer")
30< {
31< $lwriter[$wc++] = $castlist[$i]->{name};
32< }
33< }
34---
35> my @castlist = @{$xml->{moviematches}->{movie}->{people}->{person}};
36> for (my $i = 0; $i < @castlist; $i++)
37> {
38> if ($castlist[$i]->{job} eq "actor")
39> {
40> $lcast[$cc++] = $castlist[$i]->{name};
41> }
42>
43> if ($castlist[$i]->{job} eq "director")
44> {
45> $ldirector[$dc++] = $castlist[$i]->{name};
46> }
47>
48> if ($castlist[$i]->{job} eq "writer")
49> {
50> $lwriter[$wc++] = $castlist[$i]->{name};
51> }
52>
53201,203c196
54< # movie has an id attribute, we don't want this created into a hash, so force no key attr
55< my $xml = XMLin($response, forcearray => [ 'movie', 'poster', 'backdrop'], KeyAttr => { } );
56< print Dumper($xml);
57---
58> my $xml = XMLin($response, forcearray => [ 'poster', 'backdrop' ]);
59205a199
60> my $poster = $xml->{moviematches}->{movie}->{poster}->[0]->{content};
61207,210c201,203
62< my $poster;
63<
64< # there can be multiple movies with the same imdb id
65< foreach my $m (@{$xml->{moviematches}->{movie}})
66---
67> if ($poster) {
68> # check for a mid sized poster
69> foreach my $p (@{$xml->{moviematches}->{movie}->{poster}})
70212,213c205
71< # check for a mid sized poster
72< foreach my $p (@{$m->{poster}})
73---
74> if ($p->{size} eq "mid")
75215,219c207,208
76< if ($p->{size} eq "mid")
77< {
78< $poster = $p->{content};
79< last;
80< }
81---
82> $poster = $p->{content};
83> last;
84225a215
85> }