Menu

[f7b098]: / movpod.py  Maximize  Restore  History

Download this file

78 lines (60 with data), 2.1 kB

 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/python
# -*- coding: iso-8859-15 -*-
def parse(URL, debug=False):
# this parser doesn't work
return {'directlink': '', 'filename': ''}
from time import sleep
from htmlparser import between, Eval
from httpclient import HttpClient
r = HttpClient(debug=debug)
r.GET(URL)
filename = between(r.Page, 'name="fname" value="', '"')
# manually set JavaScript-set cookies
# r.Cookies.append = {
# '__utma': # Google Analytics cookies
# '__utmb':
# '__utmc':
# '__utmv':
# '__utmz':
# 'ad_referer': '',
# 'aff': '1',
# 'lang': 'english'
# }
# "Continue" form
form = r.Page.findForm(number=2)
del form.input['method_premium']
#form.input['referer'].value = URL
form.input['method_free'].value = 'Free Download'
r.Cookies['ad_referer'] = ''
r.Cookies['__utma']='5195046.1779219333.1372885161.1372885161.1373715176.2'
r.Cookies['__utmb']='5195046.4.10.1373715176'
r.Cookies['__utmc']='5195046'
r.Cookies['__utmz']='5195046.1372885161.1.1.utmcsr=watchseries.lt|utmccn=(referral)|utmcmd=referral|utmcct=/open/cale/3748860.html'
# wait
for i in range(5):
sleep(1)
print str(5-i)
host = URL
if 'http://' in host:
host = host[7:]
host = host[:host.find('/')]
#print host
r.POST(URL, form=form, AdditionalHeaders={'Origin':host, 'Referer':URL, 'Accept':'text/html,application/xhtml+xml,application/xml', 'Accept-Language':'en-US,en'})
#/cgi-bin/index_dlf.cgi?op=track_view&file_code=atqunkn8k2xy&rnd=0.3730618921108544
# check
if 'value="Continue"' in str(r.Page):
print 'Warning: There is a "Continue" button on this page.'
if not 'player_code' in str(r.Page):
print 'Warning: There is no player on this page.'
if not 'flashvars' in str(r.Page):
print 'Warning: No flashvars on this page.'
# find URL
url = between(r.Page, 'file: "', '"')
if url == '':
url = between(r.Page, 'file:"', '"')
if url == '':
print 'Failed to extract URL'
return {'directlink': url, 'filename': filename}
if __name__ == "__main__":
from sys import argv
print str( parse(argv[1]) )