Progressive download with Urllib2.

Discussion in 'Python' started by r0g, Dec 6, 2008.

  1. r0g

    r0g Guest

    Hi There,

    I am trying to download some video with python but have run aground on
    the rocky shores of pseudostreaming. Fingers crossed someone else here
    has some experience with this! Here's what I've done so far...

    The initial link is foo.asx so I download that with...

    handle = urllib2.urlopen( 'http://www.example.com/foo.asx' )
    mime_type = url_handle.info().getheader("Content-Type","")
    data = urllib2.read()

    It comes back with mime type of 'video/x-ms-asf' and the content...
    'ASF http://www.example.com/foo-100.wmv'

    I then used the same code again to grab the URL (ditching the 'ASF '
    bit) and this time it comes back with a mime type of 'video/x-ms-wvx'
    and two URLs...

    Ref1=http://www.example.com/foo-100.wmv?MSWMExt=.asf
    Ref2=http://192.168.0.1/foo-100.wmv?MSWMExt=.asf

    The latter is no use as it's on a private LAN and the second is the same
    URL as last time, just with a different mime type and naturally it
    returns the same thing if I use Urllib2 open and read to fetch it with
    or without the '?MSWMExt=.asf' part. So...

    I fired up wireshark and spotted these lines coming back in the headers:

    Server: Cougar/9.01.01.3862

    Supported: com.microsoft.wm.srvppair, com.microsoft.wm.sswitch,
    com.microsoft.wm.predstrm, com.microsoft.wm.fastcache,
    com.microsoft.wm.startupprofile

    Euw...

    I suspected for a second that meant I have to connect with a MS media
    player or something but the same URL works fine when I paste it into
    Firefox and the video starts pseudostreaming away so...

    How can I get their server to give me the video data? Do I need to ask
    for the file with some other protocol? RTSP? or change my user_agent
    string and pretend to be Windows Media Player?? Do I need another
    module as opposed to urllib2? and if so which one? I've had a search but
    drawn a blank.

    I guess I'll plug on in wireshark and see what some other programs do
    but I'd appreciate it if anyone can put me out of my misery!

    Yours stuck,

    Roger Heathcote.
    r0g, Dec 6, 2008
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wilson k. tsugue

    how to not to show progressive content in browser

    wilson k. tsugue, Aug 20, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    324
    Kevin Spencer
    Aug 20, 2003
  2. dorayme

    progressive jpgs

    dorayme, Jun 8, 2005, in forum: HTML
    Replies:
    5
    Views:
    444
    Travis Newbury
    Jun 8, 2005
  3. Andrew Gabriel
    Replies:
    1
    Views:
    527
    Benjamin Niemann
    Sep 6, 2005
  4. Girish
    Replies:
    3
    Views:
    861
    Nick Kew
    Apr 11, 2005
  5. Jon
    Replies:
    0
    Views:
    429
Loading...

Share This Page