source: titan/mediathek/localhoster/vidup_me.py @ 38960

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

[tithek] add first python hoster

File size: 1.8 KB
Line 
1"""
2    urlresolver XBMC Addon
3    Copyright (C) 2011 t0mm0
4
5    This program is free software: you can redistribute it and/or modify
6    it under the terms of the GNU General Public License as published by
7    the Free Software Foundation, either version 3 of the License, or
8    (at your option) any later version.
9
10    This program is distributed in the hope that it will be useful,
11    but WITHOUT ANY WARRANTY; without even the implied warranty of
12    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13    GNU General Public License for more details.
14
15    You should have received a copy of the GNU General Public License
16    along with this program.  If not, see <http://www.gnu.org/licenses/>.
17"""
18
19import re
20from lib import jsunpack
21from urlresolver import common
22from urlresolver.resolver import UrlResolver, ResolverError
23
24
25class VidUpMeResolver(UrlResolver):
26    name = "vidup.me"
27    domains = ["vidup.me", "beta.vidup.me"]
28    pattern = '(?://|\.)(vidup\.me)/(?:embed-)?([0-9a-zA-Z]+)'
29
30    def __init__(self):
31        self.net = common.Net()
32
33    def get_media_url(self, host, media_id):
34        web_url = self.get_url(host, media_id)
35        html = self.net.http_GET(web_url).content
36
37        js_data = re.findall('(eval\(function.*?)</script>', html.replace('\n', ''))
38
39        for i in js_data:
40            try: html += jsunpack.unpack(i)
41            except: pass
42
43        match = re.findall('''["']?sources['"]?\s*:\s*\[(.*?)\]''', html)
44
45        if match:
46            stream_url = re.findall('''['"]?file['"]?\s*:\s*['"]?([^'"]+)''', match[0])
47            if stream_url:
48                return stream_url[-1]
49
50        raise ResolverError('File Not Found or removed')
51
52    def get_url(self, host, media_id):
53        return 'http://beta.vidup.me/embed-%s.html' % media_id
Note: See TracBrowser for help on using the repository browser.