No entendía el hilo, no sabía de dónde salían los quotes hasta que no he visto el Pull requests #39 del git oficial
Bueno, siguiendo la misma línea y dando por hecho que se habla de los dos hilos, voy a echarle una mano a neno.
Cuando neno dice "... el tema de los title ..." se refiere a esto:
Código: Seleccionar todo
## ----------------------------------------------------------------------------
## fix title para el patrón de películas para afinar mejor con la página que queremos,
## a ver quien es el guap@ que sabe que número de página es la buena :), ojalá
## fuese siempre la primera
def fix_title_for_filter_page(title):
title = title.replace('Parte I','Parte 1')
title = title.replace('Parte II','Parte 2')
title = title.replace('Parte III','Parte 3')
title = re.sub(r'Fast & Furious (\d) \(A todo gas \d\)', r'Fast & Furious \1', title)
title = re.sub(r'A todo gas (\d)', r'Fast & Furious \1', title)
title = title.replace('A todo gas', 'Fast & Furious')
return title
## Arregla el título para los arts. Nos guste o no,
## cada admin hace lo que le sale de sus caramelitos
def fix_title_for_arts(title):
logger.info("[playmax.py] fix_title_for_arts")
from platformcode.library import elimina_tildes
title = elimina_tildes(title)
title = re.sub(r'3D|,|#|;|SBS|-|Temporada|Torrent|^Ver|Online|Gratis','',title)
title = title.replace(' ','%20')
title = title.replace('Érase%20una%20vez','Erase%20una%20vez%20(2011)')
title = title.replace('Hawaii%20Five%200%20','hawaii%205.0')
title = title.replace('The%20Big%20Bang%20Theory','The%20Big%20Bang%20Theory%20%20')
title = title.replace('Castle','Castle%20(2009)')
return title
## ----------------------------------------------------------------------------
Parte que irá creciendo según se detecten títulos diferentes en las webs
Cuando neno dice "... valdría para fanart solo ..." se refiere ha esto
Código: Seleccionar todo
## -- arts --------------------------------------------------------------------
## Conseguir los arts de series o películas
def get_arts(title, tipo="2"):
logger.info("[playmax.py] fanart")
ret_arts = {}
## 1: Series, 2: Películas
arts = {
## Series
'1':{
## thetvdb.com
'url_title':'http://thetvdb.com/api/GetSeries.php?seriesname=%s&language=es',
'patron_title':'<Data><Series><seriesid>([^<]+)</seriesid>',
'url_id':'http://thetvdb.com/api/1D62F2F90030C444/series/%s/banners.xml',
'path_url_fanart':'http://thetvdb.com/banners/',
'patron_fanart':'<Banners><Banner>.*?<VignettePath>(.*?)</VignettePath>',
## themoviedb.org
'url_title_episodes':'http://api.themoviedb.org/3/search/tv?api_key=57983e31fb435df4df77afb854740ea9&query=%s&language=es&include_adult=false',
'url_title_episodes2':'http://api.themoviedb.org/3/tv/%s?api_key=57983e31fb435df4df77afb854740ea9&language=es&include_adult=false',
'url_title_episodes3':'http://api.themoviedb.org/3/tv/%s/season/%s?api_key=57983e31fb435df4df77afb854740ea9&language=es&include_adult=false',
'patron_title_episodes':'(\[\{"backdrop_path"[^\}]+\})',
'patron_title_episodes2':'("seasons":\[[^\]]+\])',
'path_url_backdrop':'https://image.tmdb.org/t/p/original/',
'path_url_poster':'https://image.tmdb.org/t/p/original/',
## fanart.tv
'url_id_others_arts':'http://assets.fanart.tv/v3/tv/%s?api_key=dffe90fba4d02c199ae7a9e71330c987',
'patron_others_arts':'"%s":.*?"url": "([^"]+)"',
'tags_others_arts':{
'clearlogo','tvposter','tvbanner','tvthumb','hdtvlogo','hdclearart','showbackground','clearart'
}
},
## Películas
'2':{
## themoviedb.org
'url_title':'http://api.themoviedb.org/3/search/movie?api_key=57983e31fb435df4df77afb854740ea9&query=%s&language=es&include_adult=false',
'patron_title':'("backdrop_path":"[^"]+",.*?,"id":\d+,.*?,"poster_path":"[^"]+",.*?,"title":"%s")' % fix_title_for_filter_page(title),
'path_url_backdrop':'https://image.tmdb.org/t/p/original/',
'path_url_poster':'https://image.tmdb.org/t/p/original/',
## fanart.tv
'url_id_others_arts':'http://assets.fanart.tv/v3/movies/%s?api_key=dffe90fba4d02c199ae7a9e71330c987',
'patron_others_arts':'"%s":.*?"url": "([^"]+)"',
'tags_others_arts':{
'hdmovielogo','moviedisc','movieposter','moviethumb','moviebanner','hdmovieclearart','moviebackground'
}
}
}
## Series y películas: Extrae la 'id' o 'data' usando el título de la ficha
## thetvdb.com
data = agrupa_datos(
scrapertools.cache_page( arts[tipo]['url_title'] % fix_title_for_arts(title) )
)
id_or_data = scrapertools.find_single_match( data, arts[tipo]['patron_title'] )
## themoviedb.org
data2 = agrupa_datos(
scrapertools.cache_page( arts[tipo]['url_title_episodes'] % fix_title_for_arts(title) )
)
id_or_data2 = scrapertools.find_single_match( data2, arts[tipo]['patron_title_episodes'] )
id2 = scrapertools.find_single_match( id_or_data2, '"id":(\d+)' )
data3 = agrupa_datos(
scrapertools.cache_page( arts[tipo]['url_title_episodes2'] % id2 )
)
id_or_data3 = scrapertools.find_single_match( data3, arts[tipo]['patron_title_episodes2'] )
## Series:
if tipo == "1":
## thetvdb.com
id = id_or_data
data = agrupa_datos(
scrapertools.cache_page( arts[tipo]['url_id'] % id )
)
ret_arts['fanart'] = scrapertools.find_single_match( data, arts[tipo]['patron_fanart'] )
if ret_arts['fanart'] != "":
ret_arts['fanart'] = urlparse.urljoin( arts[tipo]['path_url_fanart'], ret_arts['fanart'] )
## themoviedb.org
ret_arts['backdrop'] = scrapertools.find_single_match( id_or_data2, '"backdrop_path":"([^"]+)"' )
if ret_arts['backdrop'] != "":
ret_arts['backdrop'] = urlparse.urljoin( arts[tipo]['path_url_backdrop'], '.' + ret_arts['backdrop'] )
ret_arts['poster'] = scrapertools.find_single_match( id_or_data2, '"poster_path":"([^"]+)"' )
if ret_arts['poster'] != "":
ret_arts['poster'] = urlparse.urljoin( arts[tipo]['path_url_poster'], '.' + ret_arts['poster'] )
ret_arts['plot'] = scrapertools.find_single_match( id_or_data2, '"overview":"(.*?)",' )
patron = '"poster_path":"([^"]+)","season_number":(\d+)'
seasons = re.compile(patron,re.DOTALL).findall(id_or_data3)
for poster, season in seasons:
ret_arts['season-' + season + '-poster'] = urlparse.urljoin( arts[tipo]['path_url_poster'], '.' + poster )
data4 = agrupa_datos(
scrapertools.cache_page( arts[tipo]['url_title_episodes3'] % (id2, season) ).replace('\\', '')
)
patron = '"episode_number":(\d+),.*?,"overview":"(.*?)".*?"still_path":"([^"]+)"'
episodes = re.compile(patron,re.DOTALL).findall(data4)
for episode, plot, still in episodes:
ret_arts['season-' + season + '-episode-' + episode + '-plot'] = plot
ret_arts['season-' + season + '-episode-' + episode + '-still'] = urlparse.urljoin( arts[tipo]['path_url_poster'], '.' + still )
## Peículas:
if tipo == "2":
## api.themoviedb.org
id = scrapertools.find_single_match( id_or_data, '"id":(\d+)' )
ret_arts['backdrop'] = scrapertools.find_single_match( id_or_data, '"backdrop_path":"([^"]+)"' )
if ret_arts['backdrop'] != "":
ret_arts['backdrop'] = urlparse.urljoin( arts[tipo]['path_url_backdrop'], '.' + ret_arts['backdrop'] )
ret_arts['poster'] = scrapertools.find_single_match( id_or_data, '"poster_path":"([^"]+)"' )
if ret_arts['poster'] != "":
ret_arts['poster'] = urlparse.urljoin( arts[tipo]['path_url_poster'], '.' + ret_arts['poster'] )
## Series y Peículas: assets.fanart.tv
if id != "":
data = agrupa_datos(
scrapertools.cache_page( arts[tipo]['url_id_others_arts'] % id )
)
for tag_others_art in arts[tipo]['tags_others_arts']:
ret_arts[tag_others_art] = scrapertools.find_single_match( data, arts[tipo]['patron_others_arts'] % tag_others_art )
return ret_arts
## ----------------------------------------------------------------------------
Esto es lo que realmente ves en sus canales, sólo hay que dedicarle un poco de tiempo a lo que intenta hacer para verlo.
Y esto es lo que consigue su código recogido en una función.
Arts de la serie Big Bang:
http://robalo.esy.es/pelisalacarta/artes.html
Creo que no hará falta decir que es no está acabado, hay que segmentarlo para los tiempos de espera. Sólo es una muestra del trabajo de neno en sus canales pero sin el contenido del canal
