Without flash

Posted in this blog on January 3rd, 2010 by blambi

B”H

Living without flash, yea that is something that is quite simple most
of the time, but well then you get some links to some random video
site and well if it isn’t a nice one it will nag about you lacking a
flash player.

For youtube there is really a lot of different solutions already, but
what about The Onion, That Video Site and a pile of
other sites?

Most of the time I don’t bother looking at ways to look at the clip,
but if I really want to then?

Quite a lot of sites are written nice enough so I can easily read out
the url to the flv/mp4/whatever-file. And well this have lead to me
having a pile of scripts for just this purpose (and then a wrapper
around wget etc to really download them).

The wrapper part most people will have there own solutions for so lets
leave that out, but here is the python script I use for The Onion:

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import urllib, sys

def get_rss_url( url ):
    """fetches the url and tries to find the videoid"""
    string = urllib.urlopen( url ).read()
    for x in string.split( '\n' ):
         xpos = x.find( 'var videoid = "' )
         if xpos != -1:
             return 'http://www.theonion.com/content/xml/' + x[ xpos + len( 'var videoid = "' ) : -2 ] + '/video'

def get_flv_url( rss_url ):
    string = urllib.urlopen( rss_url ).read()
    count = 0
    for x in string.split( '><' ):
        if x.find( "/onion_video/" ) != -1:
            xpos = x.find( ".flv" )
            if xpos != -1:
                return x[15:-21]

if __name__ == '__main__':
    print "get-theonion.py v0.1.3"
    print "© Patrik Lembke 2007 - 2009"
    print "released under the terms of the GPLv3 or later"
    print

    if not len( sys.argv ) == 2 or sys.argv[1].find( "http://" ) == -1:
        print "Usage: get-theonion.py [url]"
        print "get-theonion will just give you the url for the .flv so you can"
        print "for example download it with wget."
    else:
        print "fetching: %s" % sys.argv[1]
        rss_url = get_rss_url( sys.argv[1] )
        print "fetching: %s" % rss_url
        flv_url = get_flv_url( rss_url )
        print "Video was found at: %s" % flv_url

Probably not the most pretty but it works (got another version
integrated in a epiphany extension I’m hacking on).

For more stuff like this take a look at the kakwiki page utan flash.

Tags: