aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNigel Taylor <njtaylor0101@gmail.com>2013-03-05 00:23:20 +0000
committerNigel Taylor <njtaylor0101@gmail.com>2013-03-05 00:23:20 +0000
commit16b93aa63ae5913cfdec37f4445e7b63b46f70c9 (patch)
treec8d1557eb244e180f16ea757f73699cd9d2de3ff
parent2b67dd557a8ee08bffe26a19c7b2062a723e9b4f (diff)
downloadget-flash-videos-16b93aa63ae5913cfdec37f4445e7b63b46f70c9.tar.gz
If single prograame json doesn't return an array, test for an array. If the initial URL is other format site now redirects rather than return the page, add code to handle redirection of first page.
-rw-r--r--lib/FlashVideo/Site/Channel4.pm19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/FlashVideo/Site/Channel4.pm b/lib/FlashVideo/Site/Channel4.pm
index 43b6b46..0dd7b91 100644
--- a/lib/FlashVideo/Site/Channel4.pm
+++ b/lib/FlashVideo/Site/Channel4.pm
@@ -13,12 +13,19 @@ use Time::HiRes qw(time);
use constant TOKEN_DECRYPT_KEY => 'STINGMIMI';
-our $VERSION = '0.03';
+our $VERSION = '0.04';
sub Version() { $VERSION;}
sub find_video {
my ($self, $browser, $embed_url, $prefs) = @_;
+
+ if ($browser->response->is_redirect) {
+ my $relurl = $browser->response->header('Location');
+ info "Relocated to $relurl";
+ $browser->get($relurl);
+ }
+
my $page_url = $browser->uri->as_string;
# Determine series and episode. Channel 4 sometimes have these backwards,
@@ -83,7 +90,15 @@ sub find_video {
my $fstr = sprintf "%s/%03d", $xml_ref->{assetInfo}->{contractId},
$xml_ref->{assetInfo}->{programmeNumber};
info "Looking for programmeId $fstr";
- foreach my $entry ( @{$json->{feed}->{entry}} ) {
+ my @entries;
+ if (ref($json->{feed}->{entry}) eq "ARRAY") {
+ @entries = @{$json->{feed}->{entry}};
+ }
+ else
+ {
+ $entries[0] = $json->{feed}->{entry};
+ }
+ foreach my $entry ( @entries ) {
if ($entry->{'dc:relation.programmeId'} eq $fstr) {
my $ps3_url = $entry->{group}->{player}->{'@url'};
info $entry->{'dc:relation.BrandTitle'} .