def captcha_resolve(response, cap_cookie): import os from resources.lib.modules import client from resources.lib.modules import control try: i = os.path.join(control.dataPath, 'img') f = control.openFile(i, 'w') f.write(client.request(response, cookie=cap_cookie)) f.close() f = control.image(450, 5, 375, 115, i) d = control.windowDialog d.addControl(f) control.deleteFile(i) d.show() t = '' k = control.keyboard('', t) k.doModal() c = k.getText() if k.isConfirmed() else None if c == '': c = None d.removeControl(f) d.close() return c except: return
def resolve(self, url): try: content = [ '#EXTM3U', '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="{audio_group}",DEFAULT=YES,AUTOSELECT=YES,NAME="Stream 1",URI="{audio_stream}"', '', '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH={bandwidth},NAME="{stream_name}",AUDIO="{audio_group}"', '{video_stream}' ] url = urlparse.parse_qs(url) url = dict([(key, url[key][0]) if url[key] else (key, '') for key in url]) url = ('\n'.join(content)).format(**url) path = os.path.join(control.dataPath, 'torbase.m3u8') control.makeFile(control.dataPath) control.deleteFile(path) file = control.openFile(path, 'w') file.write(url) file.close() return path except: return
def process(self, url, direct=True): try: if not any(i in url for i in ['.jpg', '.png', '.gif']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext in ['jpg', 'png', 'gif']: raise Exception() try: i = control.joinPath(control.dataPath,'img') control.deleteFile(i) f = control.openFile(i, 'w') f.write(client.request(url)) f.close() control.execute('ShowPicture("%s")' % i) return False except: return except: log_utils.error() try: r, x = re.findall(r'(.+?)\|regex=(.+?)$', url)[0] x = regex.fetch(x) r += unquote_plus(x) if not '</regex>' in r: raise Exception() u = regex.resolve(r) if not u is None: url = u except: pass try: if not url.startswith('rtmp'): raise Exception() if len(re.compile(r'\s*timeout=(\d*)').findall(url)) == 0: url += ' timeout=10' return url except: pass try: if not any(i in url for i in ['.m3u8', '.f4m', '.ts']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext in ['m3u8', 'f4m', 'ts']: raise Exception() return url except: pass try: preset = re.findall(r'<preset>(.+?)</preset>', url)[0] if not 'search' in preset: raise Exception() title, year, imdb = re.findall(r'<title>(.+?)</title>', url)[0], re.findall('<year>(.+?)</year>', url)[0], re.findall(r'<imdb>(.+?)</imdb>', url)[0] try: tvdb, tvshowtitle, premiered, season, episode = re.findall(r'<tvdb>(.+?)</tvdb>', url)[0], re.findall(r'<tvshowtitle>(.+?)</tvshowtitle>', url)[0], re.findall(r'<premiered>(.+?)</premiered>', url)[0], re.findall(r'<season>(.+?)</season>', url)[0], re.findall(r'<episode>(.+?)</episode>', url)[0] except: tvdb = tvshowtitle = premiered = season = episode = None direct = False quality = 'HD' if not preset == 'searchsd' else 'SD' from resources.lib.modules import sources u = sources.Sources().getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, quality) if u: return u
def delete(dbfile=control.cacheFile, withyes=True): if withyes: yes = control.yesnoDialog("Do you want to Clear Cache?".encode('utf-8'), '', '') if not yes: return else: pass control.deleteFile(dbfile) control.infoDialog('DONE!!!')
def insert(meta): try: if not meta: return control.makeFile(control.dataPath) metacacheFile = os.path.join(control.dataPath, 'meta.5.db') dbcon = database.connect(metacacheFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS meta (""imdb TEXT, ""tmdb TEXT, ""tvdb TEXT, ""lang TEXT, ""item TEXT, ""time TEXT, ""UNIQUE(imdb, tmdb, tvdb, lang)"");") t = int(time.time()) r = False for m in meta: try: i = repr(m['item']) try: dbcur.execute("DELETE * FROM meta WHERE (imdb = '%s' and lang = '%s' and not imdb = '0') or (tmdb = '%s' and lang = '%s' and not tmdb = '0') or (tvdb = '%s' and lang = '%s' and not tvdb = '0')" % (m['imdb'], m['lang'], m['tmdb'], m['lang'], m['tvdb'], m['lang'])) except: pass try: dbcur.execute("INSERT INTO meta Values (?, ?, ?, ?, ?, ?)", (m['imdb'], m['tmdb'], m['tvdb'], m['lang'], i, t)) except: r = True ; break except: pass dbcon.commit() dbcon.close() if r == False: return control.deleteFile(metacacheFile) dbcon = database.connect(metacacheFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS meta (""imdb TEXT, ""tmdb TEXT, ""tvdb TEXT, ""lang TEXT, ""item TEXT, ""time TEXT, ""UNIQUE(imdb, tmdb, tvdb, lang)"");") t = int(time.time()) r = False for m in meta: try: i = repr(m['item']) try: dbcur.execute("DELETE * FROM meta WHERE (imdb = '%s' and lang = '%s' and not imdb = '0') or (tmdb = '%s' and lang = '%s' and not tmdb = '0') or (tvdb = '%s' and lang = '%s' and not tvdb = '0')" % (m['imdb'], m['lang'], m['tmdb'], m['lang'], m['tvdb'], m['lang'])) except: pass dbcur.execute("INSERT INTO meta Values (?, ?, ?, ?, ?, ?)", (m['imdb'], m['tmdb'], m['tvdb'], m['lang'], i, t)) except: pass dbcon.commit() dbcon.close() except: return
def keyboard(response): try: i = os.path.join(control.dataPath, 'img') f = control.openFile(i, 'w') f.write(client.request(response)) f.close() f = control.image(450, 5, 375, 115, i) d = control.windowDialog d.addControl(f) control.deleteFile(i) d.show() t = 'Type the letters in the image' k = control.keyboard('', t) k.doModal() c = k.getText() if k.isConfirmed() else None if c == '': c = None d.removeControl(f) d.close() return c except: return
def resolve(self, url): try: content = [ '#EXTM3U', '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="{audio_group}",DEFAULT=YES,AUTOSELECT=YES,NAME="Stream 1",URI="{audio_stream}"', '', '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH={bandwidth},NAME="{stream_name}",AUDIO="{audio_group}"', '{video_stream}'] url = urlparse.parse_qs(url) url = dict([(key, url[key][0]) if url[key] else (key, '') for key in url]) url = ('\n'.join(content)).format(**url) path = os.path.join(control.dataPath, 'torbase.m3u8') control.makeFile(control.dataPath) ; control.deleteFile(path) file = control.openFile(path, 'w') ; file.write(url) ; file.close() return path except: return
def delete_file(): control.deleteFile(control.cacheFile)
def insert(meta): try: if not meta: return control.makeFile(control.dataPath) metacacheFile = os.path.join(control.dataPath, 'meta.5.db') dbcon = database.connect(metacacheFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS meta (" "imdb TEXT, " "tmdb TEXT, " "tvdb TEXT, " "lang TEXT, " "item TEXT, " "time TEXT, " "UNIQUE(imdb, tmdb, tvdb, lang)" ");") t = int(time.time()) r = False for m in meta: try: i = repr(m['item']) try: dbcur.execute( "DELETE * FROM meta WHERE (imdb = '%s' and lang = '%s' and not imdb = '0') or (tmdb = '%s' and lang = '%s' and not tmdb = '0') or (tvdb = '%s' and lang = '%s' and not tvdb = '0')" % (m['imdb'], m['lang'], m['tmdb'], m['lang'], m['tvdb'], m['lang'])) except: pass try: dbcur.execute( "INSERT INTO meta Values (?, ?, ?, ?, ?, ?)", (m['imdb'], m['tmdb'], m['tvdb'], m['lang'], i, t)) except: r = True break except: pass dbcon.commit() dbcon.close() if r == False: return control.deleteFile(metacacheFile) dbcon = database.connect(metacacheFile) dbcur = dbcon.cursor() dbcur.execute("CREATE TABLE IF NOT EXISTS meta (" "imdb TEXT, " "tmdb TEXT, " "tvdb TEXT, " "lang TEXT, " "item TEXT, " "time TEXT, " "UNIQUE(imdb, tmdb, tvdb, lang)" ");") t = int(time.time()) r = False for m in meta: try: i = repr(m['item']) try: dbcur.execute( "DELETE * FROM meta WHERE (imdb = '%s' and lang = '%s' and not imdb = '0') or (tmdb = '%s' and lang = '%s' and not tmdb = '0') or (tvdb = '%s' and lang = '%s' and not tvdb = '0')" % (m['imdb'], m['lang'], m['tmdb'], m['lang'], m['tvdb'], m['lang'])) except: pass dbcur.execute( "INSERT INTO meta Values (?, ?, ?, ?, ?, ?)", (m['imdb'], m['tmdb'], m['tvdb'], m['lang'], i, t)) except: pass dbcon.commit() dbcon.close() except: return
def resolve(self, url): try: m3u8 = [ '#EXTM3U', '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",DEFAULT=YES,AUTOSELECT=YES,NAME="Stream 1",URI="{audio_stream}"', '', '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=0,NAME="{stream_name}",AUDIO="audio"', '{video_stream}' ] query = urlparse.parse_qs(url) query = dict([(key, query[key][0]) if query[key] else (key, '') for key in query]) auth = 'http://streamtorrent.tv/api/torrent/%s/%s.m3u8?json=true' % ( query['vid_id'], query['stream_id']) r = client.request(auth) r = json.loads(r) try: url = r['url'] except: url = None if not url == None: def dialog(url): try: self.disableScraper = control.yesnoDialog( 'To watch this video visit from any device', '[COLOR skyblue]%s[/COLOR]' % url, '', 'Torba', 'Cancel', 'Settings') except: pass workers.Thread(dialog, url).start() control.sleep(3000) for i in range(100): try: if not control.condVisibility( 'Window.IsActive(yesnoDialog)'): break r = client.request(auth) r = json.loads(r) try: url = r['url'] except: url = None if url == None: break workers.Thread(dialog, url).start() control.sleep(3000) except: pass if self.disableScraper: control.openSettings(query='2.0') return '' control.execute('Dialog.Close(yesnoDialog)') if not url == None: return stream_name = '%sp' % (query['height']) video_stream = r[stream_name] if not 'audio' in r: return video_stream audio_stream = r['audio'] content = ('\n'.join(m3u8)).format( **{ 'audio_stream': audio_stream, 'stream_name': stream_name, 'video_stream': video_stream }) path = os.path.join(control.dataPath, 'torbase.m3u8') control.makeFile(control.dataPath) control.deleteFile(path) file = control.openFile(path, 'w') file.write(content) file.close() return path except: return
def process(self, url, direct=True): try: if not any(i in url for i in ['.jpg', '.png', '.gif']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext in ['jpg', 'png', 'gif']: raise Exception() try: i = os.path.join(control.dataPath,'img') control.deleteFile(i) f = control.openFile(i, 'w') f.write(client.request(url)) f.close() control.execute('ShowPicture("%s")' % i) return False except: return except: pass try: r, x = re.findall('(.+?)\|regex=(.+?)$', url)[0] x = regex.fetch(x) r += urllib.unquote_plus(x) if not '</regex>' in r: raise Exception() u = regex.resolve(r) if not u == None: url = u except: pass try: if not url.startswith('rtmp'): raise Exception() if len(re.compile('\s*timeout=(\d*)').findall(url)) == 0: url += ' timeout=10' return url except: pass try: if not any(i in url for i in ['.m3u8', '.f4m', '.ts']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext in ['m3u8', 'f4m', 'ts']: raise Exception() return url except: pass try: preset = re.findall('<preset>(.+?)</preset>', url)[0] if not 'search' in preset: raise Exception() title, year, imdb = re.findall('<title>(.+?)</title>', url)[0], re.findall('<year>(.+?)</year>', url)[0], re.findall('<imdb>(.+?)</imdb>', url)[0] try: tvdb, tvshowtitle, premiered, season, episode = re.findall('<tvdb>(.+?)</tvdb>', url)[0], re.findall('<tvshowtitle>(.+?)</tvshowtitle>', url)[0], re.findall('<premiered>(.+?)</premiered>', url)[0], re.findall('<season>(.+?)</season>', url)[0], re.findall('<episode>(.+?)</episode>', url)[0] except: tvdb = tvshowtitle = premiered = season = episode = None direct = False quality = 'HD' if not preset == 'searchsd' else 'SD' from resources.sources import sources u = sources().getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, quality) if not u == None: return u except: pass try: from resources.sources import sources u = sources().getURISource(url) if not u == False: direct = False if u == None or u == False: raise Exception() return u except: pass try: if not '.google.com' in url: raise Exception() from resources.lib.modules import directstream u = directstream.google(url)[0]['url'] return u except: pass try: if not 'filmon.com/' in url: raise Exception() from resources.lib.modules import filmon u = filmon.resolve(url) return u except: pass try: if not 'uptostream/' in url: raise Exception() from resources.lib.modules import filmon u = url.replace('uptostream','uptobox') return u except: pass try: if not 'liveonlinetv' in url: raise Exception() u = liveonlinetv247(url) return (str(u)).replace('["' , '').replace(']"' , '').replace('[[' , '').replace(']]' , '').replace('[' , '').replace(']' , '').replace('"' , '').replace("'" , "") + '|User-Agent=Mozilla/5.0 (Windows NT 6.3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.143 Safari/537.36' except: pass try: if not 'tvplayer' in url: raise Exception() u = playtvplayer(url) return u except: pass try: if not 'tvcatchup' in url: raise Exception() open = getUrl(url) u = re.compile("file: '(.+?)'").findall(open)[0] return u except: pass try: if not 'robssatellitetv.com' in url: raise Exception() open = getUrl(url) u = re.compile('src: "(.+?)"').findall(open)[0] return u except: pass try: if not 'arconaitv.me' in url: raise Exception() url = 'http://www.justproxy.co.uk/index.php?q='+base64.b64encode(url) open = getUrl(url) u = re.compile('"src":"(.+?)"').findall(open)[0] u = u.strip() return str(u).replace('\/','/').replace('"','') except: pass try: import urlresolver hmf = urlresolver.HostedMediaFile(url=url) if hmf.valid_url() == False: raise Exception() direct = False ; u = hmf.resolve() if not u == False: return u except: pass if direct == True: return url
def process(self, url, direct=True): try: if not any(i in url for i in ['.jpg', '.png', '.gif']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext in ['jpg', 'png', 'gif']: raise Exception() try: i = os.path.join(control.dataPath,'img') control.deleteFile(i) f = control.openFile(i, 'w') f.write(client.request(url)) f.close() control.execute('ShowPicture("%s")' % i) return False except: return except: pass try: r, x = re.findall('(.+?)\|regex=(.+?)$', url)[0] x = regex.fetch(x) r += urllib.unquote_plus(x) if not '</regex>' in r: raise Exception() u = regex.resolve(r) if not u == None: url = u except: pass try: if not url.startswith('rtmp'): raise Exception() if len(re.compile('\s*timeout=(\d*)').findall(url)) == 0: url += ' timeout=10' return url except: pass try: if not any(i in url for i in ['.m3u8', '.f4m', '.ts']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext in ['m3u8', 'f4m', 'ts']: raise Exception() return url except: pass try: preset = re.findall('<preset>(.+?)</preset>', url)[0] if not 'search' in preset: raise Exception() title, year, imdb = re.findall('<title>(.+?)</title>', url)[0], re.findall('<year>(.+?)</year>', url)[0], re.findall('<imdb>(.+?)</imdb>', url)[0] try: tvdb, tvshowtitle, premiered, season, episode = re.findall('<tvdb>(.+?)</tvdb>', url)[0], re.findall('<tvshowtitle>(.+?)</tvshowtitle>', url)[0], re.findall('<premiered>(.+?)</premiered>', url)[0], re.findall('<season>(.+?)</season>', url)[0], re.findall('<episode>(.+?)</episode>', url)[0] except: tvdb = tvshowtitle = premiered = season = episode = None direct = False quality = 'HD' if not preset == 'searchsd' else 'SD' from resources.lib.modules import sources u = sources.sources().getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, quality) if not u == None: return u except: pass try: from resources.lib.modules import sources u = sources.sources().getURISource(url) if not u == False: direct = False if u == None or u == False: raise Exception() return u except: pass try: if not '.google.com' in url: raise Exception() from resources.lib.modules import directstream u = directstream.google(url)[0]['url'] return u except: pass try: if not 'filmon.com/' in url: raise Exception() from resources.lib.modules import filmon u = filmon.resolve(url) return u except: pass try: try: headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1])) except: headers = dict('') if not url.startswith('http'): raise Exception() result = client.request(url.split('|')[0], headers=headers, output='headers', timeout='20') if 'Content-Type' in result and not 'html' in result['Content-Type']: raise Exception() import liveresolver if liveresolver.isValid(url) == True: direct = False u = liveresolver.resolve(url) if not u == None: try: dialog.close() except: pass return u except: pass try: import urlresolver hmf = urlresolver.HostedMediaFile(url=url) if hmf.valid_url() == False: raise Exception() direct = False ; u = hmf.resolve() if not u == False: return u except: pass if direct == True: return url
from resources.lib.modules import log_utils from resources.lib.modules import control import threading addon_settings = xbmc.translatePath( 'special://userdata/addon_data/plugin.video.exodusrefix/settings.xml') control.execute('RunPlugin(plugin://%s)' % control.get_plugin_url({'action': 'service'})) run2 = control.setting('first.info2') if run2 == '': run2 = 'true' #clean install scenerio if run2 == 'true': import os if os.path.exists(xbmc.translatePath(addon_settings)): control.deleteFile(addon_settings) control.setSetting(id='first.info2', value='false') def syncTraktLibrary(): control.execute( 'RunPlugin(plugin://%s)' % 'plugin.video.exodusrefix/?action=tvshowsToLibrarySilent&url=traktcollection' ) control.execute( 'RunPlugin(plugin://%s)' % 'plugin.video.exodusrefix/?action=moviesToLibrarySilent&url=traktcollection' ) try:
def resolve(self, url): try: m3u8 = [ [ '#EXTM3U', '', '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH={bandwidth},NAME="{stream_name}"', '{video_stream}' ], [ '#EXTM3U', '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="{audio_group}",DEFAULT=YES,AUTOSELECT=YES,NAME="Stream 1",URI="{audio_stream}"', '', '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH={bandwidth},NAME="{stream_name}",AUDIO="{audio_group}"', '{video_stream}' ] ] query = urlparse.parse_qs(url) query = dict([(key, query[key][0]) if query[key] else (key, '') for key in query]) for i in m3u8: try: content = ('\n'.join(i)).format(**query) except: pass auth = query['video_stream'] r = client.request(auth, headers={'User-Agent': 'Lavf/56.40.101'}) try: url = json.loads(r)['url'] except: url = None if not url == None: def dialog(url): try: self.disableScraper = control.yesnoDialog('To watch this video visit from any device', '[COLOR skyblue]%s[/COLOR]' % url, '', 'Torba', 'Cancel', 'Settings') except: pass workers.Thread(dialog, url).start() control.sleep(3000) for i in range(100): try: if not control.condVisibility('Window.IsActive(yesnoDialog)'): break r = client.request(auth, headers={'User-Agent': 'Lavf/56.40.101'}) try: url = json.loads(r)['url'] except: url = None if url == None: break workers.Thread(dialog, url).start() control.sleep(3000) except: pass if self.disableScraper: control.openSettings(query='2.0') return '' control.execute('Dialog.Close(yesnoDialog)') if not url == None: return path = os.path.join(control.dataPath, 'torbase.m3u8') control.makeFile(control.dataPath) ; control.deleteFile(path) file = control.openFile(path, 'w') ; file.write(content) ; file.close() return path except: return
def process(self, url, direct=True): try: if not any(i in url for i in ['.jpg', '.png', '.gif']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext in ['jpg', 'png', 'gif']: raise Exception() try: dialog = None dialog = control.progressDialog dialog.create(control.addonInfo('name'), control.lang(30732).encode('utf-8')) dialog.update(0) i = os.path.join(control.dataPath,'img') control.deleteFile(i) f = control.openFile(i, 'w') f.write(client.request(url)) f.close() dialog.close() control.execute('ShowPicture("%s")' % i) return True except: return except: pass try: dialog = None dialog = control.progressDialog dialog.create(control.addonInfo('name'), control.lang(30726).encode('utf-8')) dialog.update(0) except: pass try: if not '</regex>' in url: raise Exception() from resources.lib.modules import regex u = regex.resolve(url) if not u == None: url = u except: pass try: if not url.startswith('rtmp'): raise Exception() if len(re.compile('\s*timeout=(\d*)').findall(url)) == 0: url += ' timeout=10' try: dialog.close() except: pass return url except: pass try: if not any(i in url for i in ['.m3u8', '.f4m', '.ts']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext in ['m3u8', 'f4m', 'ts']: raise Exception() try: dialog.close() except: pass return url except: pass try: preset = re.findall('<preset>(.+?)</preset>', url)[0] title, year, imdb = re.findall('<title>(.+?)</title>', url)[0], re.findall('<year>(.+?)</year>', url)[0], re.findall('<imdb>(.+?)</imdb>', url)[0] try: tvdb, tvshowtitle, premiered, season, episode = re.findall('<tvdb>(.+?)</tvdb>', url)[0], re.findall('<tvshowtitle>(.+?)</tvshowtitle>', url)[0], re.findall('<premiered>(.+?)</premiered>', url)[0], re.findall('<season>(.+?)</season>', url)[0], re.findall('<episode>(.+?)</episode>', url)[0] except: tvdb = tvshowtitle = premiered = season = episode = None direct = False presetDict = ['primewire_mv_tv', 'watchfree_mv_tv', 'movie25_mv', 'watchseries_tv', 'afdah_mv', 'dtmovies_mv', 'dizibox_tv', 'dizigold_tv', 'miradetodo_mv', 'onemovies_mv_tv', 'onlinedizi_tv', 'pelispedia_mv_tv', 'pubfilm_mv_tv', 'putlocker_mv_tv', 'rainierland_mv', 'sezonlukdizi_tv', 'tunemovie_mv', 'xmovies_mv'] if preset == 'searchsd': presetDict = ['primewire_mv_tv', 'watchfree_mv_tv', 'movie25_mv', 'watchseries_tv'] from resources.lib.sources import sources try: dialog.update(0, control.lang(30726).encode('utf-8'), control.lang(30731).encode('utf-8')) except: pass u = sources().getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, presetDict=presetDict, progress=False, timeout=20) try: dialog.update(50, control.lang(30726).encode('utf-8'), control.lang(30731).encode('utf-8')) except: pass u = sources().sourcesDirect(u, progress=False) if not u == None: try: dialog.close() except: pass return u except: pass try: from resources.lib.sources import sources u = sources().getURISource(url) if not u == False: direct = False if u == None or u == False or u == []: raise Exception() try: dialog.update(50, control.lang(30726).encode('utf-8'), control.lang(30731).encode('utf-8')) except: pass u = sources().sourcesDirect(u, progress=False) if not u == None: try: dialog.close() except: pass return u except: pass try: if not '.google.com' in url: raise Exception() from resources.lib.modules import directstream u = directstream.google(url)[0]['url'] try: dialog.close() except: pass return u except: pass try: import urlresolver hmf = urlresolver.HostedMediaFile(url=url, include_disabled=True, include_universal=False) if hmf.valid_url() == False: raise Exception() direct = False ; u = hmf.resolve() if 'plugin://plugin.video.youtube' in u: raise Exception() if not u == False: try: dialog.close() except: pass return u except: pass try: try: headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1])) except: headers = dict('') if not url.startswith('http'): raise Exception() result = client.request(url.split('|')[0], headers=headers, output='headers', timeout='20') if 'Content-Type' in result and not 'html' in result['Content-Type']: raise Exception() import liveresolver if liveresolver.isValid(url) == True: direct = False u = liveresolver.resolve(url) if not u == None: try: dialog.close() except: pass return u except: pass if direct == True: return url try: dialog.close() except: pass
def resolve(self, url): try: m3u8 = [ '#EXTM3U', '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="audio",DEFAULT=YES,AUTOSELECT=YES,NAME="Stream 1",URI="{audio_stream}"', '', '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=0,NAME="{stream_name}",AUDIO="audio"', '{video_stream}' ] query = urlparse.parse_qs(url) query = dict([(key, query[key][0]) if query[key] else (key, '') for key in query]) auth = 'http://streamtorrent.tv/api/torrent/%s/%s.m3u8?json=true' % (query['vid_id'], query['stream_id']) r = client.request(auth) r = json.loads(r) try: url = r['url'] except: url = None if not url == None: def dialog(url): try: self.disableScraper = control.yesnoDialog('Torba requires you visit, on any device, the following url to watch this video:', '[COLOR skyblue]%s[/COLOR]' % url, '', 'Torba', 'Cancel', 'Settings') except: pass workers.Thread(dialog, url).start() control.sleep(3000) for i in range(100): try: if not control.condVisibility('Window.IsActive(yesnoDialog)'): break r = client.request(auth) r = json.loads(r) try: url = r['url'] except: url = None if url == None: break workers.Thread(dialog, url).start() control.sleep(3000) except: pass if self.disableScraper: control.openSettings(query='2.0') return '' control.execute('Dialog.Close(yesnoDialog)') if not url == None: return stream_name = '%sp' % (query['height']) video_stream = r[stream_name] if not 'audio' in r: return video_stream audio_stream = r['audio'] content = ('\n'.join(m3u8)).format(**{'audio_stream': audio_stream, 'stream_name': stream_name, 'video_stream': video_stream}) path = os.path.join(control.dataPath, 'torbase.m3u8') control.makeFile(control.dataPath) ; control.deleteFile(path) file = control.openFile(path, 'w') ; file.write(content) ; file.close() return path except: return
def resolve(self, url): try: m3u8 = [ '#EXTM3U', '#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="{audio_group}",DEFAULT=YES,AUTOSELECT=YES,NAME="Stream 1",URI="{audio_stream}"', '', '#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH={bandwidth},NAME="{stream_name}",AUDIO="{audio_group}"', '{video_stream}' ] query = urlparse.parse_qs(url) query = dict([(key, query[key][0]) if query[key] else (key, '') for key in query]) content = ('\n'.join(m3u8)).format(**query) auth = query['video_stream'] result = client.source(auth, headers={'User-Agent': 'Lavf/56.40.101'}) try: url = json.loads(result)['url'] except: url = None if not url == None: def dialog(url): self.disableScraper = control.yesnoDialog( 'To watch this video visit from any device', '[COLOR skyblue]%s[/COLOR]' % url, '', 'Torba', 'Cancel', 'Settings') workers.Thread(dialog, url).start() control.sleep(3000) for i in range(100): try: if not control.condVisibility( 'Window.IsActive(yesnoDialog)'): break result = client.source( auth, headers={'User-Agent': 'Lavf/56.40.101'}) try: url = json.loads(result)['url'] except: url = None if url == None: break workers.Thread(dialog, url).start() control.sleep(3000) except: pass if self.disableScraper: control.openSettings(query='2.0') return '' control.execute('Dialog.Close(yesnoDialog)') if not url == None: return path = os.path.join(control.dataPath, 'torbase.m3u8') control.makeFile(control.dataPath) control.deleteFile(path) file = control.openFile(path, 'w') file.write(content) file.close() return path except: return
def process(self, url, direct=True): try: if not any(i in url for i in ['.jpg', '.png', '.gif']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit( '.')[-1].replace('/', '').lower() if not ext in ['jpg', 'png', 'gif']: raise Exception() try: i = os.path.join(control.dataPath, 'img') control.deleteFile(i) f = control.openFile(i, 'w') f.write(client.request(url)) f.close() control.execute('ShowPicture("%s")' % i) return False except: return except: pass try: r, x = re.findall('(.+?)\|regex=(.+?)$', url)[0] x = regex.fetch(x) r += urllib.unquote_plus(x) if not '</regex>' in r: raise Exception() u = regex.resolve(r) if not u == None: url = u except: pass try: if not url.startswith('rtmp'): raise Exception() if len(re.compile('\s*timeout=(\d*)').findall(url)) == 0: url += ' timeout=10' return url except: pass try: if not any(i in url for i in ['.m3u8', '.f4m', '.ts']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit( '.')[-1].replace('/', '').lower() if not ext in ['m3u8', 'f4m', 'ts']: raise Exception() return url except: pass try: import urlresolver hmf = urlresolver.HostedMediaFile(url=url) if hmf.valid_url() == False: raise Exception() direct = False u = hmf.resolve() if not u == False: return u except: pass if direct == True: return url
def process(self, url, direct=True): try: if not any(i in url for i in ['.jpg', '.png', '.gif']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext in ['jpg', 'png', 'gif']: raise Exception() try: i = os.path.join(control.dataPath,'img') control.deleteFile(i) f = control.openFile(i, 'w') f.write(client.request(url)) f.close() control.execute('ShowPicture("%s")' % i) return False except: return except: pass try: r, x = re.findall('(.+?)\|regex=(.+?)$', url)[0] x = regex.fetch(x) r += urllib.unquote_plus(x) if not '</regex>' in r: raise Exception() u = regex.resolve(r) if not u is None: url = u except: pass try: if not url.startswith('rtmp'): raise Exception() if len(re.compile('\s*timeout=(\d*)').findall(url)) == 0: url += ' timeout=10' return url except: pass try: if not any(i in url for i in ['.m3u8', '.f4m', '.ts']): raise Exception() ext = url.split('?')[0].split('&')[0].split('|')[0].rsplit('.')[-1].replace('/', '').lower() if not ext in ['m3u8', 'f4m', 'ts']: raise Exception() return url except: pass try: preset = re.findall('<preset>(.+?)</preset>', url)[0] if not 'search' in preset: raise Exception() title, year, imdb = re.findall('<title>(.+?)</title>', url)[0], re.findall('<year>(.+?)</year>', url)[0], re.findall('<imdb>(.+?)</imdb>', url)[0] try: tvdb, tvshowtitle, premiered, season, episode = re.findall('<tvdb>(.+?)</tvdb>', url)[0], re.findall('<tvshowtitle>(.+?)</tvshowtitle>', url)[0], re.findall('<premiered>(.+?)</premiered>', url)[0], re.findall('<season>(.+?)</season>', url)[0], re.findall('<episode>(.+?)</episode>', url)[0] except: tvdb = tvshowtitle = premiered = season = episode = None direct = False quality = 'HD' if not preset == 'searchsd' else 'SD' from resources.lib.modules import sources u = sources.Sources().getSources(title, year, imdb, tvdb, season, episode, tvshowtitle, premiered, quality) if not u is None: return u except: pass try: from resources.lib.modules import sources u = sources.Sources().getURISource(url) if not u is False: direct = False if u is None or u is False: raise Exception() return u except: pass try: if not '.google.com' in url: raise Exception() from resources.lib.modules import directstream u = directstream.google(url)[0]['url'] return u except: pass try: if not 'filmon.com/' in url: raise Exception() from resources.lib.modules import filmon u = filmon.resolve(url) return u except: pass try: try: headers = dict(urlparse.parse_qsl(url.rsplit('|', 1)[1])) except: headers = dict('') if not url.startswith('http'): raise Exception() result = client.request(url.split('|')[0], headers=headers, output='headers', timeout='20') if 'Content-Type' in result and not 'html' in result['Content-Type']: raise Exception() import liveresolver if liveresolver.isValid(url) is True: direct = False u = liveresolver.resolve(url) if not u is None: try: dialog.close() except: pass return u except: pass try: import resolveurl hmf = resolveurl.HostedMediaFile(url=url) if hmf.valid_url() is False: raise Exception() direct = False ; u = hmf.resolve() if not u is False: return u except: pass if direct is True: return url