source: misc/radiorai.py

Last change on this file was 2, checked in by mancausoft, 13 years ago

Added slavebot and Radio rai downloader

File size: 1.4 KB
Line 
1#!/usr/bin/env python
2# -*- coding: utf-8 -*-
3#
4# Copyright (C) 2011 Andrea Milazzo aka mancausoft <me@mancausoft.org>
5#
6#  This Program is free software. It comes without any warranty, to
7#  the extent permitted by applicable law. You can redistribute it
8#  and/or modify it under the terms of the Do What The Fuck You Want
9#  To Public License, Version 2, as published by Sam Hocevar. See
10#  http://sam.zoy.org/wtfpl/COPYING for more details.
11
12from threading import Thread
13import urllib
14import sys, os
15from BeautifulSoup import BeautifulSoup
16
17def convert(namefile, rtsp_url):
18    os.system("mplayer -dumpstream " + rtsp_url + " -dumpfile " + namefile)
19    os.system("ffmpeg2theora -o " + namefile.split('.')[0] + ".ogg " + namefile)
20    os.system("rm " + namefile)
21
22args = sys.argv
23
24try:
25    url = args[1]
26except IndexError:
27    print "Use: " + args[0] + " <urls>"
28    sys.exit(2)
29
30if url[:7] != "http://":
31    url = "http://" + url
32
33html = urllib.urlopen(url).read()
34soup = BeautifulSoup(html)
35
36data = soup.findAll('div', {'class' : 'scroll-pane'})
37data = data[0].findAll('a')
38data.reverse()
39
40tr =[]
41for i in data:
42    rtsp_url = urllib.urlopen(i['href']).read().replace('\n','')
43    namefile = rtsp_url.split('/')[-1]
44    #print "mplayer -dumpstream " + rtsp_url + " -dumpfile " + namefile
45    t = Thread(None, convert, None, (namefile, rtsp_url))
46    t.start()
47    tr.append(t)
48
49for i in tr:
50    i.join()
51
Note: See TracBrowser for help on using the repository browser.