source: titan/mediathek/localhoster/voesx.py

Last change on this file was 45653, checked in by obi, 6 months ago

tithek fix voe hoster

File size: 2.3 KB
Line 
1"""
2    Plugin for URLResolver
3    Copyright (C) 2020  gujal
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
20import base64
21#from urlresolver import common
22#from urlresolver.plugins.lib import helpers
23#from urlresolver.resolver import UrlResolver
24
25import sys
26import time
27from lib.net import Net
28import re, urllib, json
29from lib import helpers
30import lib.common as common
31
32class VoeResolver(object):
33    name = "voe"
34    domains = ["voe.sx"]
35    pattern = r'(?://|\.)(voe\.sx)/(?:e/)?([0-9A-Za-z]+)'
36
37    def __init__(self):
38        self.net = Net()
39        url = str(sys.argv[1])
40        host = self.get_host_and_id(url)[0]
41        media_id = self.get_host_and_id(url)[1]
42
43        return self.get_media_url(host, media_id)
44
45    def get_host_and_id(self, url):
46        r = re.search(self.pattern, url, re.I)
47        if r:
48            return r.groups()
49        else:
50            return False
51
52    def get_media_url(self, host, media_id):
53        web_url = self.get_url(host, media_id)
54        headers = {'User-Agent': common.RAND_UA,
55                   'Referer': 'https://{0}/'.format(host)}
56        html = self.net.http_GET(web_url, headers=headers).content
57        r = re.search(r'uttf0\((\[[^)]+)', html)
58        if r:
59            r = eval(r.group(1))
60            r = base64.b64decode(''.join(r)[::-1].encode('utf8')).decode('utf8')
61            print r + helpers.append_headers(headers)
62
63        print helpers.get_media_url(web_url,
64                                     patterns=[r'''hls":\s*"(?P<url>[^"]+)",\s*"video_height":\s*(?P<label>[^,]+)'''],
65                                     generic_patterns=False)
66
67    def get_url(self, host, media_id):
68        return 'https://%s/e/%s' % (host, media_id)
69               
70sys.stdout = VoeResolver()
Note: See TracBrowser for help on using the repository browser.