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, 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
def run(self, query=None): if not 'Greek' in str(langs).split(','): control.directory(syshandle) control.infoDialog(control.lang(32002).encode('utf-8')) return if control.kodi_version() >= 18.0 and not\ control.conditional_visibility('System.HasAddon(vfs.libarchive)')\ and not (control.condVisibility('System.Platform.Linux')): control.execute('InstallAddon(vfs.libarchive)') if not control.conditional_visibility( 'System.HasAddon(script.module.futures)') and six.PY2: if 17.0 <= control.kodi_version() <= 18.9: control.execute('InstallAddon(script.module.futures)') control.sleep(1500) if query: query = '{}/imdb=0'.format(re.sub(r'[\(|\)]', '', query)) # xbmc.log('$#$QUERY-ELSE: %s' % query, xbmc.LOGINFO) else: if control.condVisibility('Player.HasVideo'): title = control.infoLabel('VideoPlayer.Title') if re.search(r'[^\x00-\x7F]+', title) is not None: title = control.infoLabel('VideoPlayer.OriginalTitle') year = control.infoLabel('VideoPlayer.Year') tvshowtitle = control.infoLabel('VideoPlayer.TVshowtitle') season = control.infoLabel('VideoPlayer.Season') episode = control.infoLabel('VideoPlayer.Episode') try: imdb = control.infoLabel('VideoPlayer.IMDBNumber') if not imdb: imdb = '0' except BaseException: imdb = '0' else: title = xbmc.getInfoLabel("ListItem.OriginalTitle") year = xbmc.getInfoLabel("ListItem.Year") tvshowtitle = xbmc.getInfoLabel("ListItem.TVShowTitle") season = xbmc.getInfoLabel("ListItem.Season") episode = xbmc.getInfoLabel("ListItem.Episode") #labelType = xbmc.getInfoLabel("ListItem.DBTYPE") try: imdb = control.infoLabel('ListItem.IMDBNumber') # xbmc.log('$#$QUERY-NONE-IMDB: %s' % imdb, xbmc.LOGNOTICE) if not imdb: imdb = '0' except BaseException: imdb = '0' if 's' in episode.lower(): season, episode = '0', episode[-1:] if not tvshowtitle == '': # episode query = '%s S%02dE%02d/imdb=%s' % (tvshowtitle, int(season), int(episode), str(imdb)) elif not year == '': # movie query = '%s (%s)/imdb=%s' % (title, year, str(imdb)) elif '(S' in title: query = '%s/imdb=%s' % (title, str(imdb)) else: # file query, year = getCleanMovieTitle(title) if not year == '': query = '{} ({})/imdb={}'.format(query, year, str(imdb)) self.query = six.ensure_str(query, encoding='utf-8') with concurrent.futures.ThreadPoolExecutor(5) as executor: query = self.query threads = [ executor.submit(self.subztv, query), executor.submit(self.s4f, query), executor.submit(self.yifi, query) ] for future in concurrent.futures.as_completed(threads): item = future.result() if not item: continue self.list.extend(item) # threads = [] # if control.setting('provider.subztv.club'): # threads.append(workers.Thread(self.subztv)) # xbmc.log('$#$THREAD1: %s' % threads) # if control.setting('provider.s4f'): # threads.append(workers.Thread(self.s4f)) # xbmc.log('$#$THREAD2: %s' % threads) # if control.setting('provider.yifi'): # threads.append(workers.Thread(self.yifi)) # xbmc.log('$#$THREAD3: %s' % threads) # # [i.start() for i in threads] # [i.join() for i in threads] self.list = [i for i in self.list if i] f = [] f += [i for i in self.list if i['source'] == 'subztv'] f += [i for i in self.list if i['source'] == 's4f'] f += [i for i in self.list if i['source'] == 'yifi'] self.list = sorted(f, key=lambda k: k['rating'], reverse=True) for i in self.list: try: if i['source'] == 'subztv': i['name'] = u'[SUBZ] {0}'.format(i['name']) elif i['source'] == 's4f': i['name'] = u'[S4F] {0}'.format(i['name']) elif i['source'] == 'yifi': i['name'] = u'[YIFI] {0}'.format(i['name']) except BaseException: pass for i in self.list: try: u = { 'action': 'download', 'url': i['url'], 'source': i['source'] } u = '{0}?{1}'.format(sysaddon, urlencode(u)) item = control.item(label='Greek', label2=i['name']) item.setArt({'icon': str(i['rating'])[:1], 'thumb': 'el'}) item.setProperty('hearing_imp', 'false') control.addItem(handle=syshandle, url=u, listitem=item, isFolder=False) except BaseException: pass control.directory(syshandle)
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
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