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

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

update py hoster

File size: 1.9 KB
Line 
1
2import re
3import urllib
4import sys
5from lib.net import Net
6
7class MovshareResolver(object):
8    name = "movshare"
9    domains = ["movshare.net", 'wholecloud.net', 'vidgg.to']
10    pattern = '(?://|\.)(movshare.net|wholecloud.net|vidgg.to)/(?:video/|embed(?:/|\.php)\?(?:v|id)=)([A-Za-z0-9]+)'
11
12    def __init__(self):
13        self.net = Net()
14        url = str(sys.argv[1])
15        host = self.get_host_and_id(url)[0]
16        media_id = self.get_host_and_id(url)[1]
17
18        return self.get_media_url(host, media_id)
19
20    def get_host_and_id(self, url):
21        r = re.search(self.pattern, url, re.I)
22        if r:
23            return r.groups()
24        else:
25            return False
26
27    def get_media_url(self, host, media_id):
28        web_url = self.get_url(host, media_id)
29        html = self.net.http_GET(web_url).content
30        try:
31            stream_url = ''
32            r = re.search('flashvars.filekey=(.+?);', html)
33            if r:
34                r = r.group(1)
35                try: filekey = re.search('var\s+%s\s*=\s*"([^"]+)' % (r), html).group(1)
36                except: filekey = r
37                player_url = 'http://%s/api/player.api.php?key=%s&file=%s' % (host, urllib.quote(filekey), media_id)
38                html = self.net.http_GET(player_url).content
39                r = re.search('url=(.+?)&', html)
40                if r:
41                    stream_url = r.group(1)
42           
43        try:
44            r = re.search('id="player"[^>]+src="([^"]+)', html, re.DOTALL)
45            if r:
46                stream_url = r.group(1)
47
48        if stream_url:
49            print '%s|Referer=%s' % (stream_url, web_url)
50
51    def get_url(self, host, media_id):
52        if 'vidgg' in host:
53            return 'http://%s/embed/?id=%s' % (host, media_id)
54        else:
55            return 'http://%s/embed/?v=%s' % (host, media_id)
56
57sys.stdout = MovshareResolver()
Note: See TracBrowser for help on using the repository browser.