-
Notifications
You must be signed in to change notification settings - Fork 2
/
primetv-dl
executable file
·42 lines (25 loc) · 990 Bytes
/
primetv-dl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/usr/bin/env python
# Copyright Lee Begg 2009
#
# Prime TV video download tool
# Licence: GPL v2 or later
import sys
import re
from viddl.steps import download_step, extract_step, http_download_video_step
const_video_url_param_re = re.compile(r".*so\.addVariable\('file','([^']+)'\);")
const_video_url_real_fmt = "http://www.primetv.co.nz%s"
if(len(sys.argv) > 1):
req_url = sys.argv[1]
else:
print("Usage: %s url" % sys.argv[0])
sys.exit(1)
#should check url first
video_url = req_url
video_webpage = download_step(True, 'Retrieving video webpage', 'unable to retrieve video webpage', video_url)
video_url_param = extract_step('Extracting video URL parameter', 'unable to extract video URL parameter', const_video_url_param_re, video_webpage)
video_url_real = const_video_url_real_fmt % (video_url_param)
print video_url_real
video_filename = video_url_real.split('/')[-1]
http_download_video_step(video_filename, video_url_real)
# Finish
sys.exit()