def main(argv=None): try: if kodi.get_setting('email_prompt') != 'true' and not kodi.get_setting( 'email'): kodi.set_setting('email_prompt', 'true') kodi.show_settings() if __confirm_upload(): upload_logs() except Exception as e: log_utils.log('Uploader Error: %s' % (e), log_utils.LOGWARNING) kodi.notify(msg=str(e)) raise
def __init__(self): self.disable_check = kodi.get_setting('dev_resolver') if self.disable_check == 'true': return self.resolverFile = xbmc.translatePath( os.path.join('special://home/addons/script.module.adultresolver', 'lib/adultresolver/resolver.py')) self.check_resolver()
def generic(self, url, pattern=None): try: r = client.request(url) if 'chaturbate' in url: if '.m3u8' not in r: return 'offline' if pattern: s = re.findall(r'%s' % pattern, r) else: patterns = [ r'''\s*=\s*[\'\"](http.+?)[\'\"]''', \ r'''\s*=\s*['"](http.+?)['"]''', \ r'''['"][0-9_'"]+:\s[\'\"]([^'"]+)''', \ r'''\(\w+\([\'\"]([^\'\"]*)''', \ r'''[\'\"]\w+[\'\"]:['"]([^'"]*)''', \ r'''\s*=\s*[\'\"](http.+?)[\'\"]''', \ r'''\s*:\s*[\'\"](//.+?)[\'\"]''', \ r'''\:[\'\"](\.+?)[\'\"]''', \ r'''\s*\(\s*[\'\"](http.+?)[\'\"]''', \ r'''\s*=\s*[\'\"](//.+?)[\'\"]''', \ r'''\w*:\s*[\'\"](http.+?)[\'\"]''', \ r'''\w*=[\'\"]([^\'\"]*)''', \ r'''\w*\s*=\s*[\'\"]([^\'\"]*)''', \ r'''(?s)<file>([^<]*)''', \ ] s = [] for pattern in patterns: l = re.findall(pattern, r) s += [ i for i in l if (urlparse.urlparse(i).path).strip('/').split('/') [-1].split('.')[-1] in ['mp4', 'flv', 'm3u8'] ] if s: s = [ i for i in s if (urlparse.urlparse(i).path).strip('/').split('/') [-1].split('.')[-1] in ['mp4', 'flv', 'm3u8'] ] else: s = client.parseDOM(r, 'source', ret='src', attrs={'type': 'video.+?'}) if not s: log_utils.log( 'Error resolving %s :: Error: %s' % (url, str(e)), log_utils.LOGERROR) return s = ['http:' + i if i.startswith('//') else i for i in s] s = [ urlparse.urljoin(url, i) if not i.startswith('http') else i for i in s ] s = [x for y, x in enumerate(s) if x not in s[:y]] self.u = [] def request(i): try: i = i.replace(' ', '%20') c = client.request(i, output='headers', referer=url) checks = ['video', 'mpegurl', 'html'] if any(f for f in checks if f in c['Content-Type']): self.u.append((i, int(c['Content-Length']))) except: pass threads = [] for i in s: threads.append(workers.Thread(request, i)) [i.start() for i in threads] [i.join() for i in threads] u = sorted(self.u, key=lambda x: x[1])[::-1] mobile_mode = kodi.get_setting('mobile_mode') if mobile_mode == 'true': u = client.request(u[-1][0], output='geturl', referer=url) else: u = client.request(u[0][0], output='geturl', referer=url) log_utils.log('Returning %s from XXX-O-DUS Resolver' % str(u), log_utils.LOGNOTICE) return u except Exception as e: log_utils.log('Error resolving %s :: Error: %s' % (url, str(e)), log_utils.LOGERROR)
def get_service_ip(): return "127.0.0.1" if service_enabled() else get_setting("service_ip")
def upload_logs(): logs = __get_logs() results = {} last_error = '' uploaders = uploader.Uploader.__class__.__subclasses__(uploader.Uploader) uploaders = [ klass for klass in uploaders if SERVER_ORDER.get(klass.name, 100) and kodi.get_setting('enable_%s' % (klass.name)) == 'true' ] uploaders.sort(key=lambda x: SERVER_ORDER.get(x.name, 100)) if not uploaders: last_error = 'No Uploaders Enabled' for log in logs: full_path, name = log if '.old.' not in name or kodi.get_setting('include_old') == 'true': with open(full_path, 'r') as f: log = f.read() for pattern, replace in REPLACES: log = re.sub(pattern, replace, log) for klass in uploaders: try: log_service = klass() result = log_service.upload_log(log, name) results[log_service.name] = results.get( log_service.name, { 'service': log_service, 'results': {} }) results[log_service.name]['results'][name] = result break except UploaderError as e: log_utils.log( 'Uploader Error: (%s) %s: %s' % (log_service.__class__.__name__, name, e), log_utils.LOGWARNING) last_error = str(e) else: log_utils.log( 'No successful upload for: %s Last Error: %s' % (name, last_error), log_utils.LOGWARNING) if results: email = None if email: for service in results: try: success = results[service]['service'].send_email( email, results[service]['results']) results[service]['email'] = success except UploaderError as e: log_utils.log('Email Error: (%s): %s' % (service, e), log_utils.LOGWARNING) results[service]['email'] = False args = [i18n('logs_uploaded')] for _, name in FILES: for service in results: if name in results[service]['results']: line = '%s: %s' % (name, results[service]['results'][name]) args.append(line) log_utils.log( '[COLOR white]Log Uploaded: %s: %s[/COLOR]' % (name, results[service]['results'][name]), log_utils.LOGNOTICE) xbmcgui.Dialog().ok(*args) else: kodi.notify(i18n('logs_failed') % (last_error), duration=5000)