aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNigel Taylor <njtaylor0101@gmail.com>2013-02-19 00:22:15 +0000
committerNigel Taylor <njtaylor0101@gmail.com>2013-02-19 00:22:15 +0000
commit3d3a504cc11685f87e4c6e70e2afb9b2a36b4bf4 (patch)
treeb7f708fbe1331fd839439e2b3bdc72b0b6a0b3a4
parent4a1cd86b3599aa03c405267331c9cb408fea767c (diff)
downloadget-flash-videos-3d3a504cc11685f87e4c6e70e2afb9b2a36b4bf4.tar.gz
If mp4 stream not found try asset id up to +-6 until found mp4 for ps3, or mp4
for the same programme
-rw-r--r--lib/FlashVideo/Site/Channel4.pm53
1 files changed, 49 insertions, 4 deletions
diff --git a/lib/FlashVideo/Site/Channel4.pm b/lib/FlashVideo/Site/Channel4.pm
index 84c78ea..d556736 100644
--- a/lib/FlashVideo/Site/Channel4.pm
+++ b/lib/FlashVideo/Site/Channel4.pm
@@ -11,6 +11,9 @@ use MIME::Base64;
use constant TOKEN_DECRYPT_KEY => 'STINGMIMI';
+our $VERSION = '0.01';
+sub Version() { $VERSION;}
+
sub find_video {
my ($self, $browser, $embed_url, $prefs) = @_;
@@ -55,11 +58,53 @@ sub find_video {
die "Couldn't get asset XML: " . $browser->response->status_line;
}
- my $xml = from_xml($raw_xml);
+ my $xml_ref = from_xml($raw_xml);
+ my $xml;
+
+
+ # Check for mp4 if not then try different assetId
+ my $lower_id = 0;
+ my $upper_id = 9999999;
+ if ($xml_ref->{assetInfo}->{uriData}->{streamUri} !~ /mp4$/ ) {
+ for (my $off = 2; $off < 14; $off++) {
+ my $asset_off = $off >> 1;
+ $asset_off = -$asset_off if ($off & 1);
+ $asset_off += $asset_id;
+ if ($asset_off > $lower_id && $asset_off < $upper_id) {
+ $raw_xml = $browser->get("http://ais.channel4.com/asset/$asset_off");
+ if ($browser->success) {
+ my $xml_off = from_xml($raw_xml);
+ # Check Same programme
+ if ( $xml_off->{assetInfo}->{brandTitle} eq $xml_ref->{assetInfo}->{brandTitle} &&
+ $xml_off->{assetInfo}->{episodeTitle} eq $xml_ref->{assetInfo}->{episodeTitle} &&
+ $xml_off->{assetInfo}->{programmeNumber} eq $xml_ref->{assetInfo}->{programmeNumber}) {
+ if ($xml_off->{assetInfo}->{uriData}->{streamUri} =~ /mp4$/ ) {
+ $xml = $xml_off;
+ info "Found mp4 stream asset id $asset_off siteSectionId $xml->{assetInfo}->{adverts}->{siteSectionId}";
+ if ($xml->{assetInfo}->{uriData}->{streamUri} =~ /\.ps3-/ ) {
+ last;
+ }
+ }
+ }
+ else {
+ if ($asset_off > $asset_id ) {
+ $upper_id = $asset_off;
+ }
+ else {
+ $lower_id = $asset_off;
+ }
+ }
+ }
+ }
+ }
+ }
+ else {
+ $xml = $xml_ref;
+ }
- my $stream_url = $xml->{assetInfo}->{uriData}->{streamUri};
- my $token = $xml->{assetInfo}->{uriData}->{token};
- my $cdn = $xml->{assetInfo}->{uriData}->{cdn};
+ my $stream_url = $xml->{assetInfo}->{uriData}->{streamUri};
+ my $token = $xml->{assetInfo}->{uriData}->{token};
+ my $cdn = $xml->{assetInfo}->{uriData}->{cdn};
my $decoded_token = decode_4od_token($token);