# -*- coding: utf-8 -*- import os import re import urllib import urllib2 import urlparse from core import scrapertools from core.item import Item from platformcode import logger try: import xbmc import xbmcgui except: pass host = "http://bityouth.com/" def browser(url): import mechanize # Utilizamos Browser mechanize para saltar problemas con la busqueda en bing br = mechanize.Browser() # Browser options br.set_handle_equiv(False) br.set_handle_gzip(True) br.set_handle_redirect(True) br.set_handle_referer(False) br.set_handle_robots(False) # Follows refresh 0 but not hangs on refresh > 0 br.set_handle_refresh(mechanize._http.HTTPRefreshProcessor(), max_time=1) # Want debugging messages? # br.set_debug_http(True) # br.set_debug_redirects(True) # br.set_debug_responses(True) # User-Agent (this is cheating, ok?) br.addheaders = [('User-agent', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/600.7.12 (KHTML, like Gecko) Version/7.1.7 Safari/537.85.16')] # br.addheaders =[('Cookie','SRCHD=D=4210979&AF=NOFORM; domain=.bing.com; expires=Wednesday, 09-Nov-06 23:12:40 GMT; MUIDB=36F71C46589F6EAD0BE714175C9F68FC; domain=www.bing.com; expires=15 de enero de 2018 08:43:26 GMT+1')] # Open some site, let's pick a random one, the first that pops in mind r = br.open(url) response = r.read() # if "z{a:1}" in response: if not ".ftrH,.ftrHd,.ftrD>" in response: print "proooxyy" r = br.open("http://anonymouse.org/cgi-bin/anon-www.cgi/" + url) response = r.read() return response ###def proxy(url): '''from lib import requests proxies = {"http": "http://anonymouse.org/cgi-bin/anon-www.cgi/"+url} print "zorro" print proxies rsp = requests.get(url, proxies=proxies,stream=True) print rsp.raw._fp.fp._sock.getpeername() print rsp.content response = rsp.content return response''' def mainlist(item): logger.info() itemlist = [] itemlist.append(Item(channel=item.channel, title="[COLOR skyblue][B]Generos[/B][/COLOR]", action="generos", url="http://bityouth.com", thumbnail="http://s6.postimg.org/ybey4gxu9/bityougenerosthum3.png", fanart="http://s18.postimg.org/l4judlx09/bityougenerosfan.jpg")) itemlist.append(Item(channel=item.channel, title="[COLOR skyblue][B]Puntuacion[/B][/COLOR]", action="scraper", url="http://bityouth.com/more_elements/0/?o=pd", thumbnail="http://s6.postimg.org/n1qtn9i6p/bityoupuntothum4.png", fanart="http://s6.postimg.org/qrh9oof9t/bityoupuntofan.jpg")) itemlist.append(Item(channel=item.channel, title="[COLOR skyblue][B]Novedades[/B][/COLOR]", action="scraper", url="http://bityouth.com/more_elements/0/?o=", thumbnail="http://s6.postimg.org/bry3sbd5d/bityounovedathum2.png", fanart="http://s6.postimg.org/ys4r4naz5/bityounovedadfan.jpg")) import xbmc if xbmc.Player().isPlaying(): xbmc.executebuiltin('xbmc.PlayMedia(Stop)') SEARCHDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "search.txt") TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py") KEYMAPDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customkey.xml") REMOTEDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remote.xml") APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml") try: os.remove(KEYMAPDESTFILE) print "Custom Keyboard.xml borrado" os.remove(TESTPYDESTFILE) print "Testpy borrado" os.remove(REMOTEDESTFILE) print "Remote borrado" os.remove(APPCOMMANDDESTFILE) print "Appcommand borrado" xbmc.executebuiltin('Action(reloadkeymaps)') except Exception as inst: xbmc.executebuiltin('Action(reloadkeymaps)') print "No hay customs" itemlist.append(Item(channel=item.channel, title="[COLOR skyblue][B]Series[/B][/COLOR]", action="scraper", url="http://bityouth.com/more_elements/0/genero/serie_de_tv?o=", thumbnail="http://s6.postimg.org/59j1km53l/bityouseriesthum.png", fanart="http://s6.postimg.org/45yx8nkgh/bityouseriesfan3.jpg")) if xbmc.Player().isPlaying(): xbmc.executebuiltin('xbmc.PlayMedia(Stop)') TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py") KEYMAPDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customkey.xml") REMOTEDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remote.xml") APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml") TRAILERDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "trailer.txt") try: os.remove(KEYMAPDESTFILE) print "Custom Keyboard.xml borrado" os.remove(TESTPYDESTFILE) print "Testpy borrado" os.remove(REMOTEDESTFILE) print "Remote borrado" os.remove(APPCOMMANDDESTFILE) print "Appcommand borrado" xbmc.executebuiltin('Action(reloadkeymaps)') except Exception as inst: xbmc.executebuiltin('Action(reloadkeymaps)') print "No hay customs" try: os.remove(SEARCHDESTFILE) print "Custom search.txt borrado" except: print "No hay search.txt" try: os.remove(TRAILERDESTFILE) print "Custom Trailer.txt borrado" except: print "No hay Trailer.txt" itemlist.append(Item(channel=item.channel, title="[COLOR skyblue][B]Buscar...[/B][/COLOR]", action="search", url="", thumbnail="http://s6.postimg.org/48isvho41/bityousearchthum.png", fanart="http://s6.postimg.org/ic5hcegk1/bityousearchfan.jpg", plot="search")) return itemlist def search(item, texto): logger.info() itemlist = [] if item.url == "": item.url = "http://bityouth.com/busqueda/" item.url = item.url + texto item.url = item.url.replace(" ", "%20") data = scrapertools.cache_page(item.url) data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) patron = '
.*?title="([^<]+)" ' patron += 'href="([^"]+)".*?' patron += '

([^<]+)

.*?' patron += '" in data: itemlist.append(Item(channel=item.channel, title="[COLOR gold][B]No hay mas paginas...[/B][/COLOR]", thumbnail="http://s6.postimg.org/f4es4kyfl/bityou_Sorry.png", fanart="http://s6.postimg.org/y1uehu24x/bityougeneralfan.jpg", folder=False)) else: current_page_number = int(scrapertools.get_match(item.url, 'more_elements/(\d+)')) item.url = re.sub(r"more_elements/\d+", "more_elements/{0}", item.url) next_page_number = current_page_number + 40 next_page = item.url.format(next_page_number) title = "[COLOR skyblue]Pagina siguiente>>[/COLOR]" itemlist.append(Item(channel=item.channel, title=title, url=next_page, fanart="http://s6.postimg.org/y1uehu24x/bityougeneralfan.jpg", thumbnail="http://s6.postimg.org/kbzv91f0x/bityouflecha2.png", action="scraper", folder=True)) return itemlist def fanart(item): # Vamos a sacar todos los fanarts y arts posibles logger.info() itemlist = [] url = item.url data = scrapertools.cachePage(url) data = re.sub(r"\n|\r|\t|\s{2}|\(.*?\)|\[.*?\]| ", "", data) year = item.show.split("|")[1] title = item.show.split("|")[0] trailer = item.show.split("|")[2] print "joder" print title if title == "Érase una vez (Serie de TV)": title = "Once upon in time" import xbmc xbmc.executebuiltin('Action(reloadkeymaps)') title = title.replace('á', 'a') title = title.replace('Á', 'A') title = title.replace('é', 'e') title = title.replace('É', 'E') title = title.replace('í', 'i') title = title.replace('Í', 'i') title = title.replace('ó', 'o') title = title.replace('Ó', 'o') title = title.replace('ú', 'u') title = title.replace('Ú', 'U') title = title.replace('ñ', 'n') title = title.replace('Ñ', 'N') if not "_serie_de_tv" in item.url and not item.extra == "series": title = title.replace("(Serie de TV)", "") title = title.replace("torrent", "") try: try: ###Busqueda en Tmdb la peli por titulo y año title_tmdb = title.replace(" ", "%20") url_tmdb = "http://api.themoviedb.org/3/search/movie?api_key=2e2160006592024ba87ccdf78c28f49f&query=" + title_tmdb + "&year=" + year + "&language=es&include_adult=false" data = scrapertools.cachePage(url_tmdb) data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) id = scrapertools.get_match(data, '"page":1.*?,"id":(.*?),') plot = scrapertools.get_match(data, '"page":1.*?,"overview":"(.*?)",') except: if ":" in title or "(" in title: title_tmdb = title.replace(" ", "%20") url_tmdb = "http://api.themoviedb.org/3/search/movie?api_key=2e2160006592024ba87ccdf78c28f49f&query=" + title_tmdb + "&year=" + year + "&language=es&include_adult=false" data = scrapertools.cachePage(url_tmdb) data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) id = scrapertools.get_match(data, '"page":1.*?,"id":(.*?),') plot = scrapertools.get_match(data, '"page":1.*?,"overview":"(.*?)",') else: title_tmdb = title.replace(" ", "%20") title_tmdb = re.sub(r"(:.*)|\(.*?\)", "", title_tmdb) url_tmdb = "http://api.themoviedb.org/3/search/movie?api_key=2e2160006592024ba87ccdf78c28f49f&query=" + title_tmdb + "&year=" + year + "&language=es&include_adult=false" data = scrapertools.cachePage(url_tmdb) data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) id = scrapertools.get_match(data, '"page":1.*?,"id":(.*?),') plot = scrapertools.get_match(data, '"page":1.*?,"overview":"(.*?)",') except: ###Si no hay coincidencia realiza busqueda por bing del id Imdb urlbing_imdb = "http://www.bing.com/search?q=%s+%s+site:imdb.com" % (title.replace(' ', '+'), year) data = browser(urlbing_imdb) '''if "z{a:1}"in data: data = proxy(urlbing_imdb)''' try: subdata_imdb = scrapertools.get_match(data, '
  • (.*?)h="ID') subdata_imdb = re.sub("http://anonymouse.org/cgi-bin/anon-www.cgi/", "", subdata_imdb) except: pass try: url_imdb = scrapertools.get_match(subdata_imdb, '(.*?)h="ID') subdata_imdb = re.sub("http://anonymouse.org/cgi-bin/anon-www.cgi/", "", subdata_imdb) except: pass try: url_imdb = scrapertools.get_match(subdata_imdb, '.*?src="([^"]+)"') poster_imdb = poster_imdb.replace("._.*?jpg", "._V1_SX640_SY720_.jpg") except: poster_imdb = posterdb try: url_photo = scrapertools.get_match(data, '
    .*?(.*?)h="ID') except: pass try: url_tvt = scrapertools.get_match(subdata_tvt, '.*?type="hidden" value="(.*?)"') song = song.replace(" ", "%20") xbmc.executebuiltin('xbmc.PlayMedia(' + song + ')') import xbmc, time TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py") urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bityouth/test.py", TESTPYDESTFILE) KEYMAPDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customkey.xml") urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bityouth/customkey.xml", KEYMAPDESTFILE) REMOTEDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remote.xml") urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bityouth/remote.xml", REMOTEDESTFILE) APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml") urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bityouth/customapp.xml", APPCOMMANDDESTFILE) xbmc.executebuiltin('Action(reloadkeymaps)') except: pass try: os.remove(TRAILERDESTFILE) print "Trailer.txt borrado" xbmc.executebuiltin('Action(reloadkeymaps)') except: print "No hay Trailer.txt" xbmc.executebuiltin('Action(reloadkeymaps)') if os.path.exists(SEARCHDESTFILE): try: os.remove(KEYMAPDESTFILE) print "Custom Keyboard.xml borrado" os.remove(TESTPYDESTFILE) print "Testpy borrado" os.remove(REMOTEDESTFILE) print "Remote borrado" os.remove(APPCOMMANDDESTFILE) print "Appcommand borrado" os.remove(SEARCHDESTFILE) print "search.txt borrado" xbmc.executebuiltin('Action(reloadkeymaps)') except Exception as inst: print "No hay customs" xbmc.executebuiltin('Action(reloadkeymaps)') # Busqueda bing de Imdb serie id url_imdb = "http://www.bing.com/search?q=%s+%s+tv+series+site:imdb.com" % (title.replace(' ', '+'), year) print url_imdb data = browser(url_imdb) '''if "z{a:1}"in data: data = proxy(url_imdb)''' print "perro" print data data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) try: subdata_imdb = scrapertools.get_match(data, '
  • (.*?)h="ID') print "ostia" print subdata_imdb except: pass print "joder" try: imdb_id = scrapertools.get_match(subdata_imdb, '.*?posters/(.*?)') postertvdb = "http://thetvdb.com/banners/_cache/posters/" + postertvdb except: postertvdb = item.thumbnail if len(matches) == 0: extra = "http://s6.postimg.org/rv2mu3pap/bityouthsinopsis2.png" show = title + "|" + year + "|" + "http://s6.postimg.org/mh3umjzkh/bityouthnofanventanuco.jpg" fanart_info = "http://s6.postimg.org/6ucl96lsh/bityouthnofan.jpg" fanart_trailer = "http://s6.postimg.org/6ucl96lsh/bityouthnofan.jpg" itemlist.append(Item(channel=item.channel, title=item.title, url=item.url, action="findvideos", thumbnail=postertvdb, fanart="http://s6.postimg.org/6ucl96lsh/bityouthnofan.jpg", category=category, extra=extra, show=show, folder=True)) for fan in matches: fanart = "http://thetvdb.com/banners/" + fan fanart_1 = fanart patron = '.*?.*?.*?.*?(.*?).*?.*?(.*?).*?.*?(.*?)' matches = re.compile(patron, re.DOTALL).findall(data) if len(matches) == 0: fanart_info = fanart_1 fanart_trailer = fanart_1 fanart_2 = fanart_1 show = title + "|" + year + "|" + fanart_1 extra = postertvdb itemlist.append(Item(channel=item.channel, title=item.title, url=item.url, action="findvideos", thumbnail=postertvdb, fanart=fanart_1, category=category, extra=extra, show=show, folder=True)) for fanart_info, fanart_trailer, fanart_2 in matches: fanart_info = "http://thetvdb.com/banners/" + fanart_info fanart_trailer = "http://thetvdb.com/banners/" + fanart_trailer fanart_2 = "http://thetvdb.com/banners/" + fanart_2 # clearart, fanart_2 y logo for id in matches: url_fanartv = "http://webservice.fanart.tv/v3/tv/" + id_serie + "?api_key=dffe90fba4d02c199ae7a9e71330c987" data = scrapertools.cachePage(url_fanartv) data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) patron = '"clearlogo":.*?"url": "([^"]+)"' matches = re.compile(patron, re.DOTALL).findall(data) if '"tvposter"' in data: tvposter = scrapertools.get_match(data, '"tvposter":.*?"url": "([^"]+)"') if '"tvbanner"' in data: tvbanner = scrapertools.get_match(data, '"tvbanner":.*?"url": "([^"]+)"') if '"tvthumb"' in data: tvthumb = scrapertools.get_match(data, '"tvthumb":.*?"url": "([^"]+)"') if '"hdtvlogo"' in data: hdtvlogo = scrapertools.get_match(data, '"hdtvlogo":.*?"url": "([^"]+)"') if '"hdclearart"' in data: hdtvclear = scrapertools.get_match(data, '"hdclearart":.*?"url": "([^"]+)"') if len(matches) == 0: item.thumbnail = postertvdb if '"hdtvlogo"' in data: if "showbackground" in data: if '"hdclearart"' in data: thumbnail = hdtvlogo extra = hdtvclear show = title + "|" + year + "|" + fanart_2 else: thumbnail = hdtvlogo extra = thumbnail show = title + "|" + year + "|" + fanart_2 itemlist.append(Item(channel=item.channel, title=item.title, action="findvideos", url=item.url, server="torrent", thumbnail=thumbnail, fanart=fanart_1, category=category, extra=extra, show=show, plot=item.plot, folder=True)) else: if '"hdclearart"' in data: thumbnail = hdtvlogo extra = hdtvclear show = title + "|" + year + "|" + fanart_2 else: thumbnail = hdtvlogo extra = thumbnail show = title + "|" + year + "|" + fanart_2 itemlist.append(Item(channel=item.channel, title=item.title, action="findvideos", url=item.url, server="torrent", thumbnail=thumbnail, fanart=fanart_1, extra=extra, show=show, category=category, plot=item.plot, folder=True)) else: extra = "http://s6.postimg.org/rv2mu3pap/bityouthsinopsis2.png" show = title + "|" + year + "|" + fanart_2 itemlist.append(Item(channel=item.channel, title=item.title, action="findvideos", url=item.url, server="torrent", thumbnail=item.thumbnail, fanart=fanart_1, extra=extra, show=show, category=category, plot=item.plot, folder=True)) for logo in matches: if '"hdtvlogo"' in data: thumbnail = hdtvlogo elif not '"hdtvlogo"' in data: if '"clearlogo"' in data: thumbnail = logo else: thumbnail = item.thumbnail if '"clearart"' in data: clear = scrapertools.get_match(data, '"clearart":.*?"url": "([^"]+)"') if "showbackground" in data: extra = clear show = title + "|" + year + "|" + fanart_2 itemlist.append(Item(channel=item.channel, title=item.title, action="findvideos", url=item.url, server="torrent", thumbnail=thumbnail, fanart=fanart_1, extra=extra, show=show, category=category, plot=item.plot, folder=True)) else: extra = clear show = title + "|" + year + "|" + fanart_2 itemlist.append(Item(channel=item.channel, title=item.title, action="findvideos", url=item.url, server="torrent", thumbnail=thumbnail, fanart=fanart_1, extra=extra, show=show, category=category, plot=item.plot, folder=True)) if "showbackground" in data: if '"clearart"' in data: clear = scrapertools.get_match(data, '"clearart":.*?"url": "([^"]+)"') extra = clear show = title + "|" + year + "|" + fanart_2 else: extra = logo show = title + "|" + year + "|" + fanart_2 itemlist.append(Item(channel=item.channel, title=item.title, action="findvideos", url=item.url, server="torrent", thumbnail=thumbnail, fanart=fanart_1, extra=extra, show=show, category=category, plot=item.plot, folder=True)) if not '"clearart"' in data and not '"showbackground"' in data: if '"hdclearart"' in data: extra = hdtvclear show = title + "|" + year + "|" + fanart_2 else: extra = thumbnail show = title + "|" + year + "|" + fanart_2 itemlist.append( Item(channel=item.channel, title=item.title, action="findvideos", url=item.url, server="torrent", thumbnail=thumbnail, fanart=fanart_1, extra=extra, show=show, category=category, plot=item.plot, folder=True)) title = "Info" if not "_serie_de_tv" in item.url and not item.extra == "series": thumbnail = posterdb if "_serie_de_tv" in item.url or item.extra == "series": if '"tvposter"' in data: thumbnail = tvposter else: thumbnail = postertvdb if "tvbanner" in data: category = tvbanner else: category = item.show.split("|")[2] title = title.replace(title, "[COLOR cyan]" + title + "[/COLOR]") itemlist.append( Item(channel=item.channel, action="info", title=title, url=item.url, thumbnail=thumbnail, fanart=fanart_info, extra=extra, plot=plot, category=category, show=show, folder=False)) ###trailer title = "[COLOR gold]Trailer[/COLOR]" if "_serie_de_tv" in item.url or item.extra == "series": if '"tvthumb"' in data: thumbnail = tvthumb else: thumbnail = postertvdb if '"tvbanner"' in data: extra = tvbanner elif '"tvthumb"' in data: extra = tvthumb else: extra = item.thumbnail else: if '"moviethumb"' in data: thumbnail = thumb else: thumbnail = posterdb if '"moviedisc"' in data: extra = disc else: if '"moviethumb"' in data: extra = thumb else: extra = posterdb itemlist.append( Item(channel=item.channel, action="trailer", title=title, url=item.url, thumbnail=thumbnail, plot=item.plot, fanart=fanart_trailer, extra=extra, show=trailer, folder=True)) return itemlist def findvideos(item): logger.info() itemlist = [] import xbmc SEARCHDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "search.txt") TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py") KEYMAPDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customkey.xml") REMOTEDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remote.xml") APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml") if xbmc.Player().isPlaying(): if not os.path.exists(TESTPYDESTFILE): import xbmc urllib.urlretrieve("https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/search.txt", SEARCHDESTFILE) urllib.urlretrieve("https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/test.py", TESTPYDESTFILE) urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bricocine/customkey.xml", KEYMAPDESTFILE) urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bricocine/remote.xml", REMOTEDESTFILE) urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bricocine/customapp.xml", APPCOMMANDDESTFILE) xbmc.executebuiltin('Action(reloadkeymaps)') if not xbmc.Player().isPlaying(): TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py") KEYMAPDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customkey.xml") REMOTEDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remote.xml") APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml") try: os.remove(KEYMAPDESTFILE) print "Custom Keyboard.xml borrado" os.remove(TESTPYDESTFILE) print "Testpy borrado" os.remove(REMOTEDESTFILE) print "Remote borrado" os.remove(APPCOMMANDDESTFILE) print "Appcommand borrado" xbmc.executebuiltin('Action(reloadkeymaps)') except Exception as inst: xbmc.executebuiltin('Action(reloadkeymaps)') print "No hay customs" data = scrapertools.cache_page(item.url) data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) patron = '(.*?)') except: plot = item.plot plot = plot.replace(plot, "[COLOR bisque][B]" + plot + "[/B][/COLOR]") plot = plot.replace("", "") plot = plot.replace("
    ", "") plot = plot.replace("
    ", "") plot = plot.replace("“", "") plot = plot.replace("", "") plot = plot.replace("", "") plot = plot.replace(" ​​", "") plot = scrapertools.decodeHtmlentities(plot) plot = plot.replace(""", "") except: title = "[COLOR red][B]LO SENTIMOS...[/B][/COLOR]" plot = "Esta serie no tiene informacion..." plot = plot.replace(plot, "[COLOR yellow][B]" + plot + "[/B][/COLOR]") photo = "http://s6.postimg.org/nm3gk1xox/noinfosup2.png" foto = "http://s6.postimg.org/ub7pb76c1/noinfo.png" info = "" quit = "Pulsa" + " [COLOR blue][B]INTRO [/B][/COLOR]" + "para quitar" try: scrapedinfo = scrapertools.get_match(data, '
    |>,', '', info) info = info.replace("

    ", " ") info = info.replace("#", ",") info = info.replace(">", "") except: info = "[COLOR skyblue][B]Sin informacion adicional...[/B][/COLOR]" if "_serie_de_tv" in item.url: foto = item.show.split("|")[2] else: foto = item.category if item.show == item.thumbnail: foto = "http://s6.postimg.org/mh3umjzkh/bityouthnofanventanuco.jpg" photo = item.extra quit = "Pulsa" + " [COLOR blue][B]INTRO [/B][/COLOR]" + "para quitar" if "_serie_de_tv" in item.url: NOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "noback.xml") REMOTENOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remotenoback.xml") APPNOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "appnoback.xml") urllib.urlretrieve("https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/noback.xml", NOBACKDESTFILE) urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bityouth/remotenoback.xml", REMOTENOBACKDESTFILE) urllib.urlretrieve("https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/appnoback.xml", APPNOBACKDESTFILE) xbmc.executebuiltin('Action(reloadkeymaps)') ventana2 = TextBox1(title=title, plot=plot, info=info, thumbnail=photo, fanart=foto, quit=quit) ventana2.doModal() ACTION_GESTURE_SWIPE_LEFT = 511 ACTION_SELECT_ITEM = 7 class TextBox1(xbmcgui.WindowDialog): """ Create a skinned textbox window """ def __init__(self, *args, **kwargs): self.getTitle = kwargs.get('title') self.getPlot = kwargs.get('plot') self.getInfo = kwargs.get('info') self.getThumbnail = kwargs.get('thumbnail') self.getFanart = kwargs.get('fanart') self.getQuit = kwargs.get('quit') self.background = xbmcgui.ControlImage(70, 20, 1150, 630, 'http://s6.postimg.org/58jknrvtd/backgroundventana5.png') self.title = xbmcgui.ControlTextBox(140, 60, 1130, 50) self.quit = xbmcgui.ControlTextBox(145, 90, 1030, 45) self.plot = xbmcgui.ControlTextBox(120, 150, 1056, 140) self.info = xbmcgui.ControlFadeLabel(120, 310, 1056, 100) self.thumbnail = xbmcgui.ControlImage(813, 43, 390, 100, self.getThumbnail) self.fanart = xbmcgui.ControlImage(120, 365, 1060, 250, self.getFanart) self.addControl(self.background) self.addControl(self.title) self.addControl(self.quit) self.addControl(self.plot) self.addControl(self.thumbnail) self.addControl(self.fanart) self.addControl(self.info) self.title.setText(self.getTitle) self.quit.setText(self.getQuit) try: self.plot.autoScroll(7000, 6000, 30000) except: print "Actualice a la ultima version de kodi para mejor info" import xbmc xbmc.executebuiltin( 'Notification([COLOR red][B]Actualiza Kodi a su última versión[/B][/COLOR], [COLOR skyblue]para mejor info[/COLOR],8000,"https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/kodi-icon.png")') self.plot.setText(self.getPlot) self.info.addLabel(self.getInfo) def get(self): self.show() def onAction(self, action): if action == ACTION_SELECT_ITEM or action == ACTION_GESTURE_SWIPE_LEFT: import os import xbmc APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml") NOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "noback.xml") REMOTENOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remotenoback.xml") APPNOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "appnoback.xml") TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py") try: os.remove(NOBACKDESTFILE) os.remove(REMOTENOBACKDESTFILE) os.remove(APPNOBACKDESTFILE) if os.path.exists(TESTPYDESTFILE): urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bityouth/customapp.xml", APPCOMMANDDESTFILE) xbmc.executebuiltin('Action(reloadkeymaps)') except: xbmc.executebuiltin('Action(reloadkeymaps)') self.close() def info_capitulos(item): logger.info() import xbmc APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml") try: os.remove(APPCOMMANDDESTFILE) except: pass item.category = item.show.split("|")[0] item.thumbnail = item.show.split("|")[1] url = "http://thetvdb.com/api/1D62F2F90030C444/series/" + item.show.split("|")[0] + "/default/" + \ item.extra.split("|")[0] + "/" + item.extra.split("|")[2] + "/es.xml" data = scrapertools.cache_page(url) data = re.sub(r"\n|\r|\t|\s{2}| ", "", data) patron = '.*?([^<]+).*?' patron += '(.*?).*?' matches = re.compile(patron, re.DOTALL).findall(data) if len(matches) == 0: title = "[COLOR red][B]LO SENTIMOS...[/B][/COLOR]" plot = "Este capitulo no tiene informacion..." plot = plot.replace(plot, "[COLOR yellow][B]" + plot + "[/B][/COLOR]") foto = "http://s6.postimg.org/nm3gk1xox/noinfosup2.png" image = "http://s6.postimg.org/ub7pb76c1/noinfo.png" quit = "Pulsa" + " [COLOR greenyellow][B]INTRO [/B][/COLOR]" + "para quitar" else: for name_epi, info in matches: if "episodes" in data: foto = scrapertools.get_match(data, '.*?(.*?)') fanart = "http://thetvdb.com/banners/" + foto else: fanart = item.show.split("|")[1] plot = info plot = plot.replace(plot, "[COLOR burlywood][B]" + plot + "[/B][/COLOR]") title = name_epi.upper() title = title.replace(title, "[COLOR skyblue][B]" + title + "[/B][/COLOR]") image = fanart foto = item.show.split("|")[1] if not ".png" in item.show.split("|")[1]: foto = "http://s6.postimg.org/rv2mu3pap/bityouthsinopsis2.png" quit = "Pulsa" + " [COLOR greenyellow][B]INTRO [/B][/COLOR]" + "para quitar" NOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "noback.xml") REMOTENOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remotenoback.xml") APPNOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "appnoback.xml") TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py") urllib.urlretrieve("https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/noback.xml", NOBACKDESTFILE) urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bityouth/remotenoback.xml", REMOTENOBACKDESTFILE) urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/appnoback.xml", APPNOBACKDESTFILE) xbmc.executebuiltin('Action(reloadkeymaps)') ventana = TextBox2(title=title, plot=plot, thumbnail=image, fanart=foto, quit=quit) ventana.doModal() ACTION_GESTURE_SWIPE_LEFT = 511 ACTION_SELECT_ITEM = 7 class TextBox2(xbmcgui.WindowDialog): """ Create a skinned textbox window """ def __init__(self, *args, **kwargs): self.getTitle = kwargs.get('title') self.getPlot = kwargs.get('plot') self.getThumbnail = kwargs.get('thumbnail') self.getFanart = kwargs.get('fanart') self.getQuit = kwargs.get('quit') self.background = xbmcgui.ControlImage(70, 20, 1150, 630, 'http://s6.postimg.org/n3ph1uxn5/ventana.png') self.title = xbmcgui.ControlTextBox(120, 60, 430, 50) self.quit = xbmcgui.ControlTextBox(145, 90, 1030, 45) self.plot = xbmcgui.ControlTextBox(120, 150, 1056, 100) self.thumbnail = xbmcgui.ControlImage(120, 300, 1056, 300, self.getThumbnail) self.fanart = xbmcgui.ControlImage(780, 43, 390, 100, self.getFanart) self.addControl(self.background) self.addControl(self.title) self.addControl(self.quit) self.addControl(self.plot) self.addControl(self.thumbnail) self.addControl(self.fanart) self.title.setText(self.getTitle) self.quit.setText(self.getQuit) try: self.plot.autoScroll(7000, 6000, 30000) except: print "Actualice a la ultima version de kodi para mejor info" import xbmc xbmc.executebuiltin( 'Notification([COLOR red][B]Actualiza Kodi a su última versión[/B][/COLOR], [COLOR skyblue]para mejor info[/COLOR],8000,"https://raw.githubusercontent.com/linuxserver/docker-templates/master/linuxserver.io/img/kodi-icon.png")') self.plot.setText(self.getPlot) def get(self): self.show() def onAction(self, action): if action == ACTION_SELECT_ITEM or action == ACTION_GESTURE_SWIPE_LEFT: import os import xbmc APPCOMMANDDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "customapp.xml") NOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "noback.xml") REMOTENOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "remotenoback.xml") APPNOBACKDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "appnoback.xml") TESTPYDESTFILE = os.path.join(xbmc.translatePath('special://userdata/keymaps'), "test.py") try: os.remove(NOBACKDESTFILE) os.remove(REMOTENOBACKDESTFILE) os.remove(APPNOBACKDESTFILE) if os.path.exists(TESTPYDESTFILE): urllib.urlretrieve( "https://raw.githubusercontent.com/neno1978/script.palc.forcerefresh/master/Bityouth/customapp.xml", APPCOMMANDDESTFILE) xbmc.executebuiltin('Action(reloadkeymaps)') except: xbmc.executebuiltin('Action(reloadkeymaps)') self.close() def translate(to_translate, to_langage="auto", langage="auto"): ###Traducción atraves de Google '''Return the translation using google translate you must shortcut the langage you define (French = fr, English = en, Spanish = es, etc...) if you don't define anything it will detect it or use english by default Example: print(translate("salut tu vas bien?", "en")) hello you alright?''' agents = { 'User-Agent': "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)"} before_trans = 'class="t0">' link = "http://translate.google.com/m?hl=%s&sl=%s&q=%s" % (to_langage, langage, to_translate.replace(" ", "+")) request = urllib2.Request(link, headers=agents) page = urllib2.urlopen(request).read() result = page[page.find(before_trans) + len(before_trans):] result = result.split("<")[0] return result if __name__ == '__main__': to_translate = 'Hola como estas?' print("%s >> %s" % (to_translate, translate(to_translate))) print("%s >> %s" % (to_translate, translate(to_translate, 'fr'))) # should print Hola como estas >> Hello how are you # and Hola como estas? >> Bonjour comment allez-vous?