Пример #1
0
 def _auto_update(self, py_source, py_path, key=''):
     try:
         if self.get_setting('auto_update') == 'true' and py_source:
             headers = self.net.http_HEAD(py_source).get_headers(as_dict=True)
             common.logger.log(headers)
             old_etag = self.get_setting('etag')
             new_etag = headers.get('Etag', '')
             old_len = common.file_length(py_path, key)
             new_len = int(headers.get('Content-Length', 0))
             py_name = os.path.basename(py_path)
             
             if old_etag != new_etag or old_len != new_len:
                 common.logger.log('Updating %s: |%s|%s|%s|%s|' % (py_name, old_etag, new_etag, old_len, new_len))
                 self.set_setting('etag', new_etag)
                 new_py = self.net.http_GET(py_source).content
                 if new_py:
                     if key:
                         new_py = common.decrypt_py(new_py, key)
                         
                     if new_py and 'import' in new_py:
                         with open(py_path, 'w') as f:
                             f.write(new_py.encode('utf-8'))
                         common.kodi.notify('%s %s' % (self.name, common.i18n('resolver_updated')))
             else:
                 common.logger.log('Reusing existing %s: |%s|%s|%s|%s|' % (py_name, old_etag, new_etag, old_len, new_len))
             common.log_file_hash(py_path)
     except Exception as e:
         common.logger.log_warning('Exception during %s Auto-Update code retrieve: %s' % (self.name, e))
Пример #2
0
 def get_media_url(self, host, media_id):
     try:
         self._auto_update(FX_SOURCE, FX_PATH)
         common.log_file_hash(FX_PATH)
         import fx_gmu
         web_url = self.get_url(host, media_id)
         return fx_gmu.get_media_url(web_url)
     except Exception as e:
         common.log_utils.log_debug(
             'Exception during flashx resolve parse: %s' % e)
         raise
Пример #3
0
    def get_media_url(self, host, media_id):
        try:
            self._auto_update(self.get_setting('url'), OL_PATH,
                              self.get_setting('key'))
            common.log_file_hash(OL_PATH)
            import ol_gmu
            return ol_gmu.get_media_url(self.get_url(host, media_id))
        except Exception as e:
            common.log_utils.log_debug(
                'Exception during openload resolve parse: %s' % (e))
            try:
                video_url = self.__check_auth(media_id)
                if not video_url:
                    video_url = self.__auth_ip(media_id)
            except ResolverError:
                raise

            if video_url:
                return video_url
            else:
                raise ResolverError(i18n('no_ol_auth'))
Пример #4
0
    def _auto_update(self, py_source, py_path, key=''):
        try:
            if self.get_setting('auto_update') == 'true' and py_source:
                headers = self.net.http_HEAD(py_source).get_headers(
                    as_dict=True)
                common.logger.log(headers)
                old_etag = self.get_setting('etag')
                new_etag = headers.get('Etag', '')
                old_len = common.file_length(py_path, key)
                new_len = int(headers.get('Content-Length', 0))
                py_name = os.path.basename(py_path)

                if old_etag != new_etag or old_len != new_len:
                    common.logger.log(
                        'Updating %s: |%s|%s|%s|%s|' %
                        (py_name, old_etag, new_etag, old_len, new_len))
                    self.set_setting('etag', new_etag)
                    new_py = self.net.http_GET(py_source).content
                    if new_py:
                        if key:
                            new_py = common.decrypt_py(new_py, key)

                        if new_py and 'import' in new_py:
                            with open(py_path, 'w') as f:
                                f.write(new_py.encode('utf-8'))
                            common.kodi.notify(
                                '%s %s' %
                                (self.name, common.i18n('resolver_updated')))
                else:
                    common.logger.log(
                        'Reusing existing %s: |%s|%s|%s|%s|' %
                        (py_name, old_etag, new_etag, old_len, new_len))
                common.log_file_hash(py_path)
        except Exception as e:
            common.logger.log_warning(
                'Exception during %s Auto-Update code retrieve: %s' %
                (self.name, e))