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

Last change on this file since 42882 was 39359, 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
7import base64
8import json
9from lib import helpers
10
11class VivoResolver(object):
12    name = "vivosx"
13    domains = ["vivo.sx"]
14    pattern = '(?://|\.)(vivo\.sx)/([0-9a-zA-Z]+)'
15
16    def __init__(self):
17        self.net = Net()
18        url = str(sys.argv[1])
19        host = self.get_host_and_id(url)[0]
20        media_id = self.get_host_and_id(url)[1]
21
22        return self.get_media_url(host, media_id)
23
24    def get_host_and_id(self, url):
25        r = re.search(self.pattern, url, re.I)
26        if r:
27            return r.groups()
28        else:
29            return False
30
31    def get_media_url(self, host, media_id):
32        web_url = self.get_url(host, media_id)
33
34        # get landing page
35        resp = self.net.http_GET(web_url, headers={'Referer': web_url})
36        html = resp.content
37
38        r = re.search(r'Core\.InitializeStream \(\'(.*?)\'\)', html)
39        if not r: print 'page structure changed'
40
41        b = base64.b64decode(r.group(1))
42        j = json.loads(b)
43
44        if len(j) == 0: print 'video not found'
45
46        print j[0]
47
48    def get_url(self, host, media_id):
49        return 'http://%s/%s' % (host, media_id)
50
51sys.stdout = VivoResolver()
Note: See TracBrowser for help on using the repository browser.