Beispiel #1
0
    def download(self, path, url):

        try:
            result = client.request(url)
            # f = os.path.splitext(urlparse(url).path)[1][1:]
            f = os.path.join(path, url.rpartition('/')[2])

            with open(f, 'wb') as subFile:
                subFile.write(result)

            dirs, files = control.listDir(path)

            if len(files) == 0:
                return

            if not f.lower().endswith('.rar'):
                control.execute('Extract("%s","%s")' % (f, path))

            if control.infoLabel('System.Platform.Windows'):
                conversion = quote
            else:
                conversion = quote_plus

            if f.lower().endswith('.rar'):

                uri = "rar://{0}/".format(conversion(f))
                dirs, files = control.listDir(uri)

            else:

                for i in range(0, 10):

                    try:
                        dirs, files = control.listDir(path)
                        if len(files) > 1:
                            break
                        if control.aborted is True:
                            break
                        control.wait(1)
                    except BaseException:
                        pass

            filename = [
                i for i in files if any(
                    i.endswith(x) for x in ['.srt', '.sub'])
            ][0].decode('utf-8')
            subtitle = os.path.join(path, filename)

            if f.lower().endswith('.rar'):

                content = control.openFile(uri + filename).read()

                with open(subtitle, 'wb') as subFile:
                    subFile.write(content)

                control.deleteFile(f)

                return subtitle

            else:

                control.deleteFile(f)

                return subtitle

        except BaseException:

            pass
    def download(self, path, url):

        try:
            frame, url, cjcfduid, cjphp, sub_, imdb_ = url.split('|')
            # xbmc.log('$#$ FRAME: %s | URL: %s | COOKIE: %s | SUB: %s | imdb: %s | ' % (frame, url, cjcfduid, sub_, imdb_))

            sub_ = urllib.unquote_plus(sub_)

            self.s.cookies.update({'__cfduid': cjcfduid, 'PHPSESSID': cjphp})
            # xbmc.log('$#$ FRAME-COOKIES: %s' % self.s.cookies)

            self.s.headers['Referer'] = frame
            init = self.s.get(url).text
            try:
                imdb = client.parseDOM(init,
                                       'input',
                                       ret='value',
                                       attrs={'name': 'uid'})[0]
            except IndexError:
                imdb = imdb_
            try:
                sub_name = client.parseDOM(init,
                                           'input',
                                           ret='value',
                                           attrs={'name': 'output'})[0]
            except IndexError:
                sub_name = '{}.srt'.format(sub_)

            self.s.headers.update({
                'Referer': url,
                'Origin': 'https://subztv.online'
            })

            # xbmc.log('$#$ FRAME-HEADERS: %s' % self.s.headers, xbmc.LOGNOTICE)
            post = {
                "langcode": "el",
                "uid": imdb,
                "output": sub_name.lower(),
                "dll": "1"
            }
            # post = urllib.urlencode(post)
            # xbmc.log('$#$ FRAME-POST: %s' % post)

            result = self.s.post(url, data=post)
            #xbmc.log('$#$POST-RESUL: %s' % result.content)
            f = os.path.join(path, urllib.quote(sub_) + '.srt')
            with open(f, 'wb') as subFile:
                subFile.write(result.content)

            dirs, files = control.listDir(path)

            if len(files) == 0:
                return

            if not f.lower().endswith('.rar'):
                control.execute('Extract("%s","%s")' % (f, path))

            if control.infoLabel('System.Platform.Windows'):
                conversion = urllib.quote
            else:
                conversion = urllib.quote_plus

            if f.lower().endswith('.rar'):

                uri = "rar://{0}/".format(conversion(f))
                dirs, files = control.listDir(uri)

            else:

                for i in range(0, 10):

                    try:
                        dirs, files = control.listDir(path)
                        if len(files) > 1:
                            break
                        if control.aborted is True:
                            break
                        control.wait(1)
                    except BaseException:
                        pass

            filename = [
                i for i in files if any(
                    i.endswith(x) for x in ['.srt', '.sub'])
            ][0].decode('utf-8')
            subtitle = os.path.join(path, filename)

            if f.lower().endswith('.rar'):

                content = control.openFile(uri + filename).read()

                with open(subtitle, 'wb') as subFile:
                    subFile.write(content)

                return subtitle

            else:

                return subtitle

        except BaseException:
            pass
    def download(self, path, url):

        try:
            url, sub_, php, imdb = url.split('|')

            headers = {
                'User-Agent':
                'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3',
                'Referer': url
            }

            cj = {'PHPSESSID': php, 'share_show_hide_status': 'active'}

            post = {
                'langcode': 'el',
                'uid': imdb,
                'output': '%s.srt' % sub_,
                'dll': '1'
            }

            r = requests.get(url, headers=headers, cookies=cj)
            result = requests.post(url, headers=headers, data=post,
                                   cookies=cj).content

            f = os.path.join(path, urllib.quote(sub_) + '.srt')

            with open(f, 'wb') as subFile:
                subFile.write(result)

            dirs, files = control.listDir(path)

            if len(files) == 0:
                return

            if not f.lower().endswith('.rar'):
                control.execute('Extract("%s","%s")' % (f, path))

            if control.infoLabel('System.Platform.Windows'):
                conversion = urllib.quote
            else:
                conversion = urllib.quote_plus

            if f.lower().endswith('.rar'):

                uri = "rar://{0}/".format(conversion(f))
                dirs, files = control.listDir(uri)

            else:

                for i in range(0, 10):

                    try:
                        dirs, files = control.listDir(path)
                        if len(files) > 1:
                            break
                        if control.aborted is True:
                            break
                        control.wait(1)
                    except BaseException:
                        pass

            filename = [
                i for i in files if any(
                    i.endswith(x) for x in ['.srt', '.sub'])
            ][0].decode('utf-8')
            subtitle = os.path.join(path, filename)

            if f.lower().endswith('.rar'):

                content = control.openFile(uri + filename).read()

                with open(subtitle, 'wb') as subFile:
                    subFile.write(content)

                return subtitle

            else:

                return subtitle

        except BaseException:
            pass
Beispiel #4
0
    def download(self, path, url):

        try:
            url, php= url.split('|')
            if 'subs4series' in url:
                headers = {
                    'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3',
                    'Referer': url,
                    'Origin': 'https://www.subs4series.com/'}
                cj = {'PHPSESSID': php}

                r = requests.get(url, headers=headers, cookies=cj).content
                # r = re.sub(r'[^\x00-\x7F]+', ' ', r)
                if six.PY2:
                    r = re.sub(r'[^\x00-\x7F]+', ' ', r)
                # try:
                #     r = r.decode('utf-8', errors='replace')
                # except AttributeError:
                #     pass
                # xbmc.log('@@HTML:%s' % r)

                pos = re.findall(r'''href=["'](/getSub-.+?)["']''', r, re.I | re.DOTALL)[0]
                # xbmc.log('@@POSSSSS:%s' % pos)
                post_url = urljoin(self.base_TVlink, pos)
                # xbmc.log('@@POStttt:%s' % post_url)
                r = requests.get(post_url, headers=headers, cookies=cj)
                surl = r.url
                result = client.request(surl)


            else:
                headers = {
                    'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3',
                    'Referer': url,
                    'Origin': 'https://www.sf4-industry.com'}
                cj = {'PHPSESSID': php}
                post_url = 'https://www.sf4-industry.com/getSub.php'

                r = requests.get(url, headers=headers, cookies=cj).text
                if six.PY2:
                    r = re.sub(r'[^\x00-\x7F]+', ' ', r)
                # try:
                #     r = r.decode('utf-8', errors='replace')
                # except AttributeError:
                #     pass
                # xbmc.log('@@HTMLLL:%s' % r)
                pos = client.parseDOM(r, 'div', attrs={'class': 'download-btn'})[0]
                pos = client.parseDOM(pos, 'input', ret='value', attrs={'name': 'id'})[0]
                # pos = re.findall(r'getSub-(\w+)\.html', r, re.I | re.DOTALL)[0]
                post = {'id': pos,
                        'x': '107',
                        'y': '35'}

                r = requests.post(post_url, headers=headers, data=post, cookies=cj)
                # surl = r.headers['Location']
                surl = r.url
                result = client.request(surl)
                # surl = self.base_link + surl if surl.startswith('/') else surl

            # path = 'special://userdata/addon_data/service.subtitles.greeksubs/temp/'
            f = os.path.join(path, surl.rpartition('/')[2])
            # if f.lower().endswith('.rar') and not control.condVisibility('system.platform.osx'):
            #     return control.okDialog('GreekSubs', 'Το αρχείο υποτίτλου είναι σε μορφή rar\n και δεν μπορεί να ληφθεί.\n'
            #                             'Δοκιμάστε άλλον υπότιτλο!')

            with open(f, 'wb') as subFile:
                subFile.write(result)

            dirs, files = control.listDir(path)

            if len(files) == 0:
                return

            if not f.lower().endswith('.rar'):
                control.execute('Extract("{}","{}")'.format(f, path))

            if control.condVisibility('system.platform.windows'):
                conversion = quote
            else:
                conversion = quote_plus

            if f.lower().endswith('.rar'):
                    import xbmcvfs
                # if control.condVisibility('system.platform.osx'):
                #     uri = "rar://{}/".format(conversion(f))
                    uri = 'rar://%(archive_file)s' % {'archive_file': conversion(control.transPath(f))}
                    dirs, files = control.listDir(uri)
                # else:
                #     return

            else:

                for i in range(0, 10):

                    try:
                        dirs, files = control.listDir(path)
                        if len(files) > 1:
                            break
                        if control.aborted is True:
                            break
                        control.wait(1)
                    except BaseException:
                        pass

            filenames = [i for i in files if any(i.endswith(x) for x in ['.srt', '.sub'])]

            if len(filenames) == 1:
                filename = filenames[0]
            else:
                filename = multichoice(filenames)

            try:
                filename = filename.decode('utf-8')
            except BaseException:
                pass

            subtitle = os.path.join(path, filename)

            if f.lower().endswith('.rar'):

                content = control.openFile(path + filename).read()

                with open(subtitle, 'w') as subFile:
                    subFile.write(content)

                control.deleteFile(f)
                return subtitle

            else:

                return subtitle

        except BaseException:
            pass
Beispiel #5
0
    def download(self, path, url):

        try:
            url, php, cfd = url.split('|')
            if 'subs4series' in url:
                headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3',
                           'Referer': url,
                           'Origin': 'https://www.subs4series.com/'}
                cj = {'PHPSESSID': php,
                      '__cfduid': cfd}

                r = requests.get(url, headers=headers, cookies=cj).content
                r = re.sub(r'[^\x00-\x7F]+', ' ', r)

                pos = re.findall('\/(getSub-\w+\.html)', r, re.I|re.DOTALL)[0]
                post_url = urlparse.urljoin(self.base_TVlink, pos)
                r = requests.get(post_url, headers=headers, cookies=cj)
                result = r.content
                surl = r.url

            else:
                headers = {'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3',
                           'Referer': url,
                           'Origin': 'https://www.sf4-industry.com'}
                cj = {'PHPSESSID': php,
                      '__cfduid': cfd}
                post_url = 'https://www.sf4-industry.com/getSub.html'

                r = requests.get(url, headers=headers, cookies=cj).content
                r = re.sub(r'[^\x00-\x7F]+', ' ', r)
                #pos = client.parseDOM(r, 'tr', attrs={'class':'stylepps'})[0]
                pos = re.findall('getSub-(\w+)\.html', r, re.I | re.DOTALL)[0]
                post = {'id': pos,
                        'x': '107',
                        'y': '35'}

                r = requests.post(post_url, headers=headers, data=post, cookies=cj)
                result = r.content
                surl = r.url

            f = os.path.join(path, surl.rpartition('/')[2])

            with open(f, 'wb') as subFile:
                subFile.write(result)

            dirs, files = control.listDir(path)

            if len(files) == 0:
                return

            if not f.lower().endswith('.rar'):
                control.execute('Extract("%s","%s")' % (f, path))

            if control.infoLabel('System.Platform.Windows'):
                conversion = urllib.quote
            else:
                conversion = urllib.quote_plus

            if f.lower().endswith('.rar'):

                uri = "rar://{0}/".format(conversion(f))
                dirs, files = control.listDir(uri)

            else:

                for i in range(0, 10):

                    try:
                        dirs, files = control.listDir(path)
                        if len(files) > 1:
                            break
                        if control.aborted is True:
                            break
                        control.wait(1)
                    except BaseException:
                        pass

            filename = [i for i in files if any(i.endswith(x) for x in ['.srt', '.sub'])][0].decode('utf-8')
            subtitle = os.path.join(path, filename)

            if f.lower().endswith('.rar'):

                content = control.openFile(uri + filename).read()

                with open(subtitle, 'wb') as subFile:
                    subFile.write(content)

                return subtitle

            else:

                return subtitle

        except BaseException:
            pass