pelisplusco: agregado busqueda
This commit is contained in:
@@ -7,14 +7,19 @@ import re
|
|||||||
import urllib
|
import urllib
|
||||||
from platformcode import logger
|
from platformcode import logger
|
||||||
from platformcode import config
|
from platformcode import config
|
||||||
|
from core import jsontools
|
||||||
from core import scrapertools
|
from core import scrapertools
|
||||||
from core.item import Item
|
from core.item import Item
|
||||||
from core import servertools
|
from core import servertools
|
||||||
from core import httptools
|
from core import httptools
|
||||||
from core import tmdb
|
from core import tmdb
|
||||||
|
|
||||||
|
|
||||||
host = 'http://pelisplus.co'
|
host = 'http://pelisplus.co'
|
||||||
|
CHANNEL_HEADERS = [
|
||||||
|
["Host", host.replace("http://","")],
|
||||||
|
["X-Requested-With", "XMLHttpRequest"]
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
def mainlist(item):
|
def mainlist(item):
|
||||||
logger.info()
|
logger.info()
|
||||||
@@ -55,8 +60,53 @@ def movie_menu(item):
|
|||||||
seccion='anios'
|
seccion='anios'
|
||||||
))
|
))
|
||||||
|
|
||||||
|
itemlist.append(item.clone(title="Buscar",
|
||||||
|
action="search",
|
||||||
|
url=host + "/suggest/?query=",
|
||||||
|
type="m",
|
||||||
|
seccion='buscar'
|
||||||
|
))
|
||||||
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
|
def search(item, texto):
|
||||||
|
logger.info()
|
||||||
|
if not item.type:
|
||||||
|
item.type = "m"
|
||||||
|
item.url = host + "/suggest/?query="
|
||||||
|
item.url = item.url + texto
|
||||||
|
if texto != '':
|
||||||
|
return sub_search(item)
|
||||||
|
else:
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
|
def sub_search(item):
|
||||||
|
logger.info()
|
||||||
|
itemlist =[]
|
||||||
|
data = httptools.downloadpage(item.url, add_referer=True).data
|
||||||
|
dict_data = jsontools.load(data)
|
||||||
|
list =dict_data["data"] [item.type]
|
||||||
|
if item.type == "m":
|
||||||
|
action = "findvideos"
|
||||||
|
else:
|
||||||
|
action = "seasons"
|
||||||
|
for dict in list:
|
||||||
|
itemlist.append(item.clone(channel = item.channel,
|
||||||
|
action = action,
|
||||||
|
fulltitle = dict["title"],
|
||||||
|
show = dict["title"],
|
||||||
|
infoLabels={"year":dict["release_year"]},
|
||||||
|
thumbnail = "http://static.pelisfox.tv/static/movie/" + dict["cover"],
|
||||||
|
title = dict["title"] + " (" + dict["release_year"] + ")",
|
||||||
|
url = host + dict["slug"]
|
||||||
|
))
|
||||||
|
tmdb.set_infoLabels(itemlist)
|
||||||
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def series_menu(item):
|
def series_menu(item):
|
||||||
|
|
||||||
logger.info()
|
logger.info()
|
||||||
@@ -69,6 +119,13 @@ def series_menu(item):
|
|||||||
type='serie'
|
type='serie'
|
||||||
))
|
))
|
||||||
|
|
||||||
|
itemlist.append(item.clone(title="Buscar",
|
||||||
|
action="search",
|
||||||
|
url=host + "/suggest/?query=",
|
||||||
|
type="s",
|
||||||
|
seccion='buscar'
|
||||||
|
))
|
||||||
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
@@ -82,40 +139,34 @@ def get_source(url):
|
|||||||
def list_all (item):
|
def list_all (item):
|
||||||
logger.info ()
|
logger.info ()
|
||||||
itemlist = []
|
itemlist = []
|
||||||
|
if item.type in ['serie','recents']:
|
||||||
if item.type not in ['normal', 'seccion', 'serie']:
|
|
||||||
post = {'page':item.page, 'type':item.type,'id':item.id}
|
|
||||||
post = urllib.urlencode(post)
|
|
||||||
data =httptools.downloadpage(item.url, post=post).data
|
|
||||||
data = re.sub(r'"|\n|\r|\t| |<br>|\s{2,}', "", data)
|
|
||||||
else:
|
|
||||||
data = get_source(item.url)
|
|
||||||
if item.type == 'serie' or item.type == 'recents':
|
|
||||||
contentType = 'serie'
|
contentType = 'serie'
|
||||||
action = 'seasons'
|
action = 'seasons'
|
||||||
else:
|
else:
|
||||||
contentType = 'pelicula'
|
contentType = 'pelicula'
|
||||||
action = 'findvideos'
|
action = 'findvideos'
|
||||||
|
if item.type not in ['normal', 'seccion', 'serie']:
|
||||||
patron = 'item-%s><a href=(.*?)><figure><img.*?data-src=(.*?) alt=.*?<p>(.*?)<\/p><span>(\d{4})<\/span>'%contentType
|
post = {'page':item.page, 'type':item.type,'slug':item.slug,'id':item.id}
|
||||||
|
post = urllib.urlencode(post)
|
||||||
matches = re.compile(patron,re.DOTALL).findall(data)
|
data =httptools.downloadpage(item.url, post=post, headers=CHANNEL_HEADERS).data
|
||||||
|
data = re.sub(r'"|\n|\r|\t| |<br>|\s{2,}', "", data)
|
||||||
|
patron ='<a href=(.*?)><figure><img.*?src=(.*?) alt=.*?<p>(.*?)<\/p><span>(\d{4})<\/span>'
|
||||||
|
else:
|
||||||
|
data = get_source(item.url)
|
||||||
|
patron = 'item-%s><a href=(.*?)><figure><img.*?data-src=(.*?) alt=.*?<p>(.*?)<\/p><span>(\d{4})</span>'%contentType
|
||||||
|
matches = scrapertools.find_multiple_matches(data, patron)
|
||||||
for scrapedurl, scrapedthumbnail, scrapedtitle, scrapedyear in matches:
|
for scrapedurl, scrapedthumbnail, scrapedtitle, scrapedyear in matches:
|
||||||
url = host+scrapedurl+'p001/'
|
url = host+scrapedurl+'p001/'
|
||||||
thumbnail = scrapedthumbnail
|
thumbnail = scrapedthumbnail
|
||||||
plot= ''
|
|
||||||
contentTitle=scrapedtitle
|
contentTitle=scrapedtitle
|
||||||
title = contentTitle
|
title = contentTitle
|
||||||
year = scrapedyear
|
year = scrapedyear
|
||||||
fanart =''
|
|
||||||
|
|
||||||
new_item=item.clone(action=action,
|
new_item=item.clone(action=action,
|
||||||
title=title,
|
title=title,
|
||||||
url=url,
|
url=url,
|
||||||
thumbnail=thumbnail,
|
thumbnail=thumbnail,
|
||||||
plot=plot,
|
plot="",
|
||||||
fanart=fanart,
|
fanart="",
|
||||||
infoLabels ={'year':year}
|
infoLabels ={'year':year}
|
||||||
)
|
)
|
||||||
if contentType =='serie':
|
if contentType =='serie':
|
||||||
@@ -141,13 +192,15 @@ def list_all (item):
|
|||||||
else:
|
else:
|
||||||
id =''
|
id =''
|
||||||
else:
|
else:
|
||||||
|
if not item.page:
|
||||||
|
item.page = "1"
|
||||||
page = str(int(item.page)+1)
|
page = str(int(item.page)+1)
|
||||||
id = item.id
|
id = item.id
|
||||||
|
|
||||||
if type =='recents':
|
if type =='recents':
|
||||||
type_pagination = '/series/pagination'
|
type_pagination = '/series/pagination/'
|
||||||
else:
|
else:
|
||||||
type_pagination = '/pagination'
|
type_pagination = '/pagination/'
|
||||||
|
|
||||||
url = host+type_pagination
|
url = host+type_pagination
|
||||||
|
|
||||||
@@ -164,29 +217,35 @@ def seccion(item):
|
|||||||
logger.info()
|
logger.info()
|
||||||
itemlist = []
|
itemlist = []
|
||||||
data = get_source(item.url)
|
data = get_source(item.url)
|
||||||
|
page = "1"
|
||||||
if item.seccion == 'generos':
|
if item.seccion == 'generos':
|
||||||
patron = '<li><a href=(.*?)><i class=ion-cube><\/i>(.*?)<\/span>'
|
patron = '<li><a href=(.*?)><i class=ion-cube><\/i>(.*?)<\/span>'
|
||||||
type = 'genre'
|
type = 'genre'
|
||||||
|
pat = 'genero/'
|
||||||
elif item.seccion == 'anios':
|
elif item.seccion == 'anios':
|
||||||
patron = '<li><a href=(\/peliculas.*?)>(\d{4})<\/a>'
|
patron = '<li><a href=(\/peliculas.*?)>(\d{4})<\/a>'
|
||||||
type = 'year'
|
type = 'year'
|
||||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
pat = 'peliculas-'
|
||||||
|
matches = scrapertools.find_multiple_matches(data, patron)
|
||||||
for scrapedurl, scrapedtitle in matches:
|
for scrapedurl, scrapedtitle in matches:
|
||||||
title = scrapedtitle
|
title = scrapedtitle
|
||||||
if item.seccion == 'generos':
|
if item.seccion == 'generos':
|
||||||
cant = re.sub(r'.*?<span class=cant-genre>','',scrapedtitle)
|
cant = re.sub(r'.*?<span class=cant-genre>','',scrapedtitle)
|
||||||
only_title = re.sub(r'<.*','',scrapedtitle).rstrip()
|
only_title = re.sub(r'<.*','',scrapedtitle).rstrip()
|
||||||
title = only_title+' (%s)'%cant
|
title = only_title+' (%s)'%cant
|
||||||
|
|
||||||
url = host+scrapedurl
|
url = host+scrapedurl
|
||||||
|
slug = scrapertools.find_single_match(scrapedurl, "%s(.*?)/" %pat)
|
||||||
|
if item.seccion in ['generos', 'anios']:
|
||||||
|
url = host + "/pagination/"
|
||||||
itemlist.append(
|
itemlist.append(
|
||||||
Item(channel=item.channel,
|
Item(action="list_all",
|
||||||
action="list_all",
|
channel=item.channel,
|
||||||
title=title,
|
|
||||||
fulltitle=item.title,
|
fulltitle=item.title,
|
||||||
url=url,
|
page = "1",
|
||||||
type = 'seccion'
|
slug = slug,
|
||||||
|
title=title,
|
||||||
|
type = type,
|
||||||
|
url=url
|
||||||
))
|
))
|
||||||
# Paginacion
|
# Paginacion
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user