Akamai problem

David Woodhouse dwmw2 at infradead.org
Wed May 26 12:55:21 EDT 2010


On Wed, 2010-05-26 at 13:06 +0100, David Woodhouse wrote:
> This is odd -- your version _looks_ right. It's doing precisely what I
> see the real flash player doing, if I snoop its network traffic. But
> even when I try running rtmpdump manually with the parameters I see in
> that network capture, I can't make it work. Only the "obviously wrong"
> version actually works... 

Aha, the reason is that the authString from the mediaselector page at 
http://www.bbc.co.uk/mediaselector/4/mtis/stream/$verpid doesn't work.

You have to fetch a _different_ mediaselector page from
mediaselector/4/mtis/stream/$verpid/$service/$kind instead, and then it
works.

This seems to fix it, but could probably do with proper XML parsing to
find the new authString. Perhaps we should do it for all CDNs, too?]

And can someone who actually knows perl tell me if there's a better way
to pass in the 'media_selector_prefix'?

diff --git a/get_iplayer b/get_iplayer
index 485979d..92b2902 100755
--- a/get_iplayer
+++ b/get_iplayer
@@ -5641,7 +5641,18 @@ sub get_stream_data_cdn {
 				main::logger "\n$xml\n" if $opt->{debug};
 				$cattribs->{authString} = 'auth='.$1 if $xml =~ m{<token>(.+?)</token>};
 				$conn->{authstring} = $cattribs->{authString};
-			}
+			} elsif ( $mattribs->{media_selector_prefix} ) {
+				# The authString from the original media selector page doesn't work;
+			        # we need to fetch a new one from the media-specific page.
+				my $url = "$mattribs->{media_selector_prefix}/$mattribs->{service}/$cattribs->{kind}?cb=".( sprintf "%05.0f", 99999*rand(0) );
+
+				my $xml = main::request_url_retry( main::create_ua( 'desktop' ), $url, 3, undef, undef, 1 );
+				main::logger "\n$xml\n" if $opt->{debug};
+				$cattribs->{authString} = $1 if $xml =~ m{authString=\"(.+?)\"};
+				main::logger "\nauthString $cattribs->{authString}\n";
+				decode_entities($cattribs->{authString});
+				$conn->{authstring} = $cattribs->{authString};
+			}	    
 
 			if ( $cattribs->{authString} ) {
 				### ??? live and Live TV, Live EMP Video or Non-public EMP video:
@@ -5766,6 +5777,7 @@ sub get_stream_data {
 	my $data = {};
 	my $media_stream_data_prefix = 'http://www.bbc.co.uk/mediaselector/4/mtis/stream/'; # $verpid
 	my $media_stream_live_prefix = 'http://www.bbc.co.uk/mediaselector/4/gtis/stream/'; # $verpid
+	my $media_stream_prefix;
 
 	# Setup user agent with redirection enabled
 	my $ua = main::create_ua( 'desktop' );
@@ -5819,7 +5831,9 @@ sub get_stream_data {
 
 	# Could also use Javascript based one: 'http://www.bbc.co.uk/iplayer/mediaselector/4/js/stream/$verpid?cb=NNNNN
 	} else {
-		$xml = main::request_url_retry( $ua, $media_stream_data_prefix.$verpid.'?cb='.( sprintf "%05.0f", 99999*rand(0) ), 3, undef, undef, 1 );
+		$media_stream_prefix = $media_stream_data_prefix.$verpid;
+		$xml = main::request_url_retry( $ua, $media_stream_prefix.'?cb='.( sprintf "%05.0f", 99999*rand(0) ), 3, undef, undef, 1 );
+
 		main::logger "\n$xml\n" if $opt->{debug};
 		@medias = parse_metadata( $xml );
 	}
@@ -5827,7 +5841,10 @@ sub get_stream_data {
 	# Parse and dump structure
 	my $mode;
 	for my $mattribs ( @medias ) {
-		
+		if ( $media_stream_prefix ) {
+			$mattribs->{media_selector_prefix} = $media_stream_prefix;
+		}
+
 		# New iphone stream
 		if ( $mattribs->{service} eq 'iplayer_streaming_http_mp4' ) {
 			# Fix/remove some audio stream attribs


-- 
dwmw2




More information about the get_iplayer mailing list