source: titan/mediathek/localhoster/vivo.py @ 39356

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

fix

File size: 1.2 KB
Line 
1
2import re
3import urllib
4from lib import jsunpack
5import sys
6from lib.net import Net
7
8class VivoResolver(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
31        # get landing page
32        resp = self.net.http_GET(web_url, headers={'Referer': web_url})
33        html = resp.content
34
35        r = re.search(r'Core\.InitializeStream \(\'(.*?)\'\)', html)
36        if not r: print 'page structure changed'
37
38        b = base64.b64decode(r.group(1))
39        j = json.loads(b)
40
41        if len(j) == 0: print 'video not found'
42
43        print j[0]
44
45    def get_url(self, host, media_id):
46        return 'http://%s/%s' % (host, media_id)
47
48sys.stdout = VivoResolver()
Note: See TracBrowser for help on using the repository browser.