def worker(self): self.meta = [] total = len(self.list) for i in range(0, total): self.list[i].update({'metacache': False}) self.list = metacache.fetch(self.list, self.info_lang) itemsPerPage = 25 for r in range(0, total, itemsPerPage): threads = [] for i in range(r, r + itemsPerPage): if i <= total: threads.append(workers.Thread(self.super_info, i)) [i.start() for i in threads] [i.join() for i in threads] if len(self.meta) > 0: metacache.insert(self.meta)
def sourcesDialog(self, items): try: labels = [i['label'] for i in items] select = control.selectDialog(labels) if select == -1: return 'close://' self.isRegistered() next = [y for x, y in enumerate(items) if x >= select] prev = [y for x, y in enumerate(items) if x < select][::-1] items = [items[select]] items = [i for i in items + next + prev][:40] header = control.addonInfo('name') header2 = header.upper() progressDialog = control.progressDialog progressDialog.create(control.addonInfo('name'), '') progressDialog.update(0) block = None for i in range(len(items)): try: if items[i]['source'] == block: raise Exception() w = workers.Thread(self.sourcesResolve, items[i]) w.start() try: if progressDialog.iscanceled(): break progressDialog.update( int((100 / float(len(items))) * i), str(items[i]['label']), str(' ')) except: progressDialog.update( int((100 / float(len(items))) * i), str(header2), str(items[i]['label'])) m = '' for x in range(3600): try: if xbmc.abortRequested == True: return sys.exit() if progressDialog.iscanceled(): return progressDialog.close() except: pass k = control.condVisibility( 'Window.IsActive(virtualkeyboard)') if k: m += '1' m = m[-1] if (w.is_alive() == False or x > 30) and not k: break k = control.condVisibility( 'Window.IsActive(yesnoDialog)') if k: m += '1' m = m[-1] if (w.is_alive() == False or x > 30) and not k: break time.sleep(0.5) for x in range(30): try: if xbmc.abortRequested == True: return sys.exit() if progressDialog.iscanceled(): return progressDialog.close() except: pass if m == '': break if w.is_alive() == False: break time.sleep(0.5) if w.is_alive() == True: block = items[i]['source'] if self.url == None: raise Exception() self.selectedSource = items[i]['label'] try: progressDialog.close() except: pass control.execute('Dialog.Close(virtualkeyboard)') control.execute('Dialog.Close(yesnoDialog)') return self.url except: pass try: progressDialog.close() except: pass except Exception as e: logger.error(e.message) try: progressDialog.close() except: pass
def getSources(self, name, title, year, imdb, tvdb, season, episode, tvshowtitle, date, meta=None): content = 'movie' if tvshowtitle == None else 'episode' control.makeFile(control.dataPath) self.sourceFile = control.sourcescacheFile logger.debug('Content [%s]' % content, __name__) try: timeout = int(control.setting('sources_timeout_40')) except: timeout = 40 try: allowDebrid = bool(control.setting('allow_debrid')) except: allowDebrid = False import desiscrapers control.init('script.module.desiscrapers') totalScrapers = len( desiscrapers.relevant_scrapers(scraper_type=content)) if content == 'movie': title = cleantitle.normalize(title) links_scraper = desiscrapers.scrape_movie( title, year, imdb, timeout=timeout, enable_debrid=allowDebrid) elif content == 'episode': tvshowtitle = cleantitle.normalize(tvshowtitle) imdb = json.loads(meta)['url'] show_year = year tvshowtitle = tvshowtitle.replace('Season', '').replace('season', '') links_scraper = desiscrapers.scrape_episode( tvshowtitle, show_year, year, season, episode, imdb, tvdb, timeout=timeout, enable_debrid=allowDebrid) control.init('plugin.video.swadesi') control.idle() self.progressDialog = control.progressDialog self.progressDialog.create(control.addonInfo('name'), '') self.progressDialog.update(0) thread = workers.Thread(self.get_desi_sources, links_scraper, totalScrapers) thread.start() for i in range(0, timeout * 4): try: if xbmc.abortRequested: return sys.exit() try: if self.progressDialog.iscanceled(): break except: pass if not thread.is_alive(): break time.sleep(0.5) except: pass self.progressDialog.close() for i in range(0, len(self.srcs)): self.srcs[i].update({'content': content}) return self.srcs
def playItem(self, content, title, source): try: self.isRegistered() control.resolve(syshandle, True, control.item(path='')) control.execute('Dialog.Close(okdialog)') next = [] prev = [] total = [] meta = control.window.getProperty(self.metaProperty) #meta = self.metaProperty meta = json.loads(meta) year = meta['year'] if 'year' in meta else None imdb = meta['imdb'] if 'imdb' in meta else None tvdb = meta['tvdb'] if 'tvdb' in meta else None for i in range(1, 10000): try: u = control.infoLabel('ListItem(%s).FolderPath' % str(i)) if u in total: raise Exception() total.append(u) u = dict(urlparse.parse_qsl(u.replace('?', ''))) if 'meta' in u: meta = u['meta'] u = json.loads(u['source'])[0] next.append(u) except: break for i in range(-10000, 0)[::-1]: try: u = control.infoLabel('ListItem(%s).FolderPath' % str(i)) if u in total: raise Exception() total.append(u) u = dict(urlparse.parse_qsl(u.replace('?', ''))) if 'meta' in u: meta = u['meta'] u = json.loads(u['source'])[0] prev.append(u) except: break items = json.loads(source) items = [i for i in items + next + prev][:40] self.progressDialog = control.progressDialog self.progressDialog.create(control.addonInfo('name'), '') self.progressDialog.update(0) block = None for i in range(len(items)): try: self.progressDialog.update( int((100 / float(len(items))) * i), str(items[i]['label']), str(' ')) if items[i]['source'] == block: raise Exception() w = workers.Thread(self.sourcesResolve, items[i]) w.start() m = '' for x in range(3600): if self.progressDialog.iscanceled(): return self.progressDialog.close() if xbmc.abortRequested == True: return sys.exit() k = control.condVisibility( 'Window.IsActive(virtualkeyboard)') if k: m += '1' m = m[-1] if (w.is_alive() == False or x > 30) and not k: break time.sleep(1.0) for x in range(3600): if m == '': break if self.progressDialog.iscanceled(): return self.progressDialog.close() if xbmc.abortRequested == True: return sys.exit() if w.is_alive() == False: break time.sleep(1.0) if w.is_alive() == True: block = items[i]['source'] if self.url == None: raise Exception() try: self.progressDialog.close() except: pass control.sleep(200) if control.setting('playback_info') == 'true': control.infoDialog(items[i]['label']) player().run(content, title, self.url, year, imdb, tvdb, meta) return self.url except Exception as e: logger.error(e, __name__) pass try: self.progressDialog.close() except: pass raise Exception() except Exception as e: logger.error(e.message) control.infoDialog(control.lang(30501).encode('utf-8')) pass