def worker(self): if not control.setting('metadata') == 'true': return self.imdb_info_link = 'http://www.omdbapi.com/?i=%s&plot=full&r=json' self.tvmaze_info_link = 'http://api.tvmaze.com/lookup/shows?thetvdb=%s' self.lang = 'en' self.meta = [] total = len(self.list) if total == 0: return for i in range(0, total): self.list[i].update({'metacache': False}) self.list = metacache.fetch(self.list, self.lang) multi = [i['imdb'] for i in self.list] multi = [x for y,x in enumerate(multi) if x not in multi[:y]] if len(multi) == 1: self.movie_info(0) ; self.tv_info(0) if self.meta: metacache.insert(self.meta) for i in range(0, total): self.list[i].update({'metacache': False}) self.list = metacache.fetch(self.list, self.lang) for r in range(0, total, 50): threads = [] for i in range(r, r+50): if i <= total: threads.append(workers.Thread(self.movie_info, i)) if i <= total: threads.append(workers.Thread(self.tv_info, i)) [i.start() for i in threads] [i.join() for i in threads] if self.meta: metacache.insert(self.meta)
def worker(self, level=1): self.meta = [] total = len(self.list) self.fanart_tv_headers = {'api-key': 'YTc2MGMyMTEzYTM1OTk5NzFiN2FjMWU0OWUzMTAyMGQ='.decode('base64')} if not self.fanart_tv_user == '': self.fanart_tv_headers.update({'client-key': self.fanart_tv_user}) for i in range(0, total): self.list[i].update({'metacache': False}) self.list = metacache.fetch(self.list, self.lang, self.user) for r in range(0, total, 40): threads = [] for i in range(r, r+40): if i <= total: threads.append(workers.Thread(self.super_info, i)) [i.start() for i in threads] [i.join() for i in threads] if self.meta: metacache.insert(self.meta) self.list = [i for i in self.list if not i['tvdb'] == '0'] if self.fanart_tv_user == '': for i in self.list: i.update({'clearlogo': '0', 'clearart': '0'})
def worker(self, level=1): self.meta = [] total = len(self.list) self.fanart_tv_headers = {} fanart_tv_level = 'user' fanart_tv_user = control.setting('fanart.tv.user') self.fanart_tv_headers.update({'api-key': 'YTc2MGMyMTEzYTM1OTk5NzFiN2FjMWU0OWUzMTAyMGQ='.decode('base64')}) if level == 1 and not fanart_tv_user == '': self.fanart_tv_headers.update({'client-key': fanart_tv_user}) #try: fanart_tv_level = json.loads(client.request(self.fanart_tv_level_link, headers=self.fanart_tv_headers))['level'] #except: pass for i in range(0, total): self.list[i].update({'metacache': False}) self.list = metacache.fetch(self.list, self.lang) for r in range(0, total, 40): threads = [] for i in range(r, r+40): 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) if fanart_tv_level == 'user': for i in self.list: i.update({'poster2': '0', 'fanart2': '0', 'banner2': '0', 'clearlogo': '0', 'clearart': '0'}) self.list = [i for i in self.list if not i['tvdb'] == '0']
def worker(self, level=1): self.meta = [] total = len(self.list) self.fanart_tv_headers = {'api-key': '04cd6efd5628ec6082644538a6045bdc'} if not self.fanart_tv_user == '': self.fanart_tv_headers.update({'client-key': self.fanart_tv_user}) for i in range(0, total): self.list[i].update({'metacache': False}) self.list = metacache.fetch(self.list, self.lang, self.user) for r in range(0, total, 40): threads = [] for i in range(r, r+40): if i <= total: threads.append(workers.Thread(self.super_info, i)) [i.start() for i in threads] [i.join() for i in threads] if self.meta: metacache.insert(self.meta) self.list = [i for i in self.list if not i['imdb'] == '0'] self.list = metacache.local(self.list, self.tm_img_link, 'poster3', 'fanart2') if self.fanart_tv_user == '': for i in self.list: i.update({'clearlogo': '0', 'clearart': '0'})
def worker(self, level=1): self.meta = [] total = len(self.list) self.fanart_tv_headers = {'api-key': 'NDZkZmMyN2M1MmE0YTc3MjY3NWQ4ZTMyYjdiY2E2OGU='.decode('base64')} if not self.fanart_tv_user == '': self.fanart_tv_headers.update({'client-key': self.fanart_tv_user}) for i in range(0, total): self.list[i].update({'metacache': False}) self.list = metacache.fetch(self.list, self.lang, self.user) for r in range(0, total, 40): threads = [] for i in range(r, r+40): if i <= total: threads.append(workers.Thread(self.super_info, i)) [i.start() for i in threads] [i.join() for i in threads] if self.meta: metacache.insert(self.meta) self.list = [i for i in self.list if not i['imdb'] == '0'] self.list = metacache.local(self.list, self.tm_img_link, 'poster3', 'fanart2') if self.fanart_tv_user == '': for i in self.list: i.update({'clearlogo': '0', 'clearart': '0'})
def worker(self, level=1): self.meta = [] total = len(self.list) self.fanart_tv_headers = {'api-key': 'ZDY5NTRkYTk2Yzg4ODFlMzdjY2RkMmQyNTlmYjk1MzQ='.decode('base64')} if not self.fanart_tv_user == '': self.fanart_tv_headers.update({'client-key': self.fanart_tv_user}) for i in range(0, total): self.list[i].update({'metacache': False}) self.list = metacache.fetch(self.list, self.lang, self.user) for r in range(0, total, 40): threads = [] for i in range(r, r+40): if i <= total: threads.append(workers.Thread(self.super_info, i)) [i.start() for i in threads] [i.join() for i in threads] if self.meta: metacache.insert(self.meta) self.list = [i for i in self.list if not i['imdb'] == '0'] self.list = metacache.local(self.list, self.tm_img_link, 'poster3', 'fanart2') if self.fanart_tv_user == '': for i in self.list: i.update({'clearlogo': '0', 'clearart': '0'})
def worker(self, level=1): self.meta = [] total = len(self.list) self.fanart_tv_headers = {'api-key': 'db10619c97af83891690f4cfd7205d62'} if not self.fanart_tv_user == '': self.fanart_tv_headers.update({'client-key': self.fanart_tv_user}) for i in range(0, total): self.list[i].update({'metacache': False}) self.list = metacache.fetch(self.list, self.lang, self.user) for r in range(0, total, 40): threads = [] for i in range(r, r + 40): if i <= total: threads.append(workers.Thread(self.super_info, i)) [i.start() for i in threads] [i.join() for i in threads] if self.meta: metacache.insert(self.meta) self.list = [i for i in self.list if not i['imdb'] == '0'] self.list = metacache.local(self.list, self.tm_img_link, 'poster3', 'fanart2') if self.fanart_tv_user == '': for i in self.list: i.update({'clearlogo': '0', 'clearart': '0'})
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.lang) for r in range(0, total, 40): threads = [] for i in range(r, r + 40): 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) self.list = [i for i in self.list]
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.lang) for r in range(0, total, 40): threads = [] for i in range(r, r+40): if i <= total: threads.append(workers.Thread(self.super_info, i)) [i.start() for i in threads] [i.join() for i in threads] self.list = [i for i in self.list if not i['imdb'] == '0'] if len(self.meta) > 0: metacache.insert(self.meta)
def worker(self, level=1): self.meta = [] total = len(self.list) self.fanart_tv_headers = {'api-key': 'YTc2MGMyMTEzYTM1OTk5NzFiN2FjMWU0OWUzMTAyMGQ='.decode('base64')} if not self.fanart_tv_user == '': self.fanart_tv_headers.update({'client-key': self.fanart_tv_user}) for i in range(0, total): self.list[i].update({'metacache': False}) self.list = metacache.fetch(self.list, self.lang, self.user) self.list = [i for i in self.list if not i['imdb'] == '0'] self.list = metacache.local(self.list, self.tm_img_link, 'poster3', 'fanart2') if self.fanart_tv_user == '': for i in self.list: i.update({'clearlogo': '0', 'clearart': '0'})
def worker(self, level=1): self.meta = [] total = len(self.boxset_list) for i in range(0, total): self.boxset_list[i].update({'metacache': False}) self.boxset_list = metacache.fetch(self.boxset_list, 'en') for r in range(0, total, 100): threads = [] for i in range(r, r + 100): if i <= total: threads.append(workers.Thread(self.super_info, i)) [i.start() for i in threads] [i.join() for i in threads] self.boxset_list = [i for i in self.boxset_list] if len(self.meta) > 0: metacache.insert(self.meta)
def get(self): channels = [('01', 'Sky Premiere', '77'), ('02', 'Sky Classics', '69'), ('03', 'Sky Greats', '76'), ('04', 'Sky Family', '72'), ('05', 'Sky Action', '68'), ('06', 'Sky Comedy', '70'), ('07', 'Sky Drama', '71'), ('08', 'Sky Sci Fi', '78'), ('09', 'Sky Indie', '75'), ('10', 'Film4', '43'), ('11', 'TCM', '89')] for i in channels: dt = datetime.datetime.now() if dt.time() < datetime.time(12): when = 'am' else: when = 'pm' content = self.getContent('http://tv.fopii.com/tvlisting%s.html' % i[2]) onnow = re.findall('<span class="txts">%s</span></td><td width="100%s">(.*?)</td>' % (when, '%'), content,re.MULTILINE | re.DOTALL) try: if '<a' in onnow[-1]: title = onnow[-2].encode('utf-8') else: title = onnow[-1].encode('utf-8') except: title = ' No Data' self.list.append({'title': title, 'channel': i[1], 'year': '0', 'genre': '0', 'duration': '0', 'rating': '0', 'votes': '0', 'mpaa': '0', 'director': '0', 'writer': '0', 'cast': '0', 'plot': '0', 'tagline': '0', 'code': title, 'imdb': title, 'tmdb': '0', 'poster': '0'}) 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.lang) for r in range(0, total, 40): threads = [] for i in range(r, r+40): if i <= total: threads.append(workers.Thread(self.items_list, i)) [i.start() for i in threads] [i.join() for i in threads] self.list = [i for i in self.list if not i['imdb'] == '0'] if len(self.meta) > 0: metacache.insert(self.meta) self.channelDirectory(self.list) return self.list
def tmdb_list(self, url): try: result = get_request(url % API_key) items = result['results'] except: return list = [] sortList = [] try: page = int(result['page']) total = int(result['total_pages']) if page >= total: raise Exception() if 'page=' not in url: raise Exception() next = '%s&page=%s' % (url.split('&page=', 1)[0], page + 1) except: next = '' for item in items: try: title = (item.get('title')).encode('utf-8') except: title = item.get('title') try: originaltitle = (item.get('original_title')).encode('utf-8') except: originaltitle = title year = str(item.get('release_date')[:4]) tmdb = item.get('id') sortList.append(tmdb) poster = '%s%s' % (poster_path, item['poster_path'] ) if item['poster_path'] else '0' fanart = '%s%s' % (fanart_path, item['backdrop_path'] ) if item['backdrop_path'] else '0' premiered = item.get('release_date') rating = str(item.get('vote_average', '0')) votes = str(format(int(item.get('vote_count', '0')), ',d')) plot = item.get('overview') try: tagline = item.get('tagline', '0') if tagline == '' or tagline == '0' or tagline is None: tagline = re.compile('[.!?][\s]{1,2}(?=[A-Z])').split( plot)[0] except: tagline = '0' values = { 'next': next, 'title': title, 'originaltitle': originaltitle, 'year': year, 'tmdb': tmdb, 'poster': poster, 'fanart': fanart, 'premiered': premiered, 'rating': rating, 'votes': votes, 'plot': plot, 'tagline': tagline, 'metacache': False } self.list.append(values) def items_list(i): if i['metacache'] is True: return try: next, title, originaltitle, year, tmdb, poster, fanart, premiered, rating, votes, plot, tagline = i[ 'next'], i['title'], i['originaltitle'], i['year'], i[ 'tmdb'], i['poster'], i['fanart'], i['premiered'], i[ 'rating'], i['votes'], i['plot'], i['tagline'] url = self.tmdb_info_link % tmdb item = get_request(url) imdb = item.get('imdb_id', '0') if imdb == '' or imdb is None or imdb == 'None': imdb = '0' # try: # studio = item.get('production_companies', None)[0]['name'] # except: # studio = '0' genre = [] for x in item['genres']: genre.append(x.get('name')) if genre == []: genre = 'NA' duration = str(item.get('runtime', '0')) mpaa = item['release_dates']['results'] mpaa = [x for x in mpaa if x['iso_3166_1'] == 'US'] try: mpaa = mpaa[0].get('release_dates')[-1].get( 'certification') if not mpaa: mpaa = mpaa[0].get('release_dates')[0].get( 'certification') if not mpaa: mpaa = mpaa[0].get('release_dates')[1].get( 'certification') mpaa = str(mpaa) except: mpaa = '0' credits = item['credits'] director = writer = '0' for person in credits['crew']: if 'Director' in person['job']: director = ', '.join([ director['name'].encode('utf-8') for director in credits['crew'] if director['job'].lower() == 'director' ]) if person['job'] in [ 'Writer', 'Screenplay', 'Author', 'Novel' ]: writer = ', '.join([ writer['name'].encode('utf-8') for writer in credits['crew'] if writer['job'].lower() in ['writer', 'screenplay', 'author', 'novel'] ]) castandart = [] for person in item['credits']['cast']: try: try: castandart.append({ 'name': person['name'].encode('utf-8'), 'role': person['character'].encode('utf-8'), 'thumbnail': ((poster_path + person.get('profile_path')) if person.get('profile_path') is not None else '0') }) except: castandart.append({ 'name': person['name'], 'role': person['character'], 'thumbnail': ((poster_path + person.get('profile_path')) if person.get('profile_path') is not None else '0') }) except: castandart = [] if len(castandart) == 150: break try: trailer = [ i for i in item['videos']['results'] if i['site'] == 'YouTube' ][0]['key'] trailer = control.trailer % trailer except: trailer = '' values = { 'content': 'movie', 'title': title, 'originaltitle': originaltitle, 'year': year, 'premiered': premiered, 'genre': genre, 'duration': duration, 'rating': rating, 'votes': votes, 'mpaa': mpaa, 'director': director, 'writer': writer, 'castandart': castandart, 'plot': plot, 'tagline': tagline, 'code': tmdb, 'imdb': imdb, 'tmdb': tmdb, 'tvdb': '0', 'poster': poster, 'poster2': '0', 'poster3': '0', 'banner': '0', 'fanart': fanart, 'fanart2': '0', 'fanart3': '0', 'clearlogo': '0', 'clearart': '0', 'landscape': fanart, 'trailer': trailer, 'metacache': False, 'next': next } meta = { 'imdb': imdb, 'tmdb': tmdb, 'tvdb': '0', 'lang': self.lang, 'user': API_key, 'item': values } if disable_fanarttv != 'true': from resources.lib.indexers import fanarttv extended_art = cache.get(fanarttv.get_movie_art, 168, imdb, tmdb) if extended_art is not None: values.update(extended_art) meta.update(values) values = dict( (k, v) for k, v in values.iteritems() if v != '0') for i in range(0, len(self.list)): if str(self.list[i]['tmdb']) == str(tmdb): self.list[i].update(values) if 'next' in meta.get('item'): del meta['item']['next'] self.meta.append(meta) metacache.insert(self.meta) except: log_utils.error() pass self.list = metacache.fetch(self.list, self.lang, API_key) items = self.list[:len(self.list)] threads = [] for i in items: threads.append(workers.Thread(items_list, i)) [i.start() for i in threads] [i.join() for i in threads] sorted_list = [] for i in sortList: sorted_list += [ item for item in self.list if str(item['tmdb']) == str(i) ] return sorted_list
def play_source(self, title, year, season, episode, imdb, tvdb, url, meta, select=None): try: if url is None: control.cancelPlayback() raise Exception control.sleep(200) self.media_type = 'movie' if season is None or episode is None else 'episode' self.title = title self.year = str(year) if self.media_type == 'movie': self.name = quote_plus(title) + quote_plus(' (%s)' % self.year) self.season = None self.episode = None elif self.media_type == 'episode': self.name = quote_plus(title) + quote_plus( ' S%02dE%02d' % (int(season), int(episode))) self.season = '%01d' % int(season) self.episode = '%01d' % int(episode) self.name = unquote_plus( self.name) # this looks dumb, quote to only unquote? self.DBID = None self.imdb = imdb if imdb is not None else '0' self.tvdb = tvdb if tvdb is not None else '0' self.ids = {'imdb': self.imdb, 'tvdb': self.tvdb} self.ids = dict( (k, v) for k, v in self.ids.iteritems() if v != '0') self.meta = meta self.offset = Bookmarks().get(self.name, self.year) item = control.item(path=url) ## - compare meta received to database and use largest(eventually switch to a request to fetch missing db meta for item) self.imdb_user = control.setting('imdb.user').replace('ur', '') self.tmdb_key = control.setting('tm.user') if self.tmdb_key == '' or self.tmdb_key is None: self.tmdb_key = '3320855e65a9758297fec4f7c9717698' self.tvdb_key = 'N1I4U1paWDkwVUE5WU1CVQ==' if self.media_type == 'episode': self.user = str(self.imdb_user) + str(self.tvdb_key) else: self.user = str(self.tmdb_key) self.lang = control.apiLanguage()['tvdb'] items = [{ 'imdb': imdb, 'tvdb': tvdb }] # need to add tmdb but it's not passed as of now items_ck = copy.deepcopy(items) meta1 = meta meta2 = metacache.fetch(items, self.lang, self.user)[0] if meta1 is not None: if len(meta2) > len(meta1): meta = meta2 else: meta = meta1 else: meta = meta2 if meta2 != items_ck[0] else meta1 ################## poster, thumb, season_poster, fanart, banner, clearart, clearlogo, discart, meta = self.getMeta( meta) if self.media_type == 'episode': self.episodeIDS = meta.get('episodeIDS', '0') item.setUniqueIDs(self.episodeIDS) if control.setting('disable.player.art') == 'true': item.setArt({ 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart }) else: item.setArt({ 'tvshow.clearart': clearart, 'tvshow.clearlogo': clearlogo, 'tvshow.discart': discart, 'thumb': thumb, 'tvshow.poster': season_poster, 'season.poster': season_poster, 'tvshow.fanart': fanart }) else: item.setUniqueIDs(self.ids) if control.setting('disable.player.art') == 'true': item.setArt({ 'thumb': thumb, 'poster': poster, 'fanart': fanart }) else: item.setArt({ 'clearart': clearart, 'clearlogo': clearlogo, 'discart': discart, 'thumb': thumb, 'poster': poster, 'fanart': fanart }) if 'castandart' in meta: item.setCast(meta.get('castandart', '')) item.setInfo(type='video', infoLabels=control.metadataClean(meta)) if 'plugin' not in control.infoLabel( 'Container.PluginName') or select != '1': if control.window.getProperty('infodialogs.active'): control.closeAll() control.resolve(syshandle, True, item) elif select == '1': control.closeAll() control.player.play(url, item) self.keepAlive() control.window.setProperty('script.trakt.ids', json.dumps(self.ids)) control.window.clearProperty('script.trakt.ids') except: log_utils.error() return control.cancelPlayback()