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

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

fix vidzi

File size: 2.5 KB
Line 
1
2import random
3import re
4import urllib
5import sys
6from lib.net import Net
7from lib import helpers
8import lib.common as common
9
10class MovshareResolver(object):
11    name = "movshare"
12    domains = ["movshare.net", 'wholecloud.net', 'vidgg.to']
13    pattern = '(?://|\.)(movshare.net|wholecloud.net|vidgg.to)/(?:video/|embed(?:/|\.php)\?(?:v|id)=)([A-Za-z0-9]+)'
14
15    def __init__(self):
16        self.net = Net()
17        url = str(sys.argv[1])
18        host = self.get_host_and_id(url)[0]
19        media_id = self.get_host_and_id(url)[1]
20
21        return self.get_media_url(host, media_id)
22
23    def get_host_and_id(self, url):
24        r = re.search(self.pattern, url, re.I)
25        if r:
26            return r.groups()
27        else:
28            return False
29
30    def get_media_url(self, host, media_id):
31        web_url = self.get_url(host, media_id)
32        headers = {'User-Agent': common.FF_USER_AGENT}
33        html = self.net.http_GET(web_url, headers=headers).content
34        stream_url = ''
35        match = re.search('<video.*?</video>', html, re.DOTALL)
36        if match:
37            links = re.findall('<source[^>]+src="([^"]+)', match.group(0), re.DOTALL)
38            if links:
39                stream_url = random.choice(links)
40       
41        if not stream_url:
42            match = re.search('fkzd="([^"]+)', html)
43            if match:
44                query = {'pass': 'undefined', 'key': match.group(1), 'cid3': 'undefined', 'cid': 0, 'numOfErrors': 0, 'file': media_id, 'cid2': 'undefined', 'user': 'undefined'}
45                api_url = 'http://www.wholecloud.net//api/player.api.php?' + urllib.urlencode(query)
46                html = self.net.http_GET(api_url, headers=headers).content
47                match = re.search('url=([^&]+)', html)
48                if match:
49                    stream_url = match.group(1)
50
51        if stream_url:
52            headers.update({'Referer': web_url, })
53            print stream_url + helpers.append_headers(headers)
54#        else:
55#            raise ResolverError('File Not Found or removed')
56
57    def get_url(self, host, media_id):
58        if 'vidgg' in host:
59            return 'http://%s/embed/?id=%s' % (host, media_id)
60#            template = 'http://{host}/embed/?id={media_id}'
61        else:
62            return 'http://%s/embed/?v=%s' % (host, media_id)
63#           template = 'http://{host}/embed/?v={media_id}'
64        print self._default_get_url(host, media_id, template)
65
66sys.stdout = MovshareResolver()
Note: See TracBrowser for help on using the repository browser.