1 |
|
---|
2 | import re
|
---|
3 | import sys
|
---|
4 | from lib.net import Net
|
---|
5 |
|
---|
6 | class StreamcloudResolver(UrlResolver):
|
---|
7 | name = "streamcloud"
|
---|
8 | domains = ["streamcloud.eu"]
|
---|
9 | pattern = '(?://|\.)(streamcloud\.eu)/([0-9a-zA-Z]+)'
|
---|
10 |
|
---|
11 | def __init__(self):
|
---|
12 | self.net = Net()
|
---|
13 | url = str(sys.argv[1])
|
---|
14 | host = self.get_host_and_id(url)[0]
|
---|
15 | media_id = self.get_host_and_id(url)[1]
|
---|
16 |
|
---|
17 | return self.get_media_url(host, media_id)
|
---|
18 |
|
---|
19 | def get_host_and_id(self, url):
|
---|
20 | r = re.search(self.pattern, url, re.I)
|
---|
21 | if r:
|
---|
22 | return r.groups()
|
---|
23 | else:
|
---|
24 | return False
|
---|
25 |
|
---|
26 | def get_media_url(self, host, media_id):
|
---|
27 | web_url = self.get_url(host, media_id)
|
---|
28 | resp = self.net.http_GET(web_url)
|
---|
29 | html = resp.content
|
---|
30 | post_url = resp.get_url()
|
---|
31 | if re.search('>(File Not Found)<', html):
|
---|
32 | print 'File Not Found or removed'
|
---|
33 |
|
---|
34 | form_values = {}
|
---|
35 | for i in re.finditer('<input.*?name="(.*?)".*?value="(.*?)">', html):
|
---|
36 | form_values[i.group(1)] = i.group(2).replace("download1", "download2")
|
---|
37 | html = self.net.http_POST(post_url, form_data=form_values).content
|
---|
38 |
|
---|
39 | r = re.search('file: "(.+?)",', html)
|
---|
40 | if r:
|
---|
41 | print r.group(1)
|
---|
42 |
|
---|
43 | def get_url(self, host, media_id):
|
---|
44 | return 'http://streamcloud.eu/%s' % (media_id)
|
---|
45 |
|
---|
46 | sys.stdout = StreamcloudResolver()
|
---|