Rev | Line | |
---|
[39356] | 1 | |
---|
| 2 | import re |
---|
| 3 | import urllib |
---|
| 4 | from lib import jsunpack |
---|
| 5 | import sys |
---|
| 6 | from lib.net import Net |
---|
[39357] | 7 | import base64 |
---|
| 8 | import json |
---|
[39358] | 9 | from lib import helpers |
---|
[39356] | 10 | |
---|
| 11 | class VivoResolver(object): |
---|
[39359] | 12 | name = "vivosx" |
---|
| 13 | domains = ["vivo.sx"] |
---|
| 14 | pattern = '(?://|\.)(vivo\.sx)/([0-9a-zA-Z]+)' |
---|
[39356] | 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 | |
---|
| 51 | sys.stdout = VivoResolver() |
---|
Note: See
TracBrowser
for help on using the repository browser.