1 | |
---|
2 | import re |
---|
3 | import sys |
---|
4 | from lib.net import Net |
---|
5 | |
---|
6 | class VideoweedResolver(object): |
---|
7 | name = 'videoweed.es' |
---|
8 | domains = ['bitvid.sx', 'videoweed.es', 'videoweed.com'] |
---|
9 | pattern = '(?://|\.)(bitvid.sx|videoweed.es|videoweed.com)/(?:mobile/video\.php\?id=|video/|embed/\?v=|embed\.php\?v=|file/)([0-9a-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 | |
---|
29 | html = self.net.http_GET(web_url).content |
---|
30 | stream_url = '' |
---|
31 | |
---|
32 | r = re.search('flashvars.filekey=(.+?);', html) |
---|
33 | if r: |
---|
34 | r = r.group(1) |
---|
35 | |
---|
36 | try: filekey = re.compile('\s+%s="(.+?)"' % r).findall(html)[-1] |
---|
37 | except: filekey = r |
---|
38 | |
---|
39 | player_url = 'http://www.bitvid.sx/api/player.api.php?key=%s&file=%s' % (filekey, media_id) |
---|
40 | |
---|
41 | html = self.net.http_GET(player_url).content |
---|
42 | |
---|
43 | r = re.search('url=(.+?)&', html) |
---|
44 | |
---|
45 | if r: |
---|
46 | stream_url = r.group(1) |
---|
47 | # else: |
---|
48 | # raise ResolverError('File Not Found or removed') |
---|
49 | |
---|
50 | print stream_url |
---|
51 | |
---|
52 | def get_url(self, host, media_id): |
---|
53 | return 'http://www.bitvid.sx/embed/?v=%s' % media_id |
---|
54 | |
---|
55 | sys.stdout = VideoweedResolver() |
---|