source: titan/mediathek/localhoster/lib/openload.py @ 39001

Last change on this file since 39001 was 39001, checked in by obi, 6 years ago

localhoster add sh4 python stuff

File size: 2.2 KB
Line 
1
2import os
3import hashlib
4import sys
5from lib.net import Net
6import ol_gmu
7
8OL_SOURCE = 'https://offshoregit.com/tvaresolvers/ol_gmu.py'
9OL_PATH = ''#os.path.join(common.plugins_path, 'ol_gmu.py')
10
11class OpenLoadResolver(object):
12    name = "openload"
13    domains = ["openload.io", "openload.co"]
14    pattern = '(?://|\.)(openload\.(?:io|co))/(?:embed|f)/([0-9a-zA-Z-_]+)'
15
16    def __init__(self):
17        self.net = Net()
18        url = str(sys.argv[1])
19        host = self.get_host_and_id(url)[0]
20        media_id = self.get_host_and_id(url)[1]
21
22        return self.get_media_url(host, media_id)
23
24    @common.cache.cache_method(cache_limit=8)
25    def get_ol_code(self):
26        try:
27            new_py = self.net.http_GET(OL_SOURCE).content
28#            common.log_utils.log('new_py: %s' % (new_pya))
29
30            if new_py:
31                with open(OL_PATH, 'w') as f:
32                    f.write(new_py)
33        except Exception as e:
34            common.log_utils.log_warning('Exception during openload code retrieve: %s' % e)
35           
36    def get_media_url(self, host, media_id):
37#        common.log_utils.log('host: %s' % (host))
38#        common.log_utils.log('media_id: %s' % (media_id))
39#        common.log_utils.log('OL_PATH: %s' % (OL_PATH))
40        try:
41#            if self.get_setting('auto_update') == 'true':
42#                self.get_ol_code()
43#            with open(OL_PATH, 'r') as f:
44#                py_data = f.read()
45#            common.log_utils.log('py_data: %s' % (py_data))
46#            common.log_utils.log('ol_gmu hash: %s' % (hashlib.md5(py_data).hexdigest()))
47#            import ol_gmu
48            web_url = self.get_url(host, media_id)
49#            common.log_utils.log('web_url: %s' % (web_url))
50            return ol_gmu.get_media_url(web_url)
51        except Exception as e:
52#            common.log_utils.log_debug('Exception during openload resolve parse: %s' % e)
53            raise
54
55    def get_url(self, host, media_id):
56        return 'http://openload.io/embed/%s' % media_id
57
58    def get_settings_xml(cls):
59        xml = super(cls, cls).get_settings_xml()
60        xml.append('<setting id="%s_auto_update" type="bool" label="Automatically update resolver" default="true"/>' % (cls.__name__))
61        return xml
Note: See TracBrowser for help on using the repository browser.