source: titan/mediathek/localhoster/vidzi.py @ 39232

Last change on this file since 39232 was 39052, checked in by obi, 8 years ago

add new test hoster

File size: 1.4 KB
Line 
1
2import re
3import urllib
4from lib import jsunpack
5import sys
6from lib.net import Net
7
8class VidziResolver(object):
9    name = "vidzi"
10    domains = ["vidzi.tv"]
11    pattern = '(?://|\.)(vidzi\.tv)/(?:embed-)?([0-9a-zA-Z]+)'
12
13    def __init__(self):
14        self.net = Net()
15        url = str(sys.argv[1])
16        host = self.get_host_and_id(url)[0]
17        media_id = self.get_host_and_id(url)[1]
18
19        return self.get_media_url(host, media_id)
20
21    def get_host_and_id(self, url):
22        r = re.search(self.pattern, url, re.I)
23        if r:
24            return r.groups()
25        else:
26            return False
27
28    def get_media_url(self, host, media_id):
29        web_url = self.get_url(host, media_id)
30        html = self.net.http_GET(web_url).content
31
32        if '404 Not Found' in html:
33            print 'File Not Found or removed'
34
35        r = re.search('file\s*:\s*"([^"]+)', html)
36        if r:
37            return r.group(1) + '|' + urllib.urlencode({'Referer': 'http://vidzi.tv/nplayer/jwplayer.flash.swf'})
38        else:
39            for match in re.finditer('(eval\(function.*?)</script>', html, re.DOTALL):
40                js_data = jsunpack.unpack(match.group(1))
41                r = re.search('file\s*:\s*"([^"]+)', js_data)
42                if r:
43                    print r.group(1)
44
45        print 'Unable to locate link'
46
47    def get_url(self, host, media_id):
48        return 'http://%s/embed-%s.html' % (host, media_id)
49
50sys.stdout = VidziResolver()
Note: See TracBrowser for help on using the repository browser.