def discover_list(item): import datetime itemlist = [] year = 0 if item.discovery and not item.discovery.get("language", ""): item.discovery["language"] = def_lang tmdb_inf = tmdb.discovery(item, dict_=item.discovery, cast=item.cast_) result = tmdb_inf.results tvshow = False for elem in result: elem = tmdb_inf.get_infoLabels(elem, origen=elem) if 'title' in elem: title = unify.normalize(elem['title']).capitalize() else: title = unify.normalize(elem['name']).capitalize() tvshow = True elem['tmdb_id'] = elem['id'] mode = item.mode or elem['media_type'] thumbnail = elem.get('thumbnail', '') fanart = elem.get('fanart', '') if item.cast_: release = elem.get('release_date', '0000') or elem.get('first_air_date', '0000') year = scrapertools.find_single_match(release, r'(\d{4})') if not item.cast_ or (item.cast_ and (int(year) <= int(datetime.datetime.today().year))): new_item = Item(channel='search', title=title, infoLabels=elem, action='channel_search', text=title, thumbnail=thumbnail, fanart=fanart, context='', mode=mode, release_date=year) if tvshow: new_item.contentSerieName = title else: new_item.contentTitle = title itemlist.append(new_item) itemlist = set_context(itemlist) if item.cast_: itemlist.sort(key=lambda it: int(it.release_date), reverse=True) return itemlist elif len(result) > 19 and item.discovery: item.discovery['page'] = str(int(item.discovery['page']) + 1) itemlist.append(Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70065), list_type=item.list_type, discovery=item.discovery, mode=item.mode, text_color='gold')) elif len(result) > 19: next_page = str(int(item.page) + 1) itemlist.append(Item(channel=item.channel, action='discover_list', title=config.get_localized_string(70065), list_type=item.list_type, search_type=item.search_type, mode=item.mode, page=next_page, text_color='gold')) return itemlist
def discover_list(item): from platformcode import unify from core import scrapertools itemlist = [] result = tmdb.discovery(item) tvshow = False logger.debug(item) for elem in result: elem['tmdb_id'] = elem['id'] if 'title' in elem: title = unify.normalize(elem['title']).capitalize() elem['year'] = scrapertools.find_single_match( elem['release_date'], '(\d{4})-\d+-\d+') else: title = unify.normalize(elem['name']).capitalize() tvshow = True new_item = Item(channel='searchall', title=title, infoLabels=elem, action='search_tmdb', extra=title, category='Resultados', context='') if tvshow: new_item.contentSerieName = title else: new_item.contentTitle = title itemlist.append(new_item) tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True) if item.page != '' and len(itemlist) > 0: next_page = str(int(item.page) + 1) # if not 'similar' in item.list_type: # itemlist.append(item.clone(title='Pagina Siguente', page=next_page)) # else: itemlist.append( Item(channel=item.channel, action='discover_list', title=config.get_localized_string(30992), text_color="orange", search_type=item.search_type, list_type=item.list_type, type=item.type, page=next_page)) return itemlist
def actor_list(item): itemlist = [] dict_ = {'url': 'search/person', 'language': def_lang, 'query': item.searched_text, 'page': item.page} prof = {'Acting': 'Actor', 'Directing': 'Director', 'Production': 'Productor'} plot = '' item.search_type = 'person' tmdb_inf = tmdb.discovery(item, dict_=dict_) results = tmdb_inf.results if not results: return results for elem in results: name = elem.get('name', '') if not name: continue rol = elem.get('known_for_department', '') rol = prof.get(rol, rol) # genero = elem.get('gender', 0) # if genero == 1 and rol in prof: # rol += 'a' # rol = rol.replace('Actora', 'Actriz') know_for = elem.get('known_for', '') cast_id = elem.get('id', '') if know_for: t_k = know_for[0].get('title', '') if t_k: plot = '%s in %s' % (rol, t_k) thumbnail = 'https://image.tmdb.org/t/p/original%s' % elem.get('profile_path', '') title = typo(name,'bold')+typo(rol,'_ [] color kod bold') discovery = {'url': 'person/%s/combined_credits' % cast_id, 'page': '1', 'sort_by': 'primary_release_date.desc', 'language': def_lang} itemlist.append(Item(channel=item.channel, title=title, action='discover_list', cast_='cast', discovery=discovery, thumbnail=thumbnail, plot=plot, page=1)) if len(results) > 19: next_ = item.page + 1 itemlist.append(Item(channel=item.channel, title=typo(config.get_localized_string(30992),'bold color kod'), action='actor_list', page=next_, thumbnail=thumbnail, searched_text=item.searched_text)) return itemlist
def filter_thread(filter, key, item, description): thumbnail = plot = fanart = '' if item.filterkey in ['actors', 'director']: dict_ = { 'url': 'search/person', 'language': lang, 'query': filter, 'page': 1 } tmdb_inf = tmdb.discovery(item, dict_=dict_) id = None if tmdb_inf.results: results = tmdb_inf.results[0] id = results['id'] if id: thumbnail = 'https://image.tmdb.org/t/p/original' + results[ 'profile_path'] if results['profile_path'] else item.thumbnail json_file = httptools.downloadpage( 'http://api.themoviedb.org/3/person/' + str(id) + '?api_key=' + tmdb_api + '&language=en', use_requests=True).data plot += jsontools.load(json_file)['biography'] if description: if filter in description: extra = set_extra_values(item, description[filter], item.path) thumbnail = extra.thumb if extra.thumb else item.thumbnail fanart = extra.fanart if extra.fanart else item.fanart plot = extra.plot if extra.plot else item.plot item = Item(channel=item.channel, title=support.typo(filter, 'bold'), url=item.url, media_type=item.media_type, action='peliculas', thumbnail=thumbnail if thumbnail else item.thumbnail, fanart=fanart if fanart else item.fanart, plot=plot if plot else item.plot, path=item.path, filterkey=item.filterkey, filter=filter, sort=item.sort, key=key) if item.filterkey in ['genre']: support.thumb(item) return item
def actor_list(item): itemlist = [] dict_ = { 'url': 'search/person', 'language': 'es', 'query': item.searched_text, 'page': item.page } prof = { 'Acting': 'Actor', 'Directing': 'Director', 'Production': 'Productor' } plot = '' item.search_type = 'person' tmdb_inf = tmdb.discovery(item, dict_=dict_) results = tmdb_inf.results if not results: return results for elem in results: name = elem.get('name', '') if not name: continue rol = elem.get('known_for_department', '') rol = prof.get(rol, rol) genero = elem.get('gender', 0) if genero == 1 and rol in prof: rol += 'a' rol = rol.replace('Actora', 'Actriz') know_for = elem.get('known_for', '') cast_id = elem.get('id', '') if know_for: t_k = know_for[0].get('title', '') if t_k: plot = '%s en [COLOR limegreen]%s[/COLOR] y otras' % (rol, t_k) thumbnail = 'http://image.tmdb.org/t/p/original%s' % elem.get( 'profile_path', '') title = '%s [COLOR grey](%s)[/COLOR]' % (name, rol) discovery = { 'url': 'person/%s/combined_credits' % cast_id, 'page': '1', 'sort_by': 'primary_release_date.desc', 'language': 'es' } itemlist.append( Item(channel=item.channel, title=title, action='discover_list', cast_='cast', discovery=discovery, thumbnail=thumbnail, plot=plot, page=1)) if len(results) > 19: next_ = item.page + 1 itemlist.append( Item(channel=item.channel, title="Pagina Siguiente >>", action='actor_list', page=next_, thumbnail=thumbnail, text_color='gold', searched_text=item.searched_text)) return itemlist