]>
git.frykholm.com Git - svtplaydump.git/blob - svtplaydump.py
c61c36e8b05b1cdefff369f75b80c195f0b275f7
3 # (C) Copyright 2010 Mikael Frykholm <mikael@frykholm.com>
5 # This program is free software: you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation, either version 3 of the License, or
8 # (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program. If not, see <http://www.gnu.org/licenses/>
19 # 0.2 added python 2.4 urlparse compatibility
22 from BeautifulSoup
import BeautifulSoup
23 from subprocess
import *
32 import urllib2
.urlparse
as urlparse
40 videoid
= re
.findall("/video/(.*)[/]*",argv
[1])[0]
42 soup
= BeautifulSoup(urllib2
.urlopen("http://www.svtplay.se/video/%s/?type=embed"%videoid
).read())
44 flashvars
= json
.loads(soup
.find("param", {"name":"flashvars",'value':True})['value'][5:])
46 title
= flashvars
['statistics']['title']
49 if 'dynamicStreams' in flashvars
:
50 url
= flashvars
['dynamicStreams'][0].split('url:')[1].split('.mp4,')[0] +'.mp4'
51 filename
= title
+".mp4"
52 print Popen(["rtmpdump",u
"-o"+filename
,"-r", url
], stdout
=PIPE
).communicate()[0]
53 if 'pathflv' in flashvars
:
54 rtmp
= flashvars
['pathflv'][0]
55 filename
= title
+".flv"
56 print Popen(["mplayer","-dumpstream","-dumpfile",filename
, rtmp
], stdout
=PIPE
).communicate()[0]
57 if 'video' in flashvars
:
58 url
= sorted(flashvars
['video']['videoReferences'], key
=lambda k
: k
['bitrate'])[-1]['url']
59 filename
= title
+".mp4"
60 print Popen(["rtmpdump",u
"-o"+filename
,"-r", url
], stdout
=PIPE
).communicate()[0]
63 print "Could not find any streams"
66 if __name__
== "__main__":