#!/usr/bin/env python # -*- coding: utf-8 -*- # # Copyright (C) 2011 Andrea Milazzo aka mancausoft # # This Program is free software. It comes without any warranty, to # the extent permitted by applicable law. You can redistribute it # and/or modify it under the terms of the Do What The Fuck You Want # To Public License, Version 2, as published by Sam Hocevar. See # http://sam.zoy.org/wtfpl/COPYING for more details. from threading import Thread import urllib import sys, os from BeautifulSoup import BeautifulSoup def convert(namefile, rtsp_url): os.system("mplayer -dumpstream " + rtsp_url + " -dumpfile " + namefile) os.system("ffmpeg2theora -o " + namefile.split('.')[0] + ".ogg " + namefile) os.system("rm " + namefile) args = sys.argv try: url = args[1] except IndexError: print "Use: " + args[0] + " " sys.exit(2) if url[:7] != "http://": url = "http://" + url html = urllib.urlopen(url).read() soup = BeautifulSoup(html) data = soup.findAll('div', {'class' : 'scroll-pane'}) data = data[0].findAll('a') data.reverse() tr =[] for i in data: rtsp_url = urllib.urlopen(i['href']).read().replace('\n','') namefile = rtsp_url.split('/')[-1] #print "mplayer -dumpstream " + rtsp_url + " -dumpfile " + namefile t = Thread(None, convert, None, (namefile, rtsp_url)) t.start() tr.append(t) for i in tr: i.join()