def get_cast(info): cast_list = [] actors_list = [] Type = "movie" if info.getProperty('mediatype') == 'movie' else 'tv' otmdb = tmdb.Tmdb(id_Tmdb=info.getProperty('tmdb_id'), tipo=Type) actors = otmdb.result.get("credits", {}).get("cast", []) cast = otmdb.result.get("credits", {}).get("crew", []) if Type == 'movie' else otmdb.result.get("created_by", []) for i, crew in enumerate(cast): if crew.get('job', '') == 'Director' or Type!= "movie": actors.insert(0, crew) else: res = xbmcgui.ListItem(crew.get('name', '')) res.setProperties({'title': crew.get('name', ''), 'job': crew.get('job', '') if crew.get('job', '') else crew.get('character',''), 'thumbnail': "https://image.tmdb.org/t/p/w342" + crew.get('profile_path', '') if crew.get('profile_path', '') else '', 'department': crew.get('department', ''), 'type': Type, 'id': crew.get('id', ''), 'mediatype': info.getProperty('mediatype')}) cast_list.append(res) for actor in actors: res = xbmcgui.ListItem(actor.get('name', '')) res.setProperties({'title': actor.get('name', ''), 'job': actor.get('job', '') if actor.get('job', '') else actor.get('character',''), 'thumbnail': "https://image.tmdb.org/t/p/w342" + actor.get('profile_path', '') if actor.get('profile_path', '') else imagepath('no_photo'), 'type': Type, 'id': actor.get('id', ''), 'mediatype': info.getProperty('mediatype')}) actors_list.append(res) return cast_list, actors_list
def new_search(item): logger.info() itemlist = [] last_search = channeltools.get_channel_setting('Last_searched', 'search', '') searched_text = platformtools.dialog_input(default=last_search, heading='Alfa (Busqueda)') if not searched_text: return channeltools.set_channel_setting('Last_searched', searched_text, 'search') searched_text = searched_text.replace("+", " ") if item.mode == 'person': item.searched_text = searched_text return actor_list(item) if item.mode != 'all': tmdb_info = tmdb.Tmdb(texto_buscado=searched_text, tipo=item.mode.replace('show', '')) results = tmdb_info.results for result in results: result = tmdb_info.get_infoLabels(result, origen=result) if item.mode == 'movie': title = result['title'] else: title = result['name'] item.mode = 'tvshow' thumbnail = result.get('thumbnail', '') fanart = result.get('fanart', '') new_item = Item(channel=item.channel, action='channel_search', title=title, text=searched_text, thumbnail=thumbnail, fanart=fanart, mode=item.mode, infoLabels=result) if item.mode == 'movie': new_item.contentTitle = result['title'] else: new_item.contentSerieName = result['name'] itemlist.append(new_item) if item.mode == 'all' or not itemlist: itemlist = channel_search( Item(channel=item.channel, title=searched_text, text=searched_text, mode='all', infoLabels={})) return itemlist
def onClick(self, control_id): setFocus(self) title = self.getControl(RECOMANDED).getSelectedItem().getProperty('title') mode = self.getControl(RECOMANDED).getSelectedItem().getProperty('mediatype') if control_id in [SEARCH]: self.close() if self.getControl(RECOMANDED).getSelectedPosition() > 0: Search(ITEM.clone(action='search', search_text=title)) else: Search(ITEM.clone(channel='search', action='new_search', search_text=title, mode=mode)) elif control_id in [TRAILER]: info = self.getControl(RECOMANDED).getSelectedItem() self.close() Trailer(info) elif control_id in [IMAGES]: info = self.getControl(RECOMANDED).getSelectedItem() images = tmdb.Tmdb(id_Tmdb=info.getProperty('tmdb_id'), tipo='movie' if mode == 'movie' else 'tv').result.get("images", {}) for key, value in list(images.items()): if not value: images.pop(key) ImagesWindow(tmdb = images).doModal() elif control_id in [ACTORS, CAST]: self.close() Main(self.getControl(self.getFocusId()).getSelectedItem()) elif control_id in [RECOMANDED] and self.getControl(RECOMANDED).getSelectedPosition() > 0: self.close() Main(self.getControl(RECOMANDED).getSelectedItem())
def Trailer(info): global info_list, trailers trailers = [] trailers_list = [] Type = info.getProperty('mediatype') if Type != "movie": Type = "tv" trailers_list = tmdb.Tmdb(id_Tmdb=info.getProperty('tmdb_id'), tipo=Type).get_videos() if trailers_list: for i, trailer in enumerate(trailers_list): item = xbmcgui.ListItem(trailer['name']) item.setProperties({'tile':trailer['name'], 'url': trailer['url'], 'thumbnail': 'http://img.youtube.com/vi/' + trailer['url'].split('=')[-1] + '/0.jpg', 'fanart':info.getProperty('fanart'), 'position':'%s/%s' % (i + 1, len(trailers_list))}) trailers.append(item) else: # TRY youtube search patron = r'thumbnails":\[\{"url":"(https://i.ytimg.com/vi[^"]+).*?' patron += r'text":"([^"]+).*?' patron += r'simpleText":"[^"]+.*?simpleText":"([^"]+).*?' patron += r'url":"([^"]+)' matches = support.match('https://www.youtube.com/results?search_query=' + info.getProperty('title').replace(' ','+') + '+trailer+ita', patron = patron).matches i = 0 for thumb, title, text, url in matches: i += 1 item = xbmcgui.ListItem(title + ' - '+ text) item.setProperties({'tile':title + ' - '+ text, 'url': url, 'thumbnail': thumb, 'fanart':info.getProperty('fanart'), 'position':'%s/%s' % (i, len(matches))}) trailers.append(item) main = TrailerWindow('TrailerWindow.xml', config.get_runtime_path()) add({'class':main, 'info':trailers, 'id':RECOMANDED, TRAILERS:0}) modal()
def get_recomendations(info): recommendations = [info] Type = info.getProperty('mediatype') if Type != "movie": Type = "tv" search = {'url': '%s/%s/recommendations' % (Type, info.getProperty('tmdb_id')), 'language': 'it', 'page': 1} tmdb_res = tmdb.Tmdb(discover=search, tipo=Type, idioma_Search='it').results for result in tmdb_res: if Type == 'movie': title = result.get("title", '') original_title = result.get("original_title", "") else: title = result.get("name", '') original_title = result.get("original_name", '') thumbnail ='https://image.tmdb.org/t/p/w342' + result.get("poster_path", "") if result.get("poster_path", "") else '' fanart = 'https://image.tmdb.org/t/p/original' + result.get("backdrop_path", "") if result.get("backdrop_path", "") else '' item = xbmcgui.ListItem(title) item.setProperties({'title': title, 'original_title': original_title, 'mediatype': info.getProperty('mediatype'), 'tmdb_id': result.get('id', 0), 'imdb_id': info.getProperty('imdb_id'), 'rating': result.get('vote_average', 0), 'plot': result.get('overview', ''), 'year': result.get('release_date', '').split('-')[0], 'thumbnail': thumbnail, 'fanart': fanart}) recommendations.append(item) return recommendations
def get_movies(info): Type = info.getProperty('mediatype') if info.getProperty( 'mediatype') == 'movie' else 'tv' more = tmdb.Tmdb( discover={ 'url': 'person/' + str(info.getProperty('id')), 'language': 'it', 'append_to_response': Type + '_credits' }).results movies = [] for movie in more.get(Type + '_credits', {}).get('cast', []) + more.get( Type + '_credits', {}).get('crew', []): ret = {} ret['mediatype'] = info.getProperty('mediatype') thumbnail = movie.get('poster_path', '') ret['thumbnail'] = "https://image.tmdb.org/t/p/w342" + thumbnail if thumbnail else imagepath( Type) ret['title'] = movie.get( 'title', '') if Type == 'movie' else movie.get('name', '') ret['original_title'] = movie.get( 'original_title', '') if Type == 'movie' else movie.get( "original_name", '') ret['tmdb_id'] = movie.get('id', 0) if ret not in movies: movies.append(ret) itemlist = [] with futures.ThreadPoolExecutor() as executor: List = [executor.submit(add_infoLabels, movie) for movie in movies] for res in futures.as_completed(List): if res.result(): itemlist.append(res.result()) itemlist = sorted(itemlist, key=lambda it: (it.getProperty('year'), it.getProperty('title'))) return itemlist
def actors_more_info(ListItem): Type = ListItem.getProperty('type') actor_id = ListItem.getProperty('id') more = tmdb.Tmdb(discover={ 'url': 'person/' + str(actor_id), 'language': 'en' }).results if more['biography']: ListItem.setProperty('bio', more['biography'])
def get_art(item): logger.info() id = item.infoLabels['tmdb_id'] check_fanart = item.infoLabels['fanart'] if item.contentType != "movie": tipo_ps = "tv" else: tipo_ps = "movie" if not id: year = item.extra otmdb = tmdb.Tmdb(texto_buscado=item.fulltitle, year=year, tipo=tipo_ps) id = otmdb.result.get("id") if id == None: otmdb = tmdb.Tmdb(texto_buscado=item.fulltitle, tipo=tipo_ps) id = otmdb.result.get("id") if id == None: if item.contentType == "movie": urlbing_imdb = "http://www.bing.com/search?q=%s+%s+tv+series+site:imdb.com" % ( item.fulltitle.replace(' ', '+'), year) data = browser(urlbing_imdb) data = re.sub( r"\n|\r|\t|\s{2}| |http://ssl-proxy.my-addr.org/myaddrproxy.php/", "", data) subdata_imdb = scrapertools.find_single_match( data, '<li class="b_algo">(.*?)h="ID.*?<strong>.*?TV Series') else: urlbing_imdb = "http://www.bing.com/search?q=%s+%s+site:imdb.com" % ( item.fulltitle.replace(' ', '+'), year) data = browser(urlbing_imdb) data = re.sub( r"\n|\r|\t|\s{2}| |http://ssl-proxy.my-addr.org/myaddrproxy.php/", "", data) subdata_imdb = scrapertools.find_single_match( data, '<li class="b_algo">(.*?)h="ID.*?<strong>') try: imdb_id = scrapertools.get_match( subdata_imdb, '<a href=.*?http.*?imdb.com/title/(.*?)/.*?"') except: try: imdb_id = scrapertools.get_match( subdata_imdb, '<a href=.*?http.*?imdb.com/.*?/title/(.*?)/.*?"') except: imdb_id = "" otmdb = tmdb.Tmdb(external_id=imdb_id, external_source="imdb_id", tipo=tipo_ps, idioma_busqueda="es") id = otmdb.result.get("id") if id == None: if "(" in item.fulltitle: title = scrapertools.find_single_match( item.fulltitle, '\(.*?\)') if item.contentType != "movie": urlbing_imdb = "http://www.bing.com/search?q=%s+%s+tv+series+site:imdb.com" % ( title.replace(' ', '+'), year) data = browser(urlbing_imdb) data = re.sub( r"\n|\r|\t|\s{2}| |http://ssl-proxy.my-addr.org/myaddrproxy.php/", "", data) subdata_imdb = scrapertools.find_single_match( data, '<li class="b_algo">(.*?)h="ID.*?<strong>.*?TV Series' ) else: urlbing_imdb = "http://www.bing.com/search?q=%s+%s+site:imdb.com" % ( title.replace(' ', '+'), year) data = browser(urlbing_imdb) data = re.sub( r"\n|\r|\t|\s{2}| |http://ssl-proxy.my-addr.org/myaddrproxy.php/", "", data) subdata_imdb = scrapertools.find_single_match( data, '<li class="b_algo">(.*?)h="ID.*?<strong>') try: imdb_id = scrapertools.get_match( subdata_imdb, '<a href=.*?http.*?imdb.com/title/(.*?)/.*?"') except: try: imdb_id = scrapertools.get_match( subdata_imdb, '<a href=.*?http.*?imdb.com/.*?/title/(.*?)/.*?"' ) except: imdb_id = "" otmdb = tmdb.Tmdb(external_id=imdb_id, external_source="imdb_id", tipo=tipo_ps, idioma_busqueda="es") id = otmdb.result.get("id") if not id: fanart = item.fanart id_tvdb = "" imagenes = [] itmdb = tmdb.Tmdb(id_Tmdb=id, tipo=tipo_ps) images = itmdb.result.get("images") if images: for key, value in images.iteritems(): for detail in value: imagenes.append('http://image.tmdb.org/t/p/original' + detail["file_path"]) if len(imagenes) >= 4: if imagenes[0] != check_fanart: item.fanart = imagenes[0] else: item.fanart = imagenes[1] if imagenes[1] != check_fanart and imagenes[ 1] != item.fanart and imagenes[2] != check_fanart: item.extra = imagenes[1] + "|" + imagenes[2] else: if imagenes[1] != check_fanart and imagenes[1] != item.fanart: item.extra = imagenes[1] + "|" + imagenes[3] elif imagenes[2] != check_fanart: item.extra = imagenes[2] + "|" + imagenes[3] else: item.extra = imagenes[3] + "|" + imagenes[3] elif len(imagenes) == 3: if imagenes[0] != check_fanart: item.fanart = imagenes[0] else: item.fanart = imagenes[1] if imagenes[1] != check_fanart and imagenes[ 1] != item.fanart and imagenes[2] != check_fanart: item.extra = imagenes[1] + "|" + imagenes[2] else: if imagenes[1] != check_fanart and imagenes[1] != item.fanart: item.extra = imagenes[0] + "|" + imagenes[1] elif imagenes[2] != check_fanart: item.extra = imagenes[1] + "|" + imagenes[2] else: item.extra = imagenes[1] + "|" + imagenes[1] elif len(imagenes) == 2: if imagenes[0] != check_fanart: item.fanart = imagenes[0] else: item.fanart = imagenes[1] if imagenes[1] != check_fanart and imagenes[1] != item.fanart: item.extra = imagenes[0] + "|" + imagenes[1] else: item.extra = imagenes[1] + "|" + imagenes[0] elif len(imagenes) == 1: item.extra = imagenes + "|" + imagenes else: item.extra = item.fanart + "|" + item.fanart images_fanarttv = fanartv(item, id_tvdb, id) if images_fanarttv: if item.contentType == "movie": if images_fanarttv.get("moviedisc"): item.thumbnail = images_fanarttv.get("moviedisc")[0].get("url") elif images_fanarttv.get("hdmovielogo"): item.thumbnail = images_fanarttv.get("hdmovielogo")[0].get( "url") elif images_fanarttv.get("moviethumb"): item.thumbnail = images_fanarttv.get("moviethumb")[0].get( "url") elif images_fanarttv.get("moviebanner"): item.thumbnail_ = images_fanarttv.get("moviebanner")[0].get( "url") else: item.thumbnail = item.thumbnail else: if images_fanarttv.get("hdtvlogo"): item.thumbnail = images_fanarttv.get("hdtvlogo")[0].get("url") elif images_fanarttv.get("clearlogo"): item.thumbnail = images_fanarttv.get("hdmovielogo")[0].get( "url") if images_fanarttv.get("tvbanner"): item.extra = item.extra + "|" + images_fanarttv.get( "tvbanner")[0].get("url") elif images_fanarttv.get("tvthumb"): item.extra = item.extra + "|" + images_fanarttv.get( "tvthumb")[0].get("url") else: item.extra = item.extra + "|" + item.thumbnail else: item.extra = item.extra + "|" + item.thumbnail
def new_search(item): logger.debug() temp_search_file = config.get_temp_file('temp-search') if filetools.isfile(temp_search_file): filetools.remove(temp_search_file) itemlist = [] if config.get_setting('last_search'): last_search = channeltools.get_channel_setting('Last_searched', 'search', '') else: last_search = '' if item.search_text: searched_text = item.search_text else: searched_text = platformtools.dialog_input(default=last_search, heading='') save_search(searched_text) if not searched_text: return channeltools.set_channel_setting('Last_searched', searched_text, 'search') searched_text = searched_text.replace("+", " ") if item.mode == 'person': item.searched_text = searched_text return actor_list(item) if item.mode != 'all': tmdb_info = tmdb.Tmdb(searched_text=searched_text, search_type=item.mode.replace('show', '')) results = tmdb_info.results for result in results: result = tmdb_info.get_infoLabels(result, origen=result) if item.mode == 'movie': title = result['title'] else: title = result['name'] item.mode = 'tvshow' thumbnail = result.get('thumbnail', '') fanart = result.get('fanart', '') new_item = Item(channel=item.channel, action='channel_search', title=title, text=searched_text, thumbnail=thumbnail, fanart=fanart, mode=item.mode, contentType=item.mode, infoLabels=result) if item.mode == 'movie': new_item.contentTitle = result['title'] else: new_item.contentSerieName = result['name'] itemlist.append(new_item) if item.mode == 'all' or not itemlist: return channel_search( Item(channel=item.channel, title=searched_text, text=searched_text, mode='all', infoLabels={})) return itemlist
def findvideos_series(item): logger.info() itemlist = [] fanart="" check_temp=[] data = httptools.downloadpage(item.url).data if item.contentType!="movie": itmdb = tmdb.Tmdb(id_Tmdb=item.extra.split("|")[3], tipo=item.extra.split("|")[8]) season= itmdb.result.get("seasons") check="no" try: temp,bloque_enlaces = scrapertools.find_single_match(data,'Temporada (\d+)(.*?)Temporada') except: if "no se agregaron" in data: temp=bloque_enlaces="" else: temp,bloque_enlaces = scrapertools.find_single_match(data,'Temporada (\d+)(.*?)<div class="enlaces">') if temp!="": thumbnail="" if season: for detail in season: if str(detail["season_number"])== temp: if detail["poster_path"]: thumbnail="https://image.tmdb.org/t/p/original" +detail["poster_path"] images_fanarttv= fanartv(item,item.extra.split("|")[5],item.extra.split("|")[3]) if images_fanarttv: season_f=images_fanarttv.get("showbackground") if season_f: for detail in season_f: if str(detail["season"])== temp: if detail["url"]: fanart = detail["url"] if fanart=="": fanart =item.extra.split("|")[0] if thumbnail=="": thumbnail=item.thumbnail itemlist.append( Item(channel=item.channel, title ="[COLOR darkturquoise]Temporada[/COLOR] "+"[COLOR beige]"+temp+"[/COLOR]" , url="", action="", thumbnail=thumbnail, fanart=fanart ,extra="",contentType=item.contentType, folder=False) ) capitulos =scrapertools.find_multiple_matches(bloque_enlaces,'href="([^"]+)".*?Episodio (\d+) - ([^<]+)') for url,epi,title in capitulos: if epi == "1" : if epi in str(check_temp): temp = int(temp)+ 1 thumbnail="" if season: for detail in season: if detail["season_number"]== temp: if detail["poster_path"]: thumbnail="https://image.tmdb.org/t/p/original" +detail["poster_path"] images_fanarttv= fanartv(item,item.extra.split("|")[5],item.extra.split("|")[3]) if images_fanarttv: season_f=images_fanarttv.get("showbackground") if season_f: for detail in season_f: if detail["season"]== temp: if detail["url"]: fanart = detail["url"] if fanart=="": fanart =item.extra.split("|")[0] if thumbnail=="": thumbnail=item.thumbnail itemlist.append( Item(channel=item.channel, title="[COLOR darkturquoise]Temporada[/COLOR] "+"[COLOR beige]"+str(temp)+"[/COLOR]" , url="", action="", thumbnail=thumbnail, fanart=fanart ,extra="",contentType=item.contentType, folder=False) ) check_temp.append([epi]) itemlist.append( Item(channel=item.channel, title =" [COLOR cyan]Episodio[/COLOR] "+"[COLOR darkcyan]"+epi+"[/COLOR]"+" - "+"[COLOR cadetblue]"+title+"[/COLOR]" , url=url, action="findvideos", thumbnail=item.extra.split("|")[4], fanart=item.extra.split("|")[0] ,extra="",contentType=item.contentType, folder=True) ) title_info =" Info" title_info = "[COLOR steelblue]"+title_info+"[/COLOR]" itemlist.append( Item(channel=item.channel, action="info_capitulos" , title=title_info , url=item.url, thumbnail=item.extra.split("|")[6], fanart=item.extra.split("|")[1], extra=item.extra+"|"+str(temp)+"|"+epi, folder=False )) return itemlist
def fanart(item): logger.info() itemlist = [] url = item.url data = httptools.downloadpage(item.url).data data = re.sub(r"\n|\r|\t|\s{2}| ","",data) year=item.extra.split("|")[2] if not year.isdigit(): try: year =scrapertools.find_single_match(data,'<span class="izq">[^<]+<\/span><span>(\d+)<') except: year="" if item.contentType!="movie": tipo_ps="tv" else: tipo_ps="movie" title = item.extra.split("|")[0] fulltitle= title if "El infiltrado" in title: title = "The Night Manager" title_o=scrapertools.find_single_match(data,'<meta name="description"[^<]+original(.*?)&') item.title = item.extra.split("|")[1] title_imdb=re.sub(r'\[.*?\]','',item.extra.split("|")[1]) title =re.sub(r"\(.*?\)|-Remastered|Black And Chrome Edition|V.extendida|Version Extendida|V.Extendida|HEVC|X\d+|x\d+|LINE|HD|1080p|Screeener|V.O|Hdrip|.*?--|3D|SBS|HOU","",title) sinopsis=scrapertools.find_single_match(data,'<div class="sinopsis".*?<\/h2>(.*?)<\/div>') if sinopsis=="": try: sinopsis=scrapertools.find_single_match(data,'sinopsis\'>(.*?)<\/div>') except: sinopsis="" if "Miniserie" in sinopsis: tipo_ps="tv" year= scrapertools.find_single_match(sinopsis,'de TV \((\d+)\)') if year=="": if item.contentType !="movie": try: year =scrapertools.find_single_match(data,'<strong>Estreno:<\/strong>(\d+)<\/span>') except: year="" else: year =scrapertools.find_single_match(data,'<br \/>A.*?(\d+)<br \/>') if year =="": try: year=scrapertools.find_single_match(data,'Estreno.*?\d+/\d+/(\d+)') except: try: year=scrapertools.find_single_match(data,'<div class=\'descripcion_top\'>.*?Año<br />.*?(\d\d\d\d)') except: try: year=scrapertools.find_single_match(data,'<meta name="description"[^<]+Año[^<]+\d\d\d\d') except: year="" infoLabels = {'title': title, 'sinopsis': sinopsis, 'year': year} critica, rating_filma, year_f,sinopsis_f = filmaffinity(item,infoLabels) if sinopsis=="": sinopsis = sinopsis_f if year=="": year = year_f otmdb = tmdb.Tmdb(texto_buscado=title, year=year,tipo=tipo_ps) id= otmdb.result.get("id") posterdb= otmdb.result.get("poster_path") if posterdb==None: otmdb = tmdb.Tmdb(texto_buscado=title,tipo=tipo_ps) id= otmdb.result.get("id") posterdb= otmdb.result.get("poster_path") if posterdb==None: if item.contentType!="movie": urlbing_imdb = "http://www.bing.com/search?q=%s+%s+tv+series+site:imdb.com" % (title_imdb.replace(' ', '+'), year) data = browser (urlbing_imdb) data = re.sub(r"\n|\r|\t|\s{2}| |http://ssl-proxy.my-addr.org/myaddrproxy.php/","",data) subdata_imdb =scrapertools.find_single_match(data,'<li class="b_algo">(.*?)h="ID.*?<strong>.*?TV Series') else: urlbing_imdb = "http://www.bing.com/search?q=%s+%s+site:imdb.com" % (title_imdb.replace(' ', '+'), year) data = browser (urlbing_imdb) data = re.sub(r"\n|\r|\t|\s{2}| |http://ssl-proxy.my-addr.org/myaddrproxy.php/","",data) subdata_imdb =scrapertools.find_single_match(data,'<li class="b_algo">(.*?)h="ID.*?<strong>') try: imdb_id = scrapertools.get_match(subdata_imdb,'<a href=.*?http.*?imdb.com/title/(.*?)/.*?"') except: try: imdb_id = scrapertools.get_match(subdata_imdb,'<a href=.*?http.*?imdb.com/.*?/title/(.*?)/.*?"') except: imdb_id="" otmdb = tmdb.Tmdb(external_id=imdb_id, external_source="imdb_id",tipo=tipo_ps,idioma_busqueda="es") id= otmdb.result.get("id") posterdb= otmdb.result.get("poster_path") if not posterdb : if "(" in title_imdb: title =scrapertools.find_single_match(title_imdb,'\(.*?\)') if item.contentType!="movie": urlbing_imdb = "http://www.bing.com/search?q=%s+%s+tv+series+site:imdb.com" % (title_imdb.replace(' ', '+'), year) data = browser (urlbing_imdb) data = re.sub(r"\n|\r|\t|\s{2}| |http://ssl-proxy.my-addr.org/myaddrproxy.php/","",data) subdata_imdb =scrapertools.find_single_match(data,'<li class="b_algo">(.*?)h="ID.*?<strong>.*?TV Series') else: urlbing_imdb = "http://www.bing.com/search?q=%s+%s+site:imdb.com" % (title_imdb.replace(' ', '+'), year) data = browser (urlbing_imdb) data = re.sub(r"\n|\r|\t|\s{2}| |http://ssl-proxy.my-addr.org/myaddrproxy.php/","",data) subdata_imdb =scrapertools.find_single_match(data,'<li class="b_algo">(.*?)h="ID.*?<strong>') try: imdb_id = scrapertools.get_match(subdata_imdb,'<a href=.*?http.*?imdb.com/title/(.*?)/.*?"') except: try: imdb_id = scrapertools.get_match(subdata_imdb,'<a href=.*?http.*?imdb.com/.*?/title/(.*?)/.*?"') except: imdb_id="" otmdb = tmdb.Tmdb(external_id=imdb_id, external_source="imdb_id",tipo=tipo_ps,idioma_busqueda="es") id= otmdb.result.get("id") posterdb= otmdb.result.get("poster_path") if not posterdb: id=tiw=rating=tagline=id_tvdb="" fanart_4=fanart_2=fanart_3= item.fanart rating="Sin Puntuación" posterdb=tvf=item.thumbnail fanart_info= item.fanart thumbnail_art=item.thumbnail extra = str(fanart_2)+"|"+str(fanart_3)+"|"+str(fanart_4)+"|"+str(id)+"|"+str(tvf)+"|"+str(id_tvdb)+"|"+str(tiw)+"|"+str(rating) if tipo_ps !="movie": action= "findvideos_series" else: action= "findvideos" itemlist.append( Item(channel=item.channel, title=item.title, url=item.url, action=action, thumbnail=item.thumbnail, fanart=item.fanart,extra=extra,folder=True) ) else: if tipo_ps !="movie": action= "findvideos_series" else: action= "findvideos" id=tiw=rating=tagline=id_tvdb="" fanart_4=fanart_2=fanart_3= item.fanart rating="Sin Puntuación" posterdb=tvf=item.thumbnail fanart_info= item.fanart thumbnail_art=item.thumbnail extra = str(fanart_2)+"|"+str(fanart_3)+"|"+str(fanart_4)+"|"+str(id)+"|"+str(tvf)+"|"+str(id_tvdb)+"|"+str(tiw)+"|"+str(rating) itemlist.append( Item(channel=item.channel, title=item.title, url=item.url, action=action, thumbnail=item.thumbnail, fanart=item.fanart,extra=extra,contentType=item.contentType, folder=True) ) if posterdb !=item.thumbnail: if not "null" in posterdb: posterdb= "https://image.tmdb.org/t/p/original"+posterdb else: posterdb= item.thumbnail if otmdb.result.get("backdrop_path"): fanart = "https://image.tmdb.org/t/p/original"+otmdb.result.get("backdrop_path") else: fanart = item.fanart if sinopsis == "": if otmdb.result.get("'overview'"): sinopsis= otmdb.result.get("'overview'") else: sinopsis="" if otmdb.result.get("vote_average"): rating= otmdb.result.get("vote_average") else: rating ="Sin puntuacíon" imagenes=[] itmdb = tmdb.Tmdb(id_Tmdb=id, tipo=tipo_ps) images = itmdb.result.get("images") for key, value in images.iteritems(): for detail in value: imagenes.append('https://image.tmdb.org/t/p/original' + detail["file_path"]) if item.contentType!="movie": if itmdb.result.get("number_of_seasons"): season_number= itmdb.result.get("number_of_seasons") else: season_episode="" if itmdb.result.get("number_of_episodes"): season_episode= itmdb.result.get("number_of_episodes") else: season_episode="" if itmdb.result.get("status"): status =itmdb.result.get("status") else: status="" if status== "Ended": status ="Finalizada" else: status = "En emisión" tagline =str( status ) +" (Temporadas:"+ str(season_number)+",Episodios:"+str(season_episode)+")" if itmdb.result.get("external_ids").get("tvdb_id"): id_tvdb = itmdb.result.get("external_ids").get("tvdb_id") else: id_tvdb= "" else: id_tvdb="" if itmdb.result.get("tagline"): tagline = itmdb.result.get("tagline") else: tagline = "" if len(imagenes)>= 5: fanart_info = imagenes[1] fanart_2 = imagenes[2] fanart_3 = imagenes[3] fanart_4 = imagenes[4] if fanart== item.fanart: fanart= fanart_info elif len(imagenes)== 4 : fanart_info = imagenes[1] fanart_2 = imagenes[2] fanart_3 = imagenes[3] fanart_4 = imagenes[1] if fanart== item.fanart: fanart= fanart_info elif len(imagenes)== 3: fanart_info = imagenes[1] fanart_2 = imagenes[2] fanart_3 = imagenes[1] fanart_4 = imagenes[0] if fanart== item.fanart: fanart= fanart_info elif len(imagenes)== 2: fanart_info = imagenes[1] fanart_2 = imagenes[0] fanart_3 = imagenes[1] fanart_4 = imagenes[1] if fanart== item.fanart: fanart= fanart_info else: fanart_info = fanart fanart_2 = fanart fanart_3 = fanart fanart_4 = fanart images_fanarttv= fanartv(item,id_tvdb,id) if item.contentType!="movie": url=item.url+"/episodios" action="findvideos_series" if images_fanarttv: try: thumbnail_art = images_fanarttv.get("hdtvlogo")[0].get("url") except: try: thumbnail_art= images_fanarttv.get("clearlogo")[0].get("url") except: thumbnail_art =posterdb if images_fanarttv.get("tvbanner"): tvf =images_fanarttv.get("tvbanner")[0].get("url") elif images_fanarttv.get("tvthumb"): tvf =images_fanarttv.get("tvthumb")[0].get("url") elif images_fanarttv.get("tvposter"): tvf =images_fanarttv.get("tvposter")[0].get("url") else: tvf =posterdb if images_fanarttv.get("tvthumb"): thumb_info =images_fanarttv.get("tvthumb")[0].get("url") else: thumb_info =thumbnail_art if images_fanarttv.get("hdclearart"): tiw= images_fanarttv.get("hdclearart")[0].get("url") elif images_fanarttv.get("characterart"): tiw=images_fanarttv.get("characterart")[0].get("url") elif images_fanarttv.get("hdtvlogo"): tiw=images_fanarttv.get("hdtvlogo")[0].get("url") else: tiw="" else: tiw="" tvf=thumbnail_info=thumbnail_art=posterdb else: url= item.url action="findvideos" if images_fanarttv: if images_fanarttv.get("hdmovielogo"): thumbnail_art=images_fanarttv.get("hdmovielogo")[0].get("url") elif images_fanarttv.get("moviethumb"): thumbnail_art=images_fanarttv.get("moviethumb")[0].get("url") elif images_fanarttv.get("moviebanner"): thumbnail_art=images_fanarttv.get("moviebanner")[0].get("url") else: thumbnail_art =posterdb if images_fanarttv.get("moviedisc"): tvf=images_fanarttv.get("moviedisc")[0].get("url") elif images_fanarttv.get("hdmovielogo"): tvf=images_fanarttv.get("hdmovielogo")[0].get("url") else: tvf =posterdb if images_fanarttv.get("hdmovieclearart"): tiw= images_fanarttv.get("hdmovieclearart")[0].get("url") elif images_fanarttv.get("hdmovielogo"): tiw=images_fanarttv.get("hdmovielogo")[0].get("url") else: tiw="" else: tiw="" tvf=thumbnail_art=posterdb extra = str(fanart_2)+"|"+str(fanart_3)+"|"+str(fanart_4)+"|"+str(id)+"|"+str(tvf)+"|"+str(id_tvdb)+"|"+str(tiw)+"|"+str(rating)+"|"+tipo_ps itemlist.append( Item(channel=item.channel, title=item.title, url=url, action=action, thumbnail=thumbnail_art, fanart=fanart,extra=extra,contentType=item.contentType,fulltitle=fulltitle,folder=True) ) title_info ="[COLOR powderblue][B]Info[/B][/COLOR]" extra= str(rating)+"|"+str(rating_filma)+"|"+str(id)+"|"+str(item.title)+"|"+str(id_tvdb)+"|"+str(tagline)+"|"+str(sinopsis)+"|"+str(critica)+"|"+str(thumbnail_art)+"|"+str(fanart_4) itemlist.append( Item(channel=item.channel, action="info" , title=title_info , url=item.url, thumbnail=posterdb, fanart=fanart_info,extra=extra,contentType=item.contentType, folder=False )) return itemlist
def makelist(self): self.epdict = {} self.group = self.renumberdict[self.title].get(GROUP, None) busy(True) itemlist = find_episodes(self.item) if not self.group: self.group = tmdb.get_nfo(self.item) if not self.group: busy(False) return # if 'episode_group' in self.group: # seasons =[] # groupedSeasons = tmdb.get_group(self.group.replace('\n','').split('/')[-1]) # for groupedSeason in groupedSeasons: # if groupedSeason['episodes'][0]['season_number'] > 0: # seasons.append({'season_number':groupedSeason['episodes'][0]['season_number'], 'episode_count':len(groupedSeason['episodes']), 'start_from':groupedSeason['episodes'][0]['episode_number']}) # else: seasons = tmdb.Tmdb(id_Tmdb=self.id).get_list_episodes() busy(False) count = 0 for season in seasons: s = season['season_number'] c = season['episode_count'] fe = season['start_from'] self.seasonsdict[str(s)] = c if s > 0: for e in range(1, c + 1): count += 1 self.epdict[count] = '{}x{:02d}'.format(s, e + fe - 1) if self.item.renumber or self.manual: self.item.renumber = False self.season, self.episode, self.manual, self.specials, Manual, Exit = SelectreNumeration(self, itemlist) if Exit: self.item.exit = True return if self.manual: self.episodes = Manual else: firstep = 0 if self.season > 1: for c in range(1, self.season): firstep += self.seasonsdict[str(c)] firstep += self.episode - 1 count = 0 if self.epdict: for item in itemlist: if not match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'[Ss]?(\d+)(?:x|_|\s+)[Ee]?[Pp]?(\d+)').match: # Otiene Numerazione Episodi scraped_ep = match(re.sub(r'\[[^\]]+\]','',item.title), patron=r'(\d+)').match if scraped_ep: episode = int(scraped_ep) if episode == 0: self.episodes[str(episode)] = '0x01' elif str(episode) in self.specials: self.episodes[str(episode)] = self.specials[str(episode)] count += 1 elif episode - count + firstep in self.epdict: self.episodes[str(episode)] = self.epdict[episode - count + firstep] else: self.episodes[str(episode)] = '0x{:02d}'.format(count + 1) count += 1 if self.episodes: self.renumberdict[self.title][EPISODES] = self.episodes if self.group: self.renumberdict[self.title][GROUP] = self.group self.renumberdict[self.title][MANUALMODE] = self.manual self.renumberdict[self.title][SEASON] = self.season self.renumberdict[self.title][EPISODE] = self.episode self.renumberdict[self.title][SPECIALEPISODES] = self.specials self.renumberdict[self.title][SEASONSDICT] = self.seasonsdict write(self.item, self.renumberdict)
def findvideos(item): logger.info() itemlist = [] fanart="" data = httptools.downloadpage(item.url).data if item.contentType!="movie": itmdb = tmdb.Tmdb(id_Tmdb=item.extra.split("|")[3], tipo=item.extra.split("|")[8]) season= itmdb.result.get("seasons") check="no" bloque_enlaces = scrapertools.find_single_match(data,'<ul class="buscar-list">(.*?)<\/ul><!-- end \.buscar-list -->') if check== "no": check_temp= scrapertools.find_single_match(bloque_enlaces,'Temporada (\d+)') if check_temp== "": check_temp = 1 if len(check_temp) == 1: try: check_temp= scrapertools.find_single_match(bloque_enlaces,'Temporada (\d+) Capitulos') check_temp=None except: pass thumbnail="" if season: for detail in season: if str(detail["season_number"])== check_temp: if detail["poster_path"]: thumbnail="https://image.tmdb.org/t/p/original" +detail["poster_path"] images_fanarttv= fanartv(item,item.extra.split("|")[5],item.extra.split("|")[3]) if images_fanarttv: season_f=images_fanarttv.get("showbackground") if season_f: for detail in season_f: if str(detail["season"])== check_temp: if detail["url"]: fanart = detail["url"] if fanart=="": fanart =item.extra.split("|")[0] if thumbnail=="": thumbnail=item.thumbnail if check_temp: itemlist.append( Item(channel=item.channel, title ="[COLOR red][B]Temporada "+check_temp+"[/B][/COLOR]" , url="", action="", thumbnail=thumbnail, fanart=fanart , folder=False) ) temp_bloque = scrapertools.find_multiple_matches(bloque_enlaces,'href="([^"]+).*?" title=".*?Temporada (\d+) Capitulo (\d+).*?Serie <strong style="color:red.*?:none">(.*?)<\/strong>.*?Calidad <span style="color:redbackground:none">(\[.*?\])<\/span>.*?<span>.*?<span>(.*?)<\/span>') if temp_bloque!="": for url,temp,capi,check_capi,calidad,peso in temp_bloque : if "Capitulos" in check_capi: extra=item.extra+"|"+check_capi+"|"+temp title =scrapertools.find_single_match(check_capi,'-.*?(Capitulos.*)') title =" [COLOR red][B]"+title+"[/B][/COLOR]" else: extra=item.extra+"|"+"Nocapi"+"|"+temp+"|"+capi title=" [COLOR red][B]Capítulo "+capi+"[/B][/COLOR]" if temp != check_temp: check_temp= temp check= "yes" for detail in season: if detail["season_number"]: if str(detail["season_number"])== temp: if detail["poster_path"]: thumbnail="https://image.tmdb.org/t/p/original" +detail["poster_path"] else: thumbnail="" else: thumbail="" if images_fanarttv: season_f=images_fanarttv.get("showbackground") if season_f: for detail in season_f: if str(detail["season"])== check_temp: if detail["season"]: fanart = detail["url"] if fanart=="": fanart =item.extra.split("|")[0] if thumbnail=="": thumbnail=item.thumbnail itemlist.append( Item(channel=item.channel, title ="[COLOR red][B]Temporada "+temp+"[/B][/COLOR]" , url="", action="", thumbnail=thumbnail, fanart=fanart , folder=False) ) itemlist.append( Item(channel=item.channel, title =title , url=url, action="findvideos_enlaces", thumbnail=thumbnail, fanart=item.extra.split("|")[0] ,extra=extra,contentType=item.contentType, folder=True) ) else: temp_bloque = scrapertools.find_multiple_matches(bloque_enlaces,'href="([^"]+).*?Temporada (\d+) Capitulo (\d+).*?Calidad.*?\[(.*?)\]<\/span>.*?<span>.*?<span>(.*?)<\/span>') for url,capi,calidad,peso in temp_bloque : itemlist.append( Item(channel=item.channel, title = " [COLOR red][B]Capítulo "+capi+"[/B][/COLOR]" , url="", action="findvideos_enlaces", thumbnail=item.extra.split("|")[4], fanart=item.extra.split("|")[0] , folder=True) ) ## Paginación next=scrapertools.find_single_match(data,'href="([^"]+)">Next<\/a>') if len(next)>0: url =next itemlist.append( Item(channel=item.channel, action="findvideos", title="[COLOR darkred][B]siguiente[/B][/COLOR]" , url=url , thumbnail="http://imgur.com/D4ZgFri.png", fanart=item.fanart,extra=item.extra,contentType=item.contentType, folder=True) ) return itemlist