def __init__(self): self.threads = [] self.menu_list = [] self.thread_pool = ThreadPool() self.providers = {} if tools.all_debrid_enabled(): self.providers.update({'all_debrid': AllDebridWalker}) if tools.premiumize_enabled(): self.providers.update({'premiumize': PremiumizeWalker}) if tools.real_debrid_enabled(): self.providers.update({'real_debrid': RealDebridWalker})
def home(self): if tools.premiumize_enabled(): self.threads.append( threading.Thread(target=self.thread_worker, args=(self.get_premiumize_files, ''))) if tools.real_debrid_enabled(): self.threads.append( threading.Thread(target=self.thread_worker, args=(self.get_real_debrid_files, ))) self.run_threads() for file in self.real_debrid_files: file.update({'debrid_provider': 'real_debrid'}) if len(file['links']) > 1: isPlayable = False isFolder = True action = 'myFilesFolder' else: isPlayable = True isFolder = False action = 'myFilesPlay' file['link'] = file['links'][0] actionArgs = json.dumps(file) tools.addDirectoryItem(file['filename'], action, None, None, isPlayable=isPlayable, isFolder=isFolder, actionArgs=actionArgs) for file in self.premiumize_files: file.update({'debrid_provider': 'premiumize'}) actionArgs = json.dumps(file) if file['type'] == 'folder': isPlayable = False isFolder = True action = 'myFilesFolder' else: isPlayable = True isFolder = False action = 'myFilesPlay' tools.addDirectoryItem(file['name'], action, None, None, isPlayable=isPlayable, isFolder=isFolder, actionArgs=actionArgs) tools.closeDirectory('addon')
def home(self): if tools.getSetting('trakt.auth') is not '': trakt = True else: trakt = False tools.addDirectoryItem(tools.lang(32001), 'moviesHome', None, None) tools.addDirectoryItem(tools.lang(32003), 'showsHome', None, None) if trakt: tools.addDirectoryItem(tools.lang(32002), 'myMovies', None, None) if trakt: tools.addDirectoryItem(tools.lang(32004), 'myShows', None, None) if tools.premiumize_enabled() or tools.real_debrid_enabled(): tools.addDirectoryItem(tools.lang(40126), 'myFiles', None, None) tools.addDirectoryItem(tools.lang(32016), 'searchMenu', None, None) tools.addDirectoryItem(tools.lang(32041), 'toolsMenu') # tools.addDirectoryItem('Test2', 'test2', None, None, isFolder=True) tools.closeDirectory('addons')
def resolve(self, sources, args, pack_select=False): try: if 'showInfo' in args: background = args['showInfo']['art']['fanart'] else: background = args['fanart'] self.setText(tools.lang(33000)) self.setBackground(background) stream_link = None loop_count = 0 # Begin resolving links tools.log('Attempting to Resolve file link', 'info') for i in sources: debrid_provider = i.get('debrid_provider', 'None').replace('_', ' ') loop_count += 1 try: if self.is_canceled(): self.close() return if 'size' in i: i['info'].append(tools.source_size_display(i['size'])) loop_count_string = "(" + str(loop_count) + " of " + str( len(sources)) + ")" line1 = "%s %s - %s" % (tools.lang(32036), tools.colorString( tools.display_string( i['release_title'])), loop_count_string) line2 = "%s %s | Source: %s" % ( tools.lang(32037), tools.colorString(debrid_provider.upper()), tools.colorString(i['source'])) line3 = '%s %s | Info: %s' % ( tools.lang(32038), tools.colorString(i['quality']), tools.colorString(" ".join(i['info']))) self.setText(line1) self.setText2(line2) self.setText3(line3) if i['type'] == 'torrent': if i['debrid_provider'] == 'premiumize': stream_link = self.premiumizeResolve( i, args, pack_select) elif i['debrid_provider'] == 'real_debrid': stream_link = self.realdebridResolve(i, args) if stream_link is None: tools.log('Failed to resolve for torrent %s' % i['release_title']) continue else: self.return_data = stream_link self.close() return elif i['type'] == 'hoster' or i['type'] == 'cloud': # Quick fallback to speed up resolving while direct and free hosters are not supported if 'provider_imports' in i: provider = i['provider_imports'] providerModule = __import__( '%s.%s' % (provider[0], provider[1]), fromlist=['']) providerModule = providerModule.source() try: i['url'] = providerModule.resolve(i['url']) except: import traceback traceback.print_exc() pass if i['url'] is None: continue if 'debrid_provider' in i: if i['debrid_provider'] == 'premiumize' and tools.premiumize_enabled( ): stream_link = self.premiumizeResolve(i, args) if stream_link is None: continue if i['debrid_provider'] == 'real_debrid' and tools.real_debrid_enabled( ): stream_link = self.realdebridResolve(i, args) if stream_link is None: continue else: # Currently not supporting free hosters at this point in time # ResolveURL and Direct link testing needs to be tested first try: ext = i['url'].split('?')[0].split( '&')[0].split('|')[0].rsplit( '.')[-1].replace('/', '').lower() if ext == 'rar': raise Exception() try: headers = i['url'].rsplit('|', 1)[1] except: headers = '' try: headers = i['url'].rsplit('|', 1)[1] except: headers = '' headers = tools.quote_plus(headers).replace( '%3D', '=') if ' ' in headers else headers headers = dict(tools.parse_qsl(headers)) live_check = requests.head(i['url'], headers=headers, timeout=10) if not live_check.status_code == 200: continue stream_link = i['url'] except: stream_link = None if stream_link is None: continue else: if stream_link.endswith('.rar'): continue self.return_data = stream_link self.close() return continue except: import traceback traceback.print_exc() continue self.close() if tools.getSetting('premiumize.enabled') == 'true': tools.execute( 'RunPlugin("plugin://plugin.video.%s/?action=premiumizeCleanup")' % tools.addonName.lower()) return except: import traceback traceback.print_exc() self.close() return
if action == 'colorPicker': tools.colorPicker() if action == 'authTrakt': from resources.lib.indexers import trakt trakt.TraktAPI().auth() if action == 'revokeTrakt': from resources.lib.indexers import trakt trakt.TraktAPI().revokeAuth() if action == 'getSources': try: if tools.playList.getposition() == 0 and not tools.premiumize_enabled( ) and not tools.real_debrid_enabled(): tools.showDialog.ok(tools.addonName, tools.lang(40146), tools.lang(40147)) sys.exit() if tools.playList.getposition() == 0 and tools.getSetting( 'general.scrapedisplay') == '0': display_background = True else: display_background = False if tools.getSetting('general.scrapedisplay') == '1': tools.closeBusyDialog() if display_background: background = windows.persistant_background()
def resolve(self, sources, args, pack_select=False): try: if 'showInfo' in args: background = args['showInfo']['art']['fanart'] else: background = args['art']['fanart'] stream_link = None loop_count = 0 # Begin resolving links tools.log('Attempting to Resolve file link', 'info') for i in sources: debrid_provider = i.get('debrid_provider', 'None').replace('_', ' ') loop_count += 1 try: if self.is_canceled(): self.close() return if 'size' in i: i['info'].append(tools.source_size_display(i['size'])) self.setProperty('release_title', tools.display_string(i['release_title'])) self.setProperty('debrid_provider', debrid_provider) self.setProperty('source_provider', i['source']) self.setProperty('source_resolution', i['quality']) self.setProperty('source_info', " ".join(i['info'])) if i['type'] == 'torrent': if i['debrid_provider'] == 'premiumize': stream_link = self.premiumizeResolve( i, args, pack_select) elif i['debrid_provider'] == 'real_debrid': stream_link = self.realdebridResolve(i, args) if stream_link is None: tools.log('Failed to resolve for torrent %s' % i['release_title']) continue else: self.return_data = stream_link self.close() return elif i['type'] == 'hoster' or i['type'] == 'cloud': # Quick fallback to speed up resolving while direct and free hosters are not supported if 'provider_imports' in i: provider = i['provider_imports'] providerModule = __import__( '%s.%s' % (provider[0], provider[1]), fromlist=['']) providerModule = providerModule.source() try: i['url'] = providerModule.resolve(i['url']) except: import traceback traceback.print_exc() pass if i['url'] is None: continue if 'debrid_provider' in i: if i['debrid_provider'] == 'premiumize' and tools.premiumize_enabled( ): stream_link = self.premiumizeResolve(i, args) if stream_link is None: continue else: try: requests.head(stream_link, timeout=1) except: tools.log( 'Head Request failed link might be dead, skipping' ) continue if i['debrid_provider'] == 'real_debrid' and tools.real_debrid_enabled( ): stream_link = self.realdebridResolve(i, args) if stream_link is None: continue try: requests.head(stream_link, timeout=1) except: tools.log( 'Head Request failed link might be dead, skipping' ) continue else: # Currently not supporting free hosters at this point in time # ResolveURL and Direct link testing needs to be tested first try: ext = i['url'].split('?')[0].split( '&')[0].split('|')[0].rsplit( '.')[-1].replace('/', '').lower() if ext == 'rar': raise Exception() try: headers = i['url'].rsplit('|', 1)[1] except: headers = '' try: headers = i['url'].rsplit('|', 1)[1] except: headers = '' headers = tools.quote_plus(headers).replace( '%3D', '=') if ' ' in headers else headers headers = dict(tools.parse_qsl(headers)) live_check = requests.head(i['url'], headers=headers, timeout=10) if not live_check.status_code == 200: continue stream_link = i['url'] except: stream_link = None if stream_link is None: continue else: if stream_link.endswith('.rar'): continue self.return_data = stream_link self.close() return continue except: import traceback traceback.print_exc() continue self.close() return except: import traceback traceback.print_exc() self.close() return