source: titan/mediathek/localhoster/videoweed.py @ 42882

Last change on this file since 42882 was 39052, checked in by obi, 7 years ago

add new test hoster

File size: 1.6 KB
Line 
1
2import re
3import sys
4from lib.net import Net
5
6class 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
55sys.stdout = VideoweedResolver()
Note: See TracBrowser for help on using the repository browser.