]>
code.delx.au - monosys/blob - scripts/sbs-downloader
9 BASE_URL
= "http://player.sbs.com.au"
12 f
= urllib
.urlopen(BASE_URL
+ path
)
18 skeys
= sorted(options
.keys())
19 for i
, key
in enumerate(skeys
):
20 print " %d) %s" % (i
+1, key
)
24 value
= int(raw_input("Choose> "))
27 if value
> 0 and value
<= len(skeys
):
28 return options
[skeys
[value
-1]]
33 settings
= grab_xml("/playerassets/programs/config/standalone_settings.xml")
34 menu_url
= settings
.xpath("/settings/setting[@name='menuURL']/@value")[0]
36 root_menu
= grab_xml(menu_url
)
38 for menu
in root_menu
.xpath("//menu"):
40 title
= menu
.xpath("title/text()")[0]
41 playlist_url
= menu
.xpath("playlist/@xmlSrc")[0]
42 if title
in menu_list
:
45 if (title
+str(i
)) not in menu_list
:
49 menu_list
[title
] = playlist_url
55 def get_video_list(playlist_url
):
57 playlist
= grab_xml(playlist_url
)
58 for video_desc
in playlist
.xpath("//video"):
59 video_desc_url
= video_desc
.xpath("@src")[0]
60 title
= video_desc
.xpath("title/text()")[0]
61 video_list
[title
] = (title
, video_desc_url
)
64 def download_video((title
, video_desc_url
)):
65 video
= grab_xml(video_desc_url
)
66 vbase
= video
.xpath("//meta/@base")[0]
69 for vpath
in video
.xpath("//switch/video"):
70 rate
= float(vpath
.xpath("@system-bitrate")[0])
73 bestvpath
= vpath
.xpath("@src")[0]
74 title
+= "." + bestvpath
.rsplit(".", 1)[1]
75 if bestvpath
.endswith(".flv"):
76 bestvpath
= bestvpath
[:-4]
84 p
= subprocess
.Popen(cmd
)
86 except KeyboardInterrupt:
87 print "Cancelled", cmd
91 except KeyboardInterrupt:
92 p
.send_signal(signal
.SIGKILL
)
97 menu_list
= get_menu_list()
98 playlist_url
= choose(menu_list
)
99 if playlist_url
is None:
101 video_list
= get_video_list(playlist_url
)
103 video_desc_url
= choose(video_list
)
104 if video_desc_url
is None:
106 download_video(video_desc_url
)
108 if __name__
== "__main__":