Introdotto deflang in scrape

Filtro all'aggiunta in videoteca per serie con più lingue e risoluzioni
This commit is contained in:
Alhaziel
2019-09-10 20:55:21 +02:00
parent b010155f31
commit d8b61a92bd
2 changed files with 122 additions and 63 deletions
+21 -16
View File
@@ -155,13 +155,16 @@ def scrapeLang(scraped, lang, longtitle):
## in ita e subita delle serie tv nella stessa pagina ## in ita e subita delle serie tv nella stessa pagina
# altrimenti dopo un sub-ita mette tutti quelli a seguire in sub-ita # altrimenti dopo un sub-ita mette tutti quelli a seguire in sub-ita
# e credo sia utile per filtertools # e credo sia utile per filtertools
lang = 'ITA' language = ''
if scraped['lang']: if scraped['lang']:
if 'ita' in scraped['lang'].lower():
language = 'ITA'
if 'sub' in scraped['lang'].lower(): if 'sub' in scraped['lang'].lower():
lang = 'Sub-ITA' language = 'Sub-' + language
## elif 'ita' in scraped['lang'].lower():
## lang = 'ITA' if not language: language = lang
longtitle += typo(lang, '_ [] color kod') if language: longtitle += typo(language, '_ [] color kod')
return lang, longtitle return lang, longtitle
@@ -169,7 +172,7 @@ def cleantitle(title):
cleantitle = scrapertoolsV2.htmlclean(scrapertoolsV2.decodeHtmlentities(title).replace('"', "'").replace('×', 'x').replace('', '-')).strip() cleantitle = scrapertoolsV2.htmlclean(scrapertoolsV2.decodeHtmlentities(title).replace('"', "'").replace('×', 'x').replace('', '-')).strip()
return cleantitle return cleantitle
def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, typeContentDict, typeActionDict, blacklist, search, pag, function): def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, typeContentDict, typeActionDict, blacklist, search, pag, function, lang):
itemlist = [] itemlist = []
log("scrapeBlock qui", block, patron) log("scrapeBlock qui", block, patron)
matches = scrapertoolsV2.find_multiple_matches_groups(block, patron) matches = scrapertoolsV2.find_multiple_matches_groups(block, patron)
@@ -179,7 +182,7 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
regexDbg(item, patron, headers, block) regexDbg(item, patron, headers, block)
known_keys = ['url', 'title', 'title2', 'episode', 'thumb', 'quality', 'year', 'plot', 'duration', 'genere', 'rating', 'type', 'lang'] known_keys = ['url', 'title', 'title2', 'episode', 'thumb', 'quality', 'year', 'plot', 'duration', 'genere', 'rating', 'type', 'lang']
lang = '' # aggiunto per gestire i siti con pagine di serietv dove si hanno i video in ita e in subita # lang = '' # aggiunto per gestire i siti con pagine di serietv dove si hanno i video in ita e in subita
for i, match in enumerate(matches): for i, match in enumerate(matches):
if pagination and (pag - 1) * pagination > i: continue # pagination if pagination and (pag - 1) * pagination > i: continue # pagination
if pagination and i >= pag * pagination: break # pagination if pagination and i >= pag * pagination: break # pagination
@@ -211,12 +214,14 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
longtitle = typo(longtitle, 'bold') longtitle = typo(longtitle, 'bold')
longtitle += (typo(Type,'_ () bold') if Type else '') + (typo(quality, '_ [] color kod') if quality else '') longtitle += (typo(Type,'_ () bold') if Type else '') + (typo(quality, '_ [] color kod') if quality else '')
# per togliere la voce [ITA] da liste che non siano titoli (es.: genere) # # per togliere la voce [ITA] da liste che non siano titoli (es.: genere)
if action != 'peliculas': # if action != 'peliculas':
lang, longtitle = scrapeLang(scraped, lang, longtitle) # lang, longtitle = scrapeLang(scraped, lang, longtitle)
else: # else:
longtitle = longtitle.replace('[ITA]','') # longtitle = longtitle.replace('[ITA]','')
lang = '' # lang = ''
lang, longtitle = scrapeLang(scraped, lang, longtitle)
# if title is set, probably this is a list of episodes or video sources # if title is set, probably this is a list of episodes or video sources
# necessaria l'aggiunta di == scraped["title"] altrimenti non prende i gruppi dopo le categorie # necessaria l'aggiunta di == scraped["title"] altrimenti non prende i gruppi dopo le categorie
@@ -338,7 +343,7 @@ def scrape(func):
debug = args['debug'] if 'debug' in args else False debug = args['debug'] if 'debug' in args else False
if 'pagination' in args: pagination = args['pagination'] if args['pagination'] else 20 if 'pagination' in args: pagination = args['pagination'] if args['pagination'] else 20
else: pagination = '' else: pagination = ''
lang = args['deflang'] if 'deflang' in args else ''
pag = item.page if item.page else 1 # pagination pag = item.page if item.page else 1 # pagination
matches = [] matches = []
@@ -355,7 +360,7 @@ def scrape(func):
block = "" block = ""
for bl in blocks: for bl in blocks:
blockItemlist, blockMatches = scrapeBlock(item, args, bl['block'], patron, headers, action, pagination, debug, blockItemlist, blockMatches = scrapeBlock(item, args, bl['block'], patron, headers, action, pagination, debug,
typeContentDict, typeActionDict, blacklist, search, pag, function) typeContentDict, typeActionDict, blacklist, search, pag, function, lang)
for it in blockItemlist: for it in blockItemlist:
if 'lang' in bl: if 'lang' in bl:
it.contentLanguage, it.title = scrapeLang(bl, it.contentLanguage, it.title) it.contentLanguage, it.title = scrapeLang(bl, it.contentLanguage, it.title)
@@ -367,7 +372,7 @@ def scrape(func):
matches.extend(blockMatches) matches.extend(blockMatches)
elif patron: elif patron:
itemlist, matches = scrapeBlock(item, args, data, patron, headers, action, pagination, debug, typeContentDict, itemlist, matches = scrapeBlock(item, args, data, patron, headers, action, pagination, debug, typeContentDict,
typeActionDict, blacklist, search, pag, function) typeActionDict, blacklist, search, pag, function, lang)
checkHost(item, itemlist) checkHost(item, itemlist)
+67 -13
View File
@@ -6,6 +6,7 @@
import errno import errno
import math import math
import traceback import traceback
import re
from core import filetools from core import filetools
from core import scraper from core import scraper
@@ -313,19 +314,72 @@ def save_tvshow(item, episodelist):
# FILTERTOOLS # FILTERTOOLS
# si el canal tiene filtro de idiomas, añadimos el canal y el show # si el canal tiene filtro de idiomas, añadimos el canal y el show
if episodelist and "list_language" in episodelist[0]: # if episodelist and "list_language" in episodelist[0]:
# si ya hemos añadido un canal previamente con filtro, añadimos o actualizamos el canal y show # # si ya hemos añadido un canal previamente con filtro, añadimos o actualizamos el canal y show
if "library_filter_show" in item_tvshow: # if "library_filter_show" in item_tvshow:
if item.title_from_channel: # if item.title_from_channel:
item_tvshow.library_filter_show[item.channel] = item.title_from_channel # item_tvshow.library_filter_show[item.channel] = item.title_from_channel
else: # else:
item_tvshow.library_filter_show[item.channel] = item.show # item_tvshow.library_filter_show[item.channel] = item.show
# no habia ningún canal con filtro y lo generamos por primera vez # # no habia ningún canal con filtro y lo generamos por primera vez
else: # else:
if item.title_from_channel: # if item.title_from_channel:
item_tvshow.library_filter_show = {item.channel: item.title_from_channel} # item_tvshow.library_filter_show = {item.channel: item.title_from_channel}
else: # else:
item_tvshow.library_filter_show = {item.channel: item.show} # item_tvshow.library_filter_show = {item.channel: item.show}
# SELECT EISODE BY LANG AND QUALITY
quality_dict = {"BLURAY": ["br", "bluray"],
"FULLHD": ["fullhd", "fullhd 1080", "fullhd 1080p", "full hd", "full hd 1080", "full hd 1080p", "hd1080", "hd1080p", "hd 1080", "hd 1080p", "1080", "1080p"],
"HD": ["hd", "hd720", "hd720p", "hd 720", "hd 720p", "720", "720p", "hdtv"],
"480P": ["sd", "480p", '480'],
"360P": ["360p", "360"],
"240P": ["240p", "240"]}
ep_list = []
lang_list = []
quality_list = []
# Make lang_list and Quality_list
for episode in episodelist:
if episode.contentLanguage and episode.contentLanguage not in lang_list: lang_list.append(episode.contentLanguage)
for name, var in quality_dict.items():
if not episode.quality and 'N/A' not in quality_list:
quality_list.append('N/A')
if episode.quality.lower() in var and name not in quality_list:
quality_list.append(name)
# if more than one language
if len(lang_list) > 1:
selection = platformtools.dialog_select(config.get_localized_string(70725),lang_list)
it = []
for episode in episodelist:
if episode.contentLanguage == lang_list[selection]:
it.append(episode)
episodelist = it
# if more than one quality
if len(quality_list) > 1:
selection = platformtools.dialog_select(config.get_localized_string(70726),quality_list)
stop = False
while not stop:
for episode in episodelist:
title = scrapertools.find_single_match(episode.title, '(\d+x\d+)')
if not any(title in word for word in ep_list) and episode.quality.lower() in quality_dict[quality_list[selection]]:
ep_list.append(episode.title)
if selection != 0: selection = selection - 1
else: stop = True
if quality_list[selection] == 'N/A':
for episode in episodelist:
title = scrapertools.find_single_match(episode.title, '(\d+x\d+)')
if not any(title in word for word in ep_list) and not episode.quality.lower():
ep_list.append(episode.title)
it = []
for episode in episodelist:
if episode.title in ep_list:
it.append(episode)
episodelist = it
if item.channel != "downloads": if item.channel != "downloads":
item_tvshow.active = 1 # para que se actualice a diario cuando se llame a videolibrary_service item_tvshow.active = 1 # para que se actualice a diario cuando se llame a videolibrary_service