This small python script downloads flash videos (.flv) from on-demand video sites.
It currently supports youtube and dailymotion, but can easily be extended.
It can be used as a command-line tool or as an external module via its simple interface.
It looks like this:
>>> from videosucker import * >>> vid = Video('http://youtube.com/watch?v=-vdnosP9o9U') >>> vid.getTitle() 'Show Todd Oldham your DIY Videos' >>> vid.getUrl() # this returns the url of the .flv, ready to be downloaded 'http://youtube.com/get_video.php?video_id=-vdnosP9o9U&l=54&t=OEgsToPDskIeUdWeehsHuRw_j-xvJgYb&sk=FqXPW6fC9eR5HzX5oBG3FwC&fs=1' >>> vid.getSize() # in bytes 2483759 >>> # to download a video, you pass the object a file descriptor ... fd = open('test.flv', 'w') >>> # you can also pass it an indicator object. This is optional. ... ind = SimpleIndicator() >>> vid.download(fd, ind.setPercent) # you actually don't pass it the indicator object, but a method to adjust the percent done. 10% .. 20% .. 30% .. 40% .. 50% .. 60% .. 70% .. 80% .. 90% .. 100% .. >>> # when invoked from the command line, it uses the TermIndicator indicator. ... fd.close() # do not forget this!
It raises a SiteError exception when something goes wrong (bad url, mainly)
the link is here.
As usual, see the source for more details.
Note: 0.2 breaks compatibility by changing some methods and classes names. There's however very little chance anybody downloaded it, so I thought it was okay.