Пример #1
0
    def youjizz(self, url):
        try:
            r = client.request(url)
            pattern = r"""filename['"]\:['"]([^'"]+)"""
            i = re.findall(pattern, r)
            log_utils.log('%s' % str(i), log_utils.LOGERROR)
            s = [
                e.replace('\\', '') for e in i
                if ('.mp4' in e) and ('.m3u8' not in e)
            ]
            self.u = []

            def request(i):
                try:
                    c = client.request(i, output='headers')
                    checks = ['video', 'mpegurl']
                    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]
            u = client.request(u[0][0], output='geturl', referer=url)
            log_utils.log('Returning %s from YouJizz' % str(u),
                          log_utils.LOGNOTICE)
            return u
        except:
            return
Пример #2
0
def log_file_hash(path):
    try:
        with open(path, 'r') as f:
            py_data = f.read()
    except:
        py_data = ''

    log_utils.log('%s hash: %s' %
                  (os.path.basename(path), hashlib.md5(py_data).hexdigest()))
Пример #3
0
def source_action(mode, li_path):
    try:
        lines = xbmcvfs.File(li_path).read()
        lines = lines.replace('mode=%s' % (MODES.GET_SOURCES), 'mode=%s' % (mode))
        if mode == MODES.SELECT_SOURCE:
            builtin = 'PlayMedia'
        else:
            builtin = 'RunPlugin'
        runstring = '%s(%s)' % (builtin, lines)
        xbmc.executebuiltin(runstring)
    except Exception as e:
        log_utils.log('Failed to read item %s: %s' % (li_path, str(e)), xbmc.LOGERROR)
Пример #4
0
 def youporn(self, url):
     try:
         r = client.request(url)
         pattern = r"""quality[\'\"]\:[\'\"](\d+)[\'\"]\,[\'\"]videoUrl[\'\"]\:[\'\"]([^\'\"]+)"""
         i = re.findall(pattern, r)
         r = [(e[0], e[1].replace('\/', '/')) for e in i]
         log_utils.log('%s' % str(r), log_utils.LOGERROR)
         u = sorted(r,
                    key=lambda x: int(re.search('(\d+)', x[0]).group(1)),
                    reverse=True)
         return u
     except:
         return
Пример #5
0
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
Пример #6
0
def source_action(mode, li_path):
    try:
        lines = xbmcvfs.File(li_path).read()
        lines = lines.replace('mode=%s' % (MODES.GET_SOURCES),
                              'mode=%s' % (mode))
        if mode == MODES.SELECT_SOURCE:
            builtin = 'PlayMedia'
        else:
            builtin = 'RunPlugin'
        runstring = '%s(%s)' % (builtin, lines)
        xbmc.executebuiltin(runstring)
    except Exception as e:
        log_utils.log('Failed to read item %s: %s' % (li_path, str(e)),
                      xbmc.LOGERROR)
Пример #7
0
def main(argv=None):
    if sys.argv: argv = sys.argv
    log_utils.log('Version: |%s|' % (kodi.get_version()))
    log_utils.log('Args: |%s|' % (argv))
    path = xbmc.getInfoLabel('ListItem.FileNameAndPath')
    if not path:
        path = xbmc.getInfoLabel('ListItem.Path')
        
    if __is_salts_listitem(path):
        dialog = xbmcgui.Dialog()
        tools = __get_tools(path)
        ret = dialog.select('SALTS Tools', [i[0] for i in tools])
        if ret > -1:
            tools[ret][1](*tools[ret][2])
    else:
        kodi.notify(msg='Not a SALTS Library Item')
Пример #8
0
def __is_salts_listitem(li_path):
    addon = xbmcaddon.Addon('plugin.video.salts')
    tvshow_folder = xbmc.translatePath(addon.getSetting('tvshow-folder'))
    movie_folder = xbmc.translatePath(addon.getSetting('movie-folder'))
    real_path = xbmc.translatePath(li_path)
    if not real_path.startswith(movie_folder) and not real_path.startswith(tvshow_folder):
        return False
    
    try:
        lines = xbmcvfs.File(li_path).read()
        if lines and not lines.startswith('plugin://plugin.video.salts'):
                return False
    except Exception as e:
        log_utils.log('Failed to read item %s: %s' % (li_path, str(e)), xbmc.LOGERROR)
    
    return True
Пример #9
0
def main(argv=None):
    if sys.argv: argv = sys.argv
    log_utils.log('Version: |%s|' % (kodi.get_version()))
    log_utils.log('Args: |%s|' % (argv))
    path = xbmc.getInfoLabel('ListItem.FileNameAndPath')
    if not path:
        path = xbmc.getInfoLabel('ListItem.Path')

    if __is_salts_listitem(path):
        dialog = xbmcgui.Dialog()
        tools = __get_tools(path)
        ret = dialog.select('SALTS Tools', [i[0] for i in tools])
        if ret > -1:
            tools[ret][1](*tools[ret][2])
    else:
        kodi.notify(msg='Not a SALTS Library Item')
Пример #10
0
def __is_salts_listitem(li_path):
    addon = xbmcaddon.Addon('plugin.video.salts')
    tvshow_folder = xbmc.translatePath(addon.getSetting('tvshow-folder'))
    movie_folder = xbmc.translatePath(addon.getSetting('movie-folder'))
    real_path = xbmc.translatePath(li_path)
    if not real_path.startswith(movie_folder) and not real_path.startswith(
            tvshow_folder):
        return False

    try:
        lines = xbmcvfs.File(li_path).read()
        if lines and not lines.startswith('plugin://plugin.video.salts'):
            return False
    except Exception as e:
        log_utils.log('Failed to read item %s: %s' % (li_path, str(e)),
                      xbmc.LOGERROR)

    return True
Пример #11
0
    def check_resolver(self):

        try:
            r = cache.get(
                client.request, 1,
                base64.b64decode(
                    'aHR0cHM6Ly9yYXcuZ2l0aHVidXNlcmNvbnRlbnQuY29tL3hpYmFsYmExMC9zY3JpcHQubW9kdWxlLmFkdWx0cmVzb2x2ZXIvbWFzdGVyL2xpYi9hZHVsdHJlc29sdmVyL3Jlc29sdmVyLnB5'
                ))
            if len(r) > 1:
                with open(self.resolverFile, 'r') as f:
                    compfile = f.read()
                if 'import' in r:
                    if compfile == r:
                        log_utils.log('Resolver checked and up to date!',
                                      log_utils.LOGNOTICE)
                        pass
                    else:
                        with open(self.resolverFile, 'w') as f:
                            f.write(r)
                        log_utils.log('Resolver updated!', log_utils.LOGNOTICE)
                        kodi.notify(msg='Resolver Updated.',
                                    duration=1250,
                                    sound=True)
        except Exception as e:
            log_utils.log(
                'Error checking for resolver update :: Error: %s' % str(e),
                log_utils.LOGERROR)
Пример #12
0
    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)
Пример #13
0
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)