+27
-4
@@ -92,7 +92,7 @@ def color(text, color):
|
||||
|
||||
|
||||
def scrape(item, patron = '', listGroups = [], headers="", blacklist="", data="", patron_block="",
|
||||
patronNext="", action="findvideos", addVideolibrary = True):
|
||||
patronNext="", action="findvideos", addVideolibrary = True, type_content_dict={}, type_action_dict={}):
|
||||
# patron: the patron to use for scraping page, all capturing group must match with listGroups
|
||||
# listGroups: a list containing the scraping info obtained by your patron, in order
|
||||
# accepted values are: url, title, thumb, quality, year, plot, duration, genre, rating, episode, lang
|
||||
@@ -114,6 +114,9 @@ def scrape(item, patron = '', listGroups = [], headers="", blacklist="", data=""
|
||||
# blacklist = 'Request a TV serie!'
|
||||
# return support.scrape(item, itemlist, patron, ['thumb', 'quality', 'url', 'title', 'year', 'plot', 'episode', 'lang'],
|
||||
# headers=headers, blacklist=blacklist)
|
||||
# 'type' is a check for typologies of content e.g. Film or TV Series
|
||||
# 'episode' is a key to grab episode numbers if it is separated from the title
|
||||
# IMPORTANT 'type' is a special key, to work need type_content_dict={} and type_action_dict={}
|
||||
|
||||
itemlist = []
|
||||
|
||||
@@ -194,6 +197,15 @@ def scrape(item, patron = '', listGroups = [], headers="", blacklist="", data=""
|
||||
if scraped["rating"]:
|
||||
infolabels['rating'] = scrapertoolsV2.decodeHtmlentities(scraped["rating"])
|
||||
|
||||
if type_content_dict:
|
||||
for name, variants in type_content_dict.items():
|
||||
if scraped['type'] in variants:
|
||||
item.contentType = name
|
||||
if type_action_dict:
|
||||
for name, variants in type_action_dict.items():
|
||||
if scraped['type'] in variants:
|
||||
action = name
|
||||
|
||||
if scraped["title"] not in blacklist:
|
||||
it = Item(
|
||||
channel=item.channel,
|
||||
@@ -456,7 +468,11 @@ def match(item, patron='', patron_block='', headers='', url=''):
|
||||
return matches, data
|
||||
|
||||
|
||||
def videolibrary(itemlist, item, typography=''):
|
||||
def videolibrary(itemlist, item, typography='', function_level=1):
|
||||
# Simply add this function to add video library support
|
||||
# Function_level is useful if the function is called by another function.
|
||||
# If the call is direct, leave it blank
|
||||
|
||||
if item.contentType != 'episode':
|
||||
action = 'add_pelicula_to_library'
|
||||
extra = 'findvideos'
|
||||
@@ -465,9 +481,12 @@ def videolibrary(itemlist, item, typography=''):
|
||||
action = 'add_serie_to_library'
|
||||
extra = 'episodios'
|
||||
contentType = 'tvshow'
|
||||
|
||||
if not typography: typography = 'color kod bold'
|
||||
|
||||
title = typo(config.get_localized_string(30161) + ' ' + typography)
|
||||
if inspect.stack()[1][3] == 'findvideos' and contentType == 'movie' or inspect.stack()[1][3] != 'findvideos' and contentType != 'movie':
|
||||
|
||||
if inspect.stack()[function_level][3] == 'findvideos' and contentType == 'movie' or inspect.stack()[function_level][3] != 'findvideos' and contentType != 'movie':
|
||||
if config.get_videolibrary_support() and len(itemlist) > 0:
|
||||
itemlist.append(
|
||||
Item(channel=item.channel,
|
||||
@@ -479,6 +498,7 @@ def videolibrary(itemlist, item, typography=''):
|
||||
extra=extra,
|
||||
contentTitle=item.fulltitle))
|
||||
|
||||
return itemlist
|
||||
|
||||
def nextPage(itemlist, item, data, patron, function_level=1):
|
||||
# Function_level is useful if the function is called by another function.
|
||||
@@ -535,11 +555,13 @@ def server(item, data='', itemlist='', headers='', AutoPlay=True, CheckLinks=Tru
|
||||
def controls(itemlist, item, AutoPlay=True, CheckLinks=True):
|
||||
from core import jsontools
|
||||
from platformcode.config import get_setting
|
||||
|
||||
CL = get_setting('checklinks') or get_setting('checklinks', item.channel)
|
||||
autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
|
||||
channel_node = autoplay_node.get(item.channel, {})
|
||||
settings_node = channel_node.get('settings', {})
|
||||
AP = get_setting('autoplay') or settings_node['active']
|
||||
|
||||
if CL and not AP:
|
||||
if get_setting('checklinks', item.channel):
|
||||
checklinks = get_setting('checklinks', item.channel)
|
||||
@@ -553,7 +575,8 @@ def controls(itemlist, item, AutoPlay=True, CheckLinks=True):
|
||||
|
||||
if AutoPlay == True:
|
||||
autoplay.start(itemlist, item)
|
||||
videolibrary(itemlist, item)
|
||||
|
||||
videolibrary(itemlist, item, function_level=3)
|
||||
return itemlist
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user