views:

59

answers:

2

I am scraping forum website by type (article, webinar, video) I thought if ruby can extract somehow the length of the video. The corresponding html part of the web page looks like.

<div align="center"><script type="text/javascript" src="http://somedomain.com/wp-content/themes/thesis/custom/swfobject.js"&gt;&lt;/script&gt;

<div id="player">This text will be replaced</div>

<script type="text/javascript">
var so = new SWFObject('http://somedomain.com/forum/yota/audio_player/player.swf','mpl','640','500','9');
so.addParam('allowscriptaccess','always');
so.addParam('allowfullscreen','true');
so.addParam('flashvars','&amp;file=http://somedomain.net/flv/ezinearticles/ezinearticles.flv&amp;amp;dock=false');
so.write('player');
</script></div>

Interestingly I can access the flv file directly so I am happy to download all videos and then extract the length somehow. Majority of the files are flv some are wmv.

Please note that I have permission of the forum webmaster to do scrapping.

+1  A: 

I don't know about ruby, but you can always invoke external program, such as ffmpeg or mplayer with file as an argument, and parse the output. Take a look at:

http://www.linuxquestions.org/questions/linux-software-2/getting-file-information-with-ffmpeg-601817/

Mladen Jablanović
@Mladen Jablanović: it works with ffmpeg but I'd like to use ruby only. At least to try :-)
Radek
+1  A: 

ffmpeg-ruby looks like it does what you want.

agregoire
@agregoire: did you make it work under windows?
Radek
@Radek: I've never tried. Are you having problems compiling it ?
agregoire
@agregoire: never done anything like that on win platform....
Radek
so you think I can do all make, git and configure on windows?
Radek
I don't think it's that straightforward. Googling around, I found two articles that look interesting:http://blog.mmediasys.com/2008/01/17/ruby-for-windows-part-1/andhttp://www.copiousfreetime.org/articles/2008/10/12/building-gems-for-windows.htmlIt does not look fun. If you're stuck on Windows, it will probably be easier to install a ffmpeg binary and invoke it as an external program (like Mladen suggested).
agregoire