Last active 1692141866

Get videos from Clickview server

Steven Smith revised this gist 1396932304. Go to revision

1 file changed, 43 insertions

clickviewvids.py(file created)

@@ -0,0 +1,43 @@
1 + import requests
2 + import sys
3 + import os
4 + from bs4 import BeautifulSoup as Soup
5 +
6 + if len(sys.argv) < 2:
7 + print sys.argv[0] + " <IP of server / ID of video> [ID of video] - Second arg is needed if first arg is IP"
8 + sys.exit(2)
9 +
10 + CVSERVER = "10.232.66.197"
11 + if "." in sys.argv[1]:
12 + CVSERVER = sys.argv[1]
13 + sys.argv[1] = sys.argv[2]
14 + print "server: " + CVSERVER
15 + if not server:
16 + print "Invalid server provided."
17 + sys.exit(2)
18 +
19 + request = """<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/"><s:Body><GetVideo xmlns="http://ClickView.Web.CentralWebServices.ClickViewWebPlayer"><tokenId>{id}</tokenId></GetVideo></s:Body></s:Envelope>""".format(id=sys.argv[1])
20 +
21 + headers = {"Content-Length": len(request), "Content-Type": "text/xml", "SOAPAction": "http://ClickView.Web.CentralWebServices.ClickViewWebPlayer/IWebPlayerService/GetVideo"}
22 +
23 + data = requests.post("http://{addr}:9053/WebPlayerService.svc".format(addr=CVSERVER), headers=headers, data=request)
24 + soup = Soup(data.text)
25 +
26 + chapters = soup.findAll('a:video.videochapter')
27 + files = {}
28 + for a in chapters:
29 + files[a.find('a:number').text] = {'url': a.find('a:file').text,
30 + 'title': a.find('a:title').text,
31 + 'ext': a.find('a:filetype').text.split(".")[-1],
32 + "vid": sys.argv[1],
33 + "fid": a.find('a:number').text}
34 + print "got {} files".format(len(files))
35 + with open("{}.bat".format(sys.argv[1]), "w") as f:
36 + for v in files.values():
37 + try:
38 + os.mkdir(v["vid"])
39 + except:
40 + pass
41 + f.write("wget {url} -O {vid}/{vid}-{fid}.{ext}\n".format(**v))
42 + print "Done {vid}/{vid}-{fid}.{ext}".format(**v)
43 + print "done"
Newer Older