source: titan/mediathek/localhoster/nowvideo.py @ 39592

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

fix

File size: 2.1 KB
Line 
1
2import sys
3import re
4from lib.net import Net
5import lib.common as common
6from lib import helpers
7
8class NowvideoResolver(object):
9    name = "nowvideo"
10    domains = ['nowvideo.eu', 'nowvideo.ch', 'nowvideo.sx', 'nowvideo.co', 'nowvideo.li', 'nowvideo.fo', 'nowvideo.at', 'nowvideo.ec']
11    pattern = '(?://|\.)(nowvideo\.(?:eu|ch|sx|co|li|fo|at|ec))/(?:video/|embed\.php\?\S*v=|embed/\?v=)([A-Za-z0-9]+)'
12
13    def __init__(self):
14        self.net = Net()
15        url = str(sys.argv[1])
16        host = self.get_host_and_id(url)[0]
17        media_id = self.get_host_and_id(url)[1]
18
19        return self.get_media_url(host, media_id)
20
21    def get_host_and_id(self, url):
22        r = re.search(self.pattern, url, re.I)
23        if r:
24            return r.groups()
25        else:
26            return False
27
28    def get_media_url(self, host, media_id):
29        web_url = self.get_url(host, media_id)
30        stream_url = ''
31        html = self.net.http_GET(web_url).content
32        try:
33            r = re.search('flashvars.filekey=(.+?);', html)
34            if r:
35                r = r.group(1)
36
37                try: filekey = re.compile('\s+%s="(.+?)"' % r).findall(html)[-1]
38                except: filekey = r
39
40                player_url = 'http://www.nowvideo.sx/api/player.api.php?key=%s&file=%s' % (filekey, media_id)
41
42                html = self.net.http_GET(player_url).content
43
44                r = re.search('url=(.+?)&', html)
45
46                if r:
47                    stream_url = r.group(1)
48        except:
49            print "no embedded urls found using first method"
50           
51        try:
52            r = re.search('id="player".*?src="(.*?)"', html, re.DOTALL)
53            if r:
54                stream_url = r.group(1)
55           
56        except:
57            print "no embedded urls found using second method"
58
59        if stream_url:
60            print stream_url + helpers.append_headers({'Referer': web_url})
61
62    def get_url(self, host, media_id):
63        return 'http://embed.nowvideo.sx/embed/?v=%s' % media_id
64
65sys.stdout = NowvideoResolver()
Note: See TracBrowser for help on using the repository browser.