def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date): sourceDict = [] for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg)) sourceDict = [i[0] for i in sourceDict if i[1] == False] content = 'movie' if tvshowtitle == None else 'episode' if content == 'movie': sourceDict = [i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))] try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] else: sourceDict = [i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))] try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i) + '_tv')) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] global global_sources global_sources = [] threads = [] control.makeFile(control.dataPath) self.sourceFile = control.sourcescacheFile sourceDict = [i[0] for i in sourceDict if i[1] == 'true'] if content == 'movie': title = cleantitle.normalize(title) for source in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) else: tvshowtitle = cleantitle.normalize(tvshowtitle) season, episode = alterepisode.alterepisode().get(imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date) for source in sourceDict: threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) try: timeout = int(control.setting('sources_timeout_15')) except: timeout = 10 [i.start() for i in threads] #[i.join() for i in threads] ; self.sources = global_sources ; return self.sources for i in range(0, timeout * 2): is_alive = [x.is_alive() for x in threads] if all(x == False for x in is_alive): break time.sleep(0.5) for i in range(0, 5 * 2): is_alive = len([i for i in threads if i.is_alive() == True]) if is_alive < 10: break time.sleep(0.5) self.sources = global_sources return self.sources
def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date): sourceDict = [] for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg)) sourceDict = [i[0] for i in sourceDict if i[1] == False] content = 'movie' if tvshowtitle == None else 'episode' if content == 'movie': sourceDict = [i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))] try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] else: sourceDict = [i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))] try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i) + '_tv')) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] global global_sources global_sources = [] threads = [] control.makeFile(control.dataPath) self.sourceFile = control.sourcescacheFile sourceDict = [i[0] for i in sourceDict if i[1] == 'true'] if content == 'movie': title = cleantitle.normalize(title) for source in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) else: tvshowtitle = cleantitle.normalize(tvshowtitle) season, episode = alterepisode.alterepisode().get(imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date) for source in sourceDict: threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) try: timeout = int(control.setting('sources_timeout_40')) except: timeout = 40 [i.start() for i in threads] #[i.join() for i in threads] ; self.sources = global_sources ; return self.sources for i in range(0, timeout * 2): is_alive = [x.is_alive() for x in threads] if all(x == False for x in is_alive): break time.sleep(0.5) for i in range(0, 5 * 2): is_alive = len([i for i in threads if i.is_alive() == True]) if is_alive < 10: break time.sleep(0.5) self.sources = global_sources return self.sources
def checkSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date): sourceDict = [] for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg)) sourceDict = [i[0] for i in sourceDict if i[1] == False] content = 'movie' if tvshowtitle == None else 'episode' if content == 'movie': sourceDict = [i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))] try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] else: sourceDict = [i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))] try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i) + '_tv')) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] threads = [] control.makeFile(control.dataPath) self.sourceFile = control.sourcescacheFile sourceDict = [i[0] for i in sourceDict if i[1] == 'true'] if content == 'movie': title = cleantitle.normalize(title) for source in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) else: tvshowtitle = cleantitle.normalize(tvshowtitle) season, episode = alterepisode.alterepisode().get(imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date) for source in sourceDict: #control.log("SOURCE S2 %s" % source) threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) try: timeout = int(control.setting('sources_timeout_40')) except: timeout = 40 [i.start() for i in threads] for i in range(0, timeout * 2): try: if xbmc.abortRequested == True: return sys.exit() if len(self.sources) >= 10: break is_alive = [x.is_alive() for x in threads] if all(x == False for x in is_alive): break time.sleep(0.5) except: pass if len(self.sources) >= 5: return True else: return False
def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, proxy_options, provider_options, key, session): #try: sourceDict = [] self.getSourcesAlive = True if provider_options !=None: myProviders = [] for prov in provider_options: myProviders += [i for i in self.providersCaller if i['url'].lower() == prov['url'].lower() and str(prov['enabled'])=='True'] else: myProviders = self.providersCaller content = 'movie' if tvshowtitle == None else 'show' self.threads[key] = [] if content == 'movie': log(err='Searching Movie: %s' % title) title = cleantitle.normalize(title) for source in myProviders: try: source_name = 'Unknow source (import error)' source_name = source['name'] log(err='Searching Movie: %s (%s) in Provider %s' % (title,year,source_name)) thread_i = workers.Thread(self.getMovieSource, title, year, imdb, proxy_options, key, re.sub('_mv_tv$|_mv$|_tv$', '', source['name']), source['call']) self.threads[key].append(thread_i) thread_i.start() except Exception as e: log(type='ERROR', err='getSources %s - %s' % (source_name,e)) else: log(err='Searching Show: %s' % tvshowtitle) try: tvshowtitle = cleantitle.normalize(tvshowtitle) except: pass try: season, episode = alterepisode.alterepisode().get(imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date) except: pass for source in myProviders: try: source_name = 'Unknow source (import error)' source_name = source['name'] log(err='Searching Show: %s S%sE%s in Provider %s' % (tvshowtitle,season,episode,source_name)) thread_i = workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, proxy_options, key, re.sub('_mv_tv$|_mv$|_tv$', '', source_name), source['call']) self.threads[key].append(thread_i) thread_i.start() except Exception as e: log(type='ERROR', err='getSources %s - %s' % (source_name,e)) #sourceLabel = [re.sub('_mv_tv$|_mv$|_tv$', '', i) for i in sourceDict] #sourceLabel = [re.sub('v\d+$', '', i).upper() for i in sourceLabel] #time.sleep(0.5) self.getSourcesAlive = False return self.sources
def checkSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date): sourceDict = [] for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg)) sourceDict = [i[0] for i in sourceDict if i[1] == False] content = 'movie' if tvshowtitle == None else 'episode' if content == 'movie': sourceDict = [i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))] try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] else: sourceDict = [i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))] try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i) + '_tv')) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] threads = [] control.makeFile(control.dataPath) self.sourceFile = control.sourcescacheFile sourceDict = [i[0] for i in sourceDict if i[1] == 'true'] if content == 'movie': title = cleantitle.normalize(title) for source in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) else: tvshowtitle = cleantitle.normalize(tvshowtitle) season, episode = alterepisode.alterepisode().get(imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date) for source in sourceDict: #control.log("SOURCE S2 %s" % source) threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) try: timeout = int(control.setting('sources_timeout_40')) except: timeout = 40 [i.start() for i in threads] for i in range(0, timeout * 2): try: if xbmc.abortRequested == True: return sys.exit() if len(self.sources) >= 10: break is_alive = [x.is_alive() for x in threads] if all(x == False for x in is_alive): break time.sleep(0.5) except: pass if len(self.sources) >= 10: return True else: return False
def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, proxy_options, provider_options, key): #try: sourceDict = [] self.getSourcesAlive = True if provider_options !=None: myProviders = [] for prov in provider_options: myProviders += [i for i in self.providersCaller if i['url'].lower() == prov['url'].lower() and str(prov['enabled'])=='True'] else: myProviders = self.providersCaller content = 'movie' if tvshowtitle == None else 'episode' self.threads[key] = [] if content == 'movie': print 'Searching Movie' title = cleantitle.normalize(title) for source in myProviders: try: thread_i = workers.Thread(self.getMovieSource, title, year, imdb, proxy_options, key, re.sub('_mv_tv$|_mv$|_tv$', '', source['name']), source['call']) self.threads[key].append(thread_i) thread_i.start() except Exception as e: print ('Source getSources %s ERROR %s' % (source,e)) control.log('Source getSources %s ERROR %s' % (source,e)) pass else: print 'Searching Episode' try: tvshowtitle = cleantitle.normalize(tvshowtitle) except: pass try: season, episode = alterepisode.alterepisode().get(imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date) except: pass for source in myProviders: try: thread_i = workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, proxy_options, key, re.sub('_mv_tv$|_mv$|_tv$', '', source['name']), source['call']) self.threads[key].append(thread_i) thread_i.start() except Exception as e: print ('Source getSources %s ERROR %s' % (source, e)) control.log('Source getSources %s ERROR %s' % (source, e)) pass #sourceLabel = [re.sub('_mv_tv$|_mv$|_tv$', '', i) for i in sourceDict] #sourceLabel = [re.sub('v\d+$', '', i).upper() for i in sourceLabel] #time.sleep(0.5) self.getSourcesAlive = False return self.sources
def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date): sourceDict = [] for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg)) sourceDict = [i[0] for i in sourceDict if i[1] == False] content = 'movie' if tvshowtitle == None else 'episode' if content == 'movie': sourceDict = [ i for i in sourceDict if i.endswith(('_mv', '_mv_tv')) ] try: sourceDict = [ (i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict ] except: sourceDict = [(i, 'true') for i in sourceDict] else: sourceDict = [ i for i in sourceDict if i.endswith(('_tv', '_mv_tv')) ] try: sourceDict = [(i, control.setting( re.sub('_mv_tv$|_mv$|_tv$', '', i) + '_tv')) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] threads = [] control.makeFile(control.dataPath) self.sourceFile = control.sourcescacheFile sourceDict = [i[0] for i in sourceDict if i[1] == 'true'] if content == 'movie': title = cleantitle.normalize(title) for source in sourceDict: threads.append( workers.Thread( self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) else: tvshowtitle = cleantitle.normalize(tvshowtitle) season, episode = alterepisode.alterepisode().get( imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date) for source in sourceDict: threads.append( workers.Thread( self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) try: timeout = int(control.setting('sources_timeout_40')) except: timeout = 40 [i.start() for i in threads] control.idle() sourceLabel = [re.sub('_mv_tv$|_mv$|_tv$', '', i) for i in sourceDict] sourceLabel = [re.sub('v\d+$', '', i).upper() for i in sourceLabel] self.progressDialog = control.progressDialog self.progressDialog.create(control.addonInfo('name'), '') self.progressDialog.update(0) string1 = control.lang(30512).encode('utf-8') string2 = control.lang(30513).encode('utf-8') string3 = control.lang(30514).encode('utf-8') for i in range(0, timeout * 2): try: if xbmc.abortRequested == True: return sys.exit() try: info = [ sourceLabel[int(re.sub('[^0-9]', '', str(x.getName()))) - 1] for x in threads if x.is_alive() == True ] except: info = [] if len(info) > 5: info = len(info) self.progressDialog.update( int((100 / float(len(threads))) * len([x for x in threads if x.is_alive() == False])), str('%s: %s %s' % (string1, int(i * 0.5), string2)), str('%s: %s' % (string3, str(info).translate(None, "[]'")))) if self.progressDialog.iscanceled(): break is_alive = [x.is_alive() for x in threads] if all(x == False for x in is_alive): break time.sleep(0.5) except: pass self.progressDialog.close() return self.sources
def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date, proxy_options, provider_options, key, session): try: sourceDict = [] self.getSourcesAlive = True if provider_options != None: myProviders = [] for prov in provider_options: myProviders += [ i for i in self.providersCaller if i['url'].lower() == prov['url'].lower() and str(prov['enabled']) == 'True' ] else: myProviders = self.providersCaller content = 'movie' if tvshowtitle == None else 'show' self.threads[key] = [] self.threadSlots[key] = [] pos = 0 if content == 'movie': log(err='Initializing Search for Movie: %s (%s)' % (title, year)) title = cleantitle.normalize(title) for source in myProviders: try: source_name = 'Unknow source (import error)' source_name = source['name'] if content in source['types']: log(err= 'Queuing Search for Movie: %s (%s) in Provider %s' % (title, year, source_name)) thread_i = workers.Thread(self.getMovieSource, title, year, imdb, proxy_options, key, source_name, source['call']) self.threads[key].append(thread_i) self.threadSlots[key].append({ 'thread': thread_i, 'status': 'idle', 'pos': pos, 'source': source_name }) pos += 1 else: log(err= 'Content Movie: %s (%s) not supported in Provider %s' % (title, year, source_name)) except Exception as e: log(type='ERROR-CRITICAL', err='getSources %s - %s' % (source_name, e)) else: log(err='Initializing Search for Show: %s' % tvshowtitle) try: tvshowtitle = cleantitle.normalize(tvshowtitle) except: pass try: season, episode = alterepisode.alterepisode().get( imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date) except: pass for source in myProviders: try: source_name = 'Unknow source (import error)' source_name = source['name'] if content in source['types']: log(err= 'Queuing Search for Show: %s S%sE%s in Provider %s' % (tvshowtitle, season, episode, source_name)) thread_i = workers.Thread( self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, proxy_options, key, source_name, source['call']) self.threads[key].append(thread_i) self.threadSlots[key].append({ 'thread': thread_i, 'status': 'idle', 'pos': pos, 'source': source_name }) pos += 1 else: log(err= 'Content Show: %s S%sE%s not supported in Provider %s' % (tvshowtitle, season, episode, source_name)) except Exception as e: log(type='ERROR-CRITICAL', err='getSources %s - %s' % (source_name, e)) thread_ex = workers.Thread(self.executeThreads, key) thread_ex.start() self.executeThreadsStatus(key, thread_ex) self.getSourcesAlive = False return self.sources except Exception as e: log(type='ERROR-CRITICAL', err='getSources - %s' % e) return self.sources
def getSources(self, name, title, year, imdb, tmdb, tvdb, tvrage, season, episode, tvshowtitle, alter, date): sourceDict = [] for package, name, is_pkg in pkgutil.walk_packages(__path__): sourceDict.append((name, is_pkg)) sourceDict = [i[0] for i in sourceDict if i[1] == False] content = 'movie' if tvshowtitle == None else 'episode' if content == 'movie': sourceDict = [i for i in sourceDict if i.endswith(('_mv', '_mv_tv'))] try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i))) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] else: sourceDict = [i for i in sourceDict if i.endswith(('_tv', '_mv_tv'))] try: sourceDict = [(i, control.setting(re.sub('_mv_tv$|_mv$|_tv$', '', i) + '_tv')) for i in sourceDict] except: sourceDict = [(i, 'true') for i in sourceDict] threads = [] control.makeFile(control.dataPath) self.sourceFile = control.sourcescacheFile sourceDict = [i[0] for i in sourceDict if i[1] == 'true'] if content == 'movie': title = cleantitle.normalize(title) for source in sourceDict: threads.append(workers.Thread(self.getMovieSource, title, year, imdb, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) else: tvshowtitle = cleantitle.normalize(tvshowtitle) season, episode = alterepisode.alterepisode().get(imdb, tmdb, tvdb, tvrage, season, episode, alter, title, date) for source in sourceDict: threads.append(workers.Thread(self.getEpisodeSource, title, year, imdb, tvdb, season, episode, tvshowtitle, date, re.sub('_mv_tv$|_mv$|_tv$', '', source), __import__(source, globals(), locals(), [], -1).source())) try: timeout = int(control.setting('sources_timeout_40')) except: timeout = 40 [i.start() for i in threads] control.idle() sourceLabel = [re.sub('_mv_tv$|_mv$|_tv$', '', i) for i in sourceDict] sourceLabel = [re.sub('v\d+$', '', i).upper() for i in sourceLabel] self.progressDialog = control.progressDialog self.progressDialog.create(control.addonInfo('name'), '') self.progressDialog.update(0) string1 = control.lang(30512).encode('utf-8') string2 = control.lang(30513).encode('utf-8') string3 = control.lang(30514).encode('utf-8') for i in range(0, timeout * 2): try: if xbmc.abortRequested == True: return sys.exit() try: info = [sourceLabel[int(re.sub('[^0-9]', '', str(x.getName()))) - 1] for x in threads if x.is_alive() == True] except: info = [] if len(info) > 5: info = len(info) self.progressDialog.update(int((100 / float(len(threads))) * len([x for x in threads if x.is_alive() == False])), str('%s: %s %s' % (string1, int(i * 0.5), string2)), str('%s: %s' % (string3, str(info).translate(None, "[]'")))) if self.progressDialog.iscanceled(): break is_alive = [x.is_alive() for x in threads] if all(x == False for x in is_alive): break time.sleep(0.5) except: pass self.progressDialog.close() return self.sources