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

Last change on this file since 39352 was 39352, checked in by obi, 5 years ago

fix flashx.py

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