KoD 1.2
- aggiunto nuovo canale: guardaserie.cam - autoplay migliorato, ora i settaggi sono globali e non più per canale - adesso in onda riscritto, ora usa EPG (ringraziamo epg-guide.com) - Riprendi la visione di un film o episodio da server diversi (solo videoteca) - fix e ottimizzazioni varie
This commit is contained in:
+90
-561
@@ -1,83 +1,19 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
#from builtins import str
|
||||
import sys
|
||||
PY3 = False
|
||||
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
||||
from builtins import range
|
||||
|
||||
import os
|
||||
|
||||
from core import channeltools, jsontools
|
||||
from core import filetools, jsontools
|
||||
from core.item import Item
|
||||
from platformcode import config, logger, platformtools, launcher
|
||||
from platformcode import config, logger, platformtools
|
||||
from time import sleep
|
||||
from platformcode.config import get_setting
|
||||
|
||||
__channel__ = "autoplay"
|
||||
|
||||
PLAYED = False
|
||||
|
||||
autoplay_node = {}
|
||||
|
||||
colorKOD = '0xFF65B3DA'
|
||||
|
||||
|
||||
def context():
|
||||
'''
|
||||
Add the Configure AutoPlay option to the context menu
|
||||
|
||||
:return:
|
||||
'''
|
||||
|
||||
_context = ""
|
||||
|
||||
if config.is_xbmc():
|
||||
_context = [{"title": config.get_localized_string(60071),
|
||||
"action": "autoplay_config",
|
||||
"channel": "autoplay"}]
|
||||
return _context
|
||||
|
||||
|
||||
context = context()
|
||||
|
||||
|
||||
def show_option(channel, itemlist, text_color=colorKOD, thumbnail=None, fanart=None):
|
||||
'''
|
||||
Add the option Configure AutoPlay in the received list
|
||||
|
||||
:param channel: str
|
||||
:param itemlist: list (lista donde se desea integrar la opcion de configurar AutoPlay)
|
||||
:param text_color: str (color for the text of the option Configure Autoplay)
|
||||
:param thumbnail: str (address where the thumbnail is for the Configure Autoplay option)
|
||||
:return:
|
||||
'''
|
||||
from channelselector import get_thumb
|
||||
from core.support import typo
|
||||
logger.info()
|
||||
|
||||
if not config.is_xbmc():
|
||||
return itemlist
|
||||
|
||||
if thumbnail == None:
|
||||
thumbnail = get_thumb('autoplay.png')
|
||||
# if fanart == None:
|
||||
# fanart = get_thumb('autoplay.png')
|
||||
|
||||
plot_autoplay = config.get_localized_string(60399)
|
||||
itemlist.append(
|
||||
Item(channel=__channel__,
|
||||
title=typo(config.get_localized_string(60071), 'bold color kod'),
|
||||
action="autoplay_config",
|
||||
text_color=text_color,
|
||||
text_bold=True,
|
||||
thumbnail=thumbnail,
|
||||
# fanart=fanart,
|
||||
plot=plot_autoplay,
|
||||
from_channel=channel,
|
||||
folder=False
|
||||
))
|
||||
return itemlist
|
||||
quality_list = ['4k', '2160p', '2160', '4k2160p', '4k2160', '4k 2160p', '4k 2160', '2k',
|
||||
'fullhd', 'fullhd 1080', 'fullhd 1080p', 'full hd', 'full hd 1080', 'full hd 1080p', 'hd1080', 'hd1080p', 'hd 1080', 'hd 1080p', '1080', '1080p',
|
||||
'hd', 'hd720', 'hd720p', 'hd 720', 'hd 720p', '720', '720p', 'hdtv',
|
||||
'sd', '480p', '480', '360p', '360', '240p', '240',
|
||||
'default']
|
||||
|
||||
|
||||
def start(itemlist, item):
|
||||
@@ -90,68 +26,49 @@ def start(itemlist, item):
|
||||
:param item: item (the main item of the channel)
|
||||
:return: try to auto-reproduce, in case of failure it returns the itemlist that it received in the beginning
|
||||
'''
|
||||
|
||||
if item.global_search:
|
||||
return itemlist
|
||||
logger.info()
|
||||
|
||||
global PLAYED
|
||||
global autoplay_node
|
||||
PLAYED = False
|
||||
|
||||
base_item = item
|
||||
|
||||
|
||||
if not config.is_xbmc():
|
||||
# platformtools.dialog_notification('AutoPlay ERROR', 'Sólo disponible para XBMC/Kodi')
|
||||
return itemlist
|
||||
|
||||
if not autoplay_node:
|
||||
# Get AUTOPLAY node from json
|
||||
autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
|
||||
|
||||
channel_id = item.channel
|
||||
if item.channel == 'videolibrary':
|
||||
autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
|
||||
channel_id = item.contentChannel
|
||||
# try:
|
||||
# active = autoplay_node['status']
|
||||
# except:
|
||||
# active = is_active(item.channel)
|
||||
|
||||
if not channel_id in autoplay_node: # or not active:
|
||||
return itemlist
|
||||
|
||||
# Add servers and qualities not listed to autoplay_node
|
||||
new_options = check_value(channel_id, itemlist)
|
||||
|
||||
# Get the channel node from autoplay_node
|
||||
channel_node = autoplay_node.get(channel_id, {})
|
||||
# Get the autoplay settings for this channel
|
||||
settings_node = channel_node.get('settings', {})
|
||||
|
||||
if get_setting('autoplay') or settings_node['active']:
|
||||
if config.get_setting('autoplay'):
|
||||
url_list_valid = []
|
||||
autoplay_list = []
|
||||
autoplay_b = []
|
||||
favorite_langs = []
|
||||
favorite_servers = []
|
||||
favorite_quality = []
|
||||
|
||||
# 2nd lang, see if you want to filter or not
|
||||
status_language = config.get_setting("filter_languages", channel_id)
|
||||
|
||||
blacklisted_servers = config.get_setting('black_list', server='servers')
|
||||
if not blacklisted_servers:
|
||||
config.set_setting('black_list', [], server='servers')
|
||||
blacklisted_servers = []
|
||||
favorite_servers = config.get_setting('favorites_servers_list', server='servers')
|
||||
if not favorite_servers:
|
||||
config.set_setting('favorites_servers_list', [], server='servers')
|
||||
favorite_servers = []
|
||||
else:
|
||||
favorite_servers = list(set(favorite_servers) - set(blacklisted_servers))
|
||||
|
||||
# Save the current value of "Action and Player Mode" in preferences
|
||||
user_config_setting_action = config.get_setting("default_action")
|
||||
user_config_setting_player = config.get_setting("player_mode")
|
||||
# Enable the "View in high quality" action (if the server returns more than one quality, eg gdrive)
|
||||
if user_config_setting_action != 2:
|
||||
config.set_setting("default_action", 2)
|
||||
if user_config_setting_player != 0:
|
||||
config.set_setting("player_mode", 0)
|
||||
|
||||
# Report that AutoPlay is active
|
||||
# platformtools.dialog_notification('AutoPlay Activo', '', sound=False)
|
||||
# Enable the "View in high quality" action (if the server returns more than one quality, eg gdrive)
|
||||
if not user_config_setting_action: config.set_setting("default_action", 2)
|
||||
|
||||
if user_config_setting_player != 0: config.set_setting("player_mode", 0)
|
||||
|
||||
# Priorities when ordering itemlist:
|
||||
# 0: Servers and qualities
|
||||
@@ -159,131 +76,121 @@ def start(itemlist, item):
|
||||
# 2: Servers only
|
||||
# 3: Only qualities
|
||||
# 4: Do not order
|
||||
if (settings_node['custom_servers'] and settings_node['custom_quality']) or get_setting('autoplay'):
|
||||
priority = settings_node['priority'] # 0: Servers and qualities or 1: Qualities and servers
|
||||
elif settings_node['custom_servers']:
|
||||
if config.get_setting('favorites_servers') and favorite_servers and config.get_setting('default_action'):
|
||||
priority = 0 # 0: Servers and qualities or 1: Qualities and servers
|
||||
elif config.get_setting('favorites_servers') and favorite_servers:
|
||||
priority = 2 # Servers only
|
||||
elif settings_node['custom_quality']:
|
||||
elif config.get_setting('default_action'):
|
||||
priority = 3 # Only qualities
|
||||
else:
|
||||
priority = 4 # Do not order
|
||||
|
||||
# Get server lists, qualities available from AutoPlay json node
|
||||
server_list = channel_node.get('servers', [])
|
||||
for server in server_list:
|
||||
server = server.lower()
|
||||
quality_list = channel_node.get('quality', [])
|
||||
if config.get_setting('default_action') == 1:
|
||||
quality_list.reverse()
|
||||
favorite_quality = quality_list
|
||||
|
||||
# If no qualities are defined, default is assigned as unique quality.
|
||||
if len(quality_list) == 0:
|
||||
quality_list =['default']
|
||||
|
||||
# The texts of each server and quality are stored in lists, e.g. favorite_servers = ['verystream', 'openload', 'streamcloud']
|
||||
for num in range(1, 4):
|
||||
favorite_servers.append(channel_node['servers'][settings_node['server_%s' % num]].lower())
|
||||
favorite_quality.append(channel_node['quality'][settings_node['quality_%s' % num]])
|
||||
|
||||
# Itemlist links are filtered and correspond to autoplay values
|
||||
for n, item in enumerate(itemlist):
|
||||
for item in itemlist:
|
||||
autoplay_elem = dict()
|
||||
b_dict = dict()
|
||||
|
||||
# We check that it is a video item
|
||||
if 'server' not in item:
|
||||
continue
|
||||
# 2nd lang language list
|
||||
if item.language not in favorite_langs:
|
||||
favorite_langs.append(item.language)
|
||||
|
||||
# Add the option to configure AutoPlay to the context menu
|
||||
if 'context' not in item:
|
||||
item.context = list()
|
||||
if not [x for x in context if x['action'] == 'autoplay_config']:
|
||||
item.context.append({"title": config.get_localized_string(60071),
|
||||
"action": "autoplay_config",
|
||||
"channel": "autoplay",
|
||||
"from_channel": channel_id})
|
||||
if item.server.lower() in blacklisted_servers:
|
||||
continue
|
||||
|
||||
# If it does not have a defined quality, it assigns a 'default' quality.
|
||||
if item.quality == '':
|
||||
if item.quality not in quality_list:
|
||||
item.quality = 'default'
|
||||
|
||||
# The list for custom settings is created
|
||||
|
||||
if priority < 2: # 0: Servers and qualities or 1: Qualities and servers
|
||||
|
||||
# if the server and the quality are not in the favorites lists or the url is repeated, we discard the item
|
||||
if item.server.lower() not in favorite_servers or item.quality not in favorite_quality \
|
||||
or item.url in url_list_valid:
|
||||
if item.server.lower() not in favorite_servers or item.quality.lower() not in favorite_quality or item.url in url_list_valid:
|
||||
item.type_b = True
|
||||
item.play_from = base_item.play_from
|
||||
b_dict['videoitem']= item
|
||||
autoplay_b.append(b_dict)
|
||||
continue
|
||||
autoplay_elem["indice_lang"] = favorite_langs.index(item.language)
|
||||
autoplay_elem["indice_server"] = favorite_servers.index(item.server.lower())
|
||||
autoplay_elem["indice_quality"] = favorite_quality.index(item.quality)
|
||||
autoplay_elem["indice_quality"] = favorite_quality.index(item.quality.lower())
|
||||
|
||||
elif priority == 2: # Servers only
|
||||
|
||||
# if the server is not in the favorites list or the url is repeated, we discard the item
|
||||
if item.server.lower() not in favorite_servers or item.url in url_list_valid:
|
||||
item.type_b = True
|
||||
item.play_from = base_item.play_from
|
||||
b_dict['videoitem'] = item
|
||||
autoplay_b.append(b_dict)
|
||||
continue
|
||||
autoplay_elem["indice_lang"] = favorite_langs.index(item.language)
|
||||
autoplay_elem["indice_server"] = favorite_servers.index(item.server.lower())
|
||||
|
||||
elif priority == 3: # Solo calidades
|
||||
elif priority == 3: # Only qualities
|
||||
|
||||
# if the quality is not in the favorites list or the url is repeated, we discard the item
|
||||
if item.quality not in favorite_quality or item.url in url_list_valid:
|
||||
if item.quality.lower() not in favorite_quality or item.url in url_list_valid:
|
||||
item.type_b = True
|
||||
item.play_from = base_item.play_from
|
||||
b_dict['videoitem'] = item
|
||||
autoplay_b.append(b_dict)
|
||||
continue
|
||||
autoplay_elem["indice_lang"] = favorite_langs.index(item.language)
|
||||
autoplay_elem["indice_quality"] = favorite_quality.index(item.quality)
|
||||
autoplay_elem["indice_quality"] = favorite_quality.index(item.quality.lower())
|
||||
|
||||
else: # Do not order
|
||||
|
||||
# if the url is repeated, we discard the item
|
||||
item.play_from = base_item.play_from
|
||||
if item.url in url_list_valid:
|
||||
continue
|
||||
|
||||
# If the item reaches here we add it to the list of valid urls and to autoplay_list
|
||||
url_list_valid.append(item.url)
|
||||
item.plan_b=True
|
||||
item.play_from = base_item.play_from
|
||||
autoplay_elem['videoitem'] = item
|
||||
# autoplay_elem['server'] = item.server
|
||||
# autoplay_elem['quality'] = item.quality
|
||||
autoplay_list.append(autoplay_elem)
|
||||
|
||||
# We order according to priority
|
||||
if priority == 0: # Servers and qualities
|
||||
autoplay_list.sort(key=lambda orden: (orden['indice_lang'], orden['indice_server'], orden['indice_quality']))
|
||||
if priority == 0: autoplay_list.sort(key=lambda orden: (orden['indice_quality'], orden['indice_server'])) # Servers and qualities
|
||||
elif priority == 1: autoplay_list.sort(key=lambda orden: (orden['indice_quality'], orden['indice_server'])) # Qualities and servers
|
||||
elif priority == 2: autoplay_list.sort(key=lambda orden: (orden['indice_server'])) # Servers only
|
||||
elif priority == 3: autoplay_list.sort(key=lambda orden: (orden['indice_quality'])) # Only qualities
|
||||
|
||||
elif priority == 1: # Qualities and servers
|
||||
autoplay_list.sort(key=lambda orden: (orden['indice_lang'], orden['indice_quality'], orden['indice_server']))
|
||||
# if quality priority is active
|
||||
if priority == 0 and config.get_setting('quality_priority'):
|
||||
max_quality = autoplay_list[0]["indice_quality"] if autoplay_list and "indice_quality" in autoplay_list[0] else 0
|
||||
for n, item in enumerate(itemlist):
|
||||
if 'server' not in item:
|
||||
continue
|
||||
|
||||
elif priority == 2: # Servers only
|
||||
autoplay_list.sort(key=lambda orden: (orden['indice_lang'], orden['indice_server']))
|
||||
if item.server.lower() in blacklisted_servers:
|
||||
continue
|
||||
|
||||
elif priority == 3: # Only qualities
|
||||
autoplay_list.sort(key=lambda orden: (orden['indice_lang'], orden['indice_quality']))
|
||||
# If it does not have a defined quality, it assigns a 'default' quality.
|
||||
if item.quality == '':
|
||||
item.quality = 'default'
|
||||
|
||||
if favorite_quality.index(item.quality.lower()) < max_quality:
|
||||
item.type_b = False
|
||||
autoplay_elem["indice_server"] = n
|
||||
autoplay_elem["indice_quality"] = favorite_quality.index(item.quality.lower())
|
||||
autoplay_elem['videoitem'] = item
|
||||
autoplay_list.append(autoplay_elem)
|
||||
autoplay_list.sort(key=lambda orden: (orden['indice_quality'], orden['indice_server']))
|
||||
|
||||
# Plan b is prepared, in case it is active the non-favorite elements are added at the end
|
||||
try:
|
||||
plan_b = settings_node['plan_b']
|
||||
except:
|
||||
plan_b = True
|
||||
# try: plan_b = settings_node['plan_b']
|
||||
# except:
|
||||
plan_b = True
|
||||
text_b = ''
|
||||
if plan_b:
|
||||
autoplay_list.extend(autoplay_b)
|
||||
if plan_b: autoplay_list.extend(autoplay_b)
|
||||
# If there are elements in the autoplay list, an attempt is made to reproduce each element, until one is found or all fail.
|
||||
|
||||
if autoplay_list or (plan_b and autoplay_b):
|
||||
|
||||
# played = False
|
||||
max_intentos = 5
|
||||
max_intentos_servers = {}
|
||||
|
||||
@@ -309,35 +216,25 @@ def start(itemlist, item):
|
||||
lang = " "
|
||||
if hasattr(videoitem, 'language') and videoitem.language != "":
|
||||
lang = " '%s' " % videoitem.language
|
||||
|
||||
platformtools.dialog_notification("AutoPlay %s" %text_b, "%s%s%s" % (
|
||||
videoitem.server.upper(), lang, videoitem.quality.upper()), sound=False)
|
||||
# TODO videoitem.server is the id of the server, but it might not be the name !!!
|
||||
name = servername(videoitem.server)
|
||||
platformtools.dialog_notification("AutoPlay %s" %text_b, "%s%s%s" % (name, lang, videoitem.quality.upper()), sound=False)
|
||||
|
||||
# Try to play the links If the channel has its own play method, use it
|
||||
try:
|
||||
channel = __import__('channels.%s' % channel_id, None, None, ["channels.%s" % channel_id])
|
||||
except:
|
||||
channel = __import__('specials.%s' % channel_id, None, None, ["specials.%s" % channel_id])
|
||||
try: channel = __import__('channels.%s' % channel_id, None, None, ["channels.%s" % channel_id])
|
||||
except: channel = __import__('specials.%s' % channel_id, None, None, ["specials.%s" % channel_id])
|
||||
if hasattr(channel, 'play'):
|
||||
resolved_item = getattr(channel, 'play')(videoitem)
|
||||
if len(resolved_item) > 0:
|
||||
if isinstance(resolved_item[0], list):
|
||||
videoitem.video_urls = resolved_item
|
||||
else:
|
||||
videoitem = resolved_item[0]
|
||||
if isinstance(resolved_item[0], list): videoitem.video_urls = resolved_item
|
||||
else: videoitem = resolved_item[0]
|
||||
|
||||
# If not directly reproduce and mark as seen
|
||||
|
||||
#Check if the item comes from the video library
|
||||
# Check if the item comes from the video library
|
||||
try:
|
||||
if base_item.contentChannel =='videolibrary':
|
||||
# Mark as seen
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.mark_auto_as_watched(base_item)
|
||||
if base_item.contentChannel == 'videolibrary' or base_item.nfo:
|
||||
# Fill the video with the data of the main item and play
|
||||
play_item = base_item.clone(url=videoitem)
|
||||
platformtools.play_video(play_item.url, autoplay=True)
|
||||
play_item = base_item.clone(**videoitem.__dict__)
|
||||
platformtools.play_video(play_item, autoplay=True)
|
||||
else:
|
||||
# If it doesn't come from the video library, just play
|
||||
platformtools.play_video(videoitem, autoplay=True)
|
||||
@@ -356,400 +253,31 @@ def start(itemlist, item):
|
||||
|
||||
# If the maximum number of attempts of this server has been reached, ask if we want to continue testing or ignore it.
|
||||
if max_intentos_servers[videoitem.server.lower()] == 0:
|
||||
text = config.get_localized_string(60072) % videoitem.server.upper()
|
||||
text = config.get_localized_string(60072) % name
|
||||
if not platformtools.dialog_yesno("AutoPlay", text, config.get_localized_string(60073)):
|
||||
max_intentos_servers[videoitem.server.lower()] = max_intentos
|
||||
|
||||
# If there are no items in the list, it is reported
|
||||
if autoplay_elem == autoplay_list[-1]:
|
||||
platformtools.dialog_notification('AutoPlay', config.get_localized_string(60072) % videoitem.server.upper())
|
||||
platformtools.dialog_notification('AutoPlay', config.get_localized_string(60072) % name)
|
||||
|
||||
else:
|
||||
platformtools.dialog_notification(config.get_localized_string(60074), config.get_localized_string(60075))
|
||||
if new_options:
|
||||
platformtools.dialog_notification("AutoPlay", config.get_localized_string(60076), sound=False)
|
||||
|
||||
# Restore if necessary the previous value of "Action and Player Mode" in preferences
|
||||
if user_config_setting_action != 2:
|
||||
config.set_setting("default_action", user_config_setting_action)
|
||||
if user_config_setting_player != 0:
|
||||
config.set_setting("player_mode", user_config_setting_player)
|
||||
if not user_config_setting_action: config.set_setting("default_action", user_config_setting_action)
|
||||
if user_config_setting_player != 0: config.set_setting("player_mode", user_config_setting_player)
|
||||
|
||||
return itemlist
|
||||
|
||||
|
||||
def init(channel, list_servers, list_quality, reset=False):
|
||||
'''
|
||||
Check the existence of a channel in the Autoplay configuration file and if it does not exist, add it.
|
||||
It is necessary to call this function when entering any channel that includes the Autoplay function.
|
||||
|
||||
:param channel: (str) channel id
|
||||
:param list_servers: (list) initial list of valid servers for the channel. It is not necessary to include them all,
|
||||
since the list of valid servers will be updated dynamically.
|
||||
:param list_quality: (list) initial list of valid qualities for the channel. It is not necessary to include them all,
|
||||
since the list of valid qualities will be updated dynamically.
|
||||
:return: (bool) True if the initialization was successful.
|
||||
'''
|
||||
logger.info()
|
||||
change = False
|
||||
result = True
|
||||
|
||||
|
||||
if not config.is_xbmc():
|
||||
# platformtools.dialog_notification('AutoPlay ERROR', 'Sólo disponible para XBMC/Kodi')
|
||||
result = False
|
||||
else:
|
||||
autoplay_path = os.path.join(config.get_data_path(), "settings_channels", 'autoplay_data.json')
|
||||
if os.path.exists(autoplay_path):
|
||||
autoplay_node = jsontools.get_node_from_file('autoplay', "AUTOPLAY")
|
||||
else:
|
||||
change = True
|
||||
autoplay_node = {"AUTOPLAY": {}}
|
||||
|
||||
if channel not in autoplay_node or reset:
|
||||
change = True
|
||||
|
||||
# It is verified that there are no duplicate qualities or servers
|
||||
if 'default' not in list_quality:
|
||||
list_quality.append('default')
|
||||
# list_servers = list(set(list_servers))
|
||||
# list_quality = list(set(list_quality))
|
||||
|
||||
# We create the channel node and add it
|
||||
channel_node = {"servers": list_servers,
|
||||
"quality": list_quality,
|
||||
"settings": {
|
||||
"active": False,
|
||||
"hide_servers": False,
|
||||
"plan_b": True,
|
||||
"custom_servers": False,
|
||||
"custom_quality": False,
|
||||
"priority": 0}}
|
||||
for n in range(1, 4):
|
||||
s = c = 0
|
||||
if len(list_servers) >= n:
|
||||
s = n - 1
|
||||
if len(list_quality) >= n:
|
||||
c = n - 1
|
||||
|
||||
channel_node["settings"]["server_%s" % n] = s
|
||||
channel_node["settings"]["quality_%s" % n] = c
|
||||
autoplay_node[channel] = channel_node
|
||||
|
||||
if change:
|
||||
result, json_data = jsontools.update_node(autoplay_node, 'autoplay', 'AUTOPLAY')
|
||||
|
||||
if not result:
|
||||
heading = config.get_localized_string(60077)
|
||||
msj = config.get_localized_string(60078)
|
||||
|
||||
platformtools.dialog_notification(heading, msj, sound=False)
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def check_value(channel, itemlist):
|
||||
'''
|
||||
checks the existence of a value in the list of servers or qualities if it does not exist adds them to the list in the json
|
||||
|
||||
:param channel: str
|
||||
:param values: list (one of servers or qualities)
|
||||
:param value_type: str (server o quality)
|
||||
:return: list
|
||||
'''
|
||||
logger.info()
|
||||
global autoplay_node
|
||||
change = False
|
||||
|
||||
if not autoplay_node:
|
||||
# Get AUTOPLAY node from json
|
||||
autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
|
||||
|
||||
channel_node = autoplay_node.get(channel)
|
||||
|
||||
server_list = channel_node.get('servers')
|
||||
if not server_list:
|
||||
server_list = channel_node['servers'] = list()
|
||||
|
||||
quality_list = channel_node.get('quality')
|
||||
if not quality_list:
|
||||
quality_list = channel_node['quality'] = list()
|
||||
|
||||
for item in itemlist:
|
||||
if item.server.lower() not in server_list and item.server !='':
|
||||
server_list.append(item.server.lower())
|
||||
change = True
|
||||
if item.quality not in quality_list and item.quality !='':
|
||||
quality_list.append(item.quality)
|
||||
change = True
|
||||
|
||||
if change:
|
||||
change, json_data = jsontools.update_node(autoplay_node, 'autoplay', 'AUTOPLAY')
|
||||
|
||||
return change
|
||||
|
||||
|
||||
def autoplay_config(item):
|
||||
logger.info()
|
||||
global autoplay_node
|
||||
dict_values = {}
|
||||
list_controls = []
|
||||
channel_parameters = channeltools.get_channel_parameters(item.from_channel)
|
||||
channel_name = channel_parameters['title']
|
||||
|
||||
if not autoplay_node:
|
||||
# Get AUTOPLAY node from json
|
||||
autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
|
||||
|
||||
channel_node = autoplay_node.get(item.from_channel, {})
|
||||
settings_node = channel_node.get('settings', {})
|
||||
|
||||
allow_option = True
|
||||
|
||||
active_settings = {"id": "active", "label": config.get_localized_string(60079), "type": "bool",
|
||||
"default": False, "enabled": allow_option, "visible": allow_option}
|
||||
|
||||
list_controls.append(active_settings)
|
||||
dict_values['active'] = settings_node.get('active', False)
|
||||
|
||||
hide_servers = {"id": "hide_servers", "label": config.get_localized_string(70747), "type": "bool",
|
||||
"default": False, "enabled": "eq(-" + str(len(list_controls)) + ",true)", "visible": allow_option}
|
||||
|
||||
list_controls.append(hide_servers)
|
||||
dict_values['hide_servers'] = settings_node.get('hide_servers', False)
|
||||
|
||||
# Language
|
||||
status_language = config.get_setting("filter_languages", item.from_channel)
|
||||
if not status_language:
|
||||
status_language = 0
|
||||
|
||||
set_language = {"id": "language", "label": config.get_localized_string(60080),
|
||||
"type": "list", "default": 0, "enabled": "eq(-" + str(len(list_controls)) + ",true)", "visible": True,
|
||||
"lvalues": get_languages(item.from_channel)}
|
||||
|
||||
list_controls.append(set_language)
|
||||
dict_values['language'] = status_language
|
||||
|
||||
separador = {"id": "label", "label": " "
|
||||
"_________________________________________________________________________________________",
|
||||
"type": "label", "enabled": True, "visible": True}
|
||||
list_controls.append(separador)
|
||||
|
||||
# Favorite servers section
|
||||
server_list = channel_node.get("servers", [])
|
||||
if not server_list:
|
||||
enabled = False
|
||||
server_list = ["No disponible"]
|
||||
else:
|
||||
enabled = "eq(-" + str(len(list_controls)) + ",true)"
|
||||
|
||||
custom_servers_settings = {"id": "custom_servers", "label": config.get_localized_string(60081),
|
||||
"type": "bool", "default": False, "enabled": enabled, "visible": True}
|
||||
custom_servers_pos = len(list_controls)
|
||||
list_controls.append(custom_servers_settings)
|
||||
if dict_values['active'] and enabled:
|
||||
dict_values['custom_servers'] = settings_node.get('custom_servers', False)
|
||||
else:
|
||||
dict_values['custom_servers'] = False
|
||||
|
||||
for num in range(1, 4):
|
||||
pos1 = num + custom_servers_pos
|
||||
default = num - 1
|
||||
if default > len(server_list) - 1:
|
||||
default = 0
|
||||
set_servers = {"id": "server_%s" % num, "label": u" \u2665" + config.get_localized_string(60082) % num,
|
||||
"type": "list", "default": default,
|
||||
"enabled": "eq(-%s,true)+eq(-%s,true)" % (pos1, num), "visible": True,
|
||||
"lvalues": server_list}
|
||||
list_controls.append(set_servers)
|
||||
|
||||
dict_values["server_%s" % num] = settings_node.get("server_%s" % num, 0)
|
||||
if settings_node.get("server_%s" % num, 0) > len(server_list) - 1:
|
||||
dict_values["server_%s" % num] = 0
|
||||
|
||||
# Favorite Qualities Section
|
||||
quality_list = channel_node.get("quality", [])
|
||||
if not quality_list:
|
||||
enabled = False
|
||||
quality_list = ["No disponible"]
|
||||
else:
|
||||
enabled = "eq(-" + str(len(list_controls)) + ",true)"
|
||||
|
||||
custom_quality_settings = {"id": "custom_quality", "label": config.get_localized_string(60083), "type": "bool", "default": False, "enabled": enabled, "visible": True}
|
||||
custom_quality_pos = len(list_controls)
|
||||
list_controls.append(custom_quality_settings)
|
||||
if dict_values['active'] and enabled:
|
||||
dict_values['custom_quality'] = settings_node.get('custom_quality', False)
|
||||
else:
|
||||
dict_values['custom_quality'] = False
|
||||
|
||||
for num in range(1, 4):
|
||||
pos1 = num + custom_quality_pos
|
||||
default = num - 1
|
||||
if default > len(quality_list) - 1:
|
||||
default = 0
|
||||
|
||||
set_quality = {"id": "quality_%s" % num, "label": u" \u2665 " + config.get_localized_string(707417) + " %s" % num,
|
||||
"type": "list", "default": default,
|
||||
"enabled": "eq(-%s,true)+eq(-%s,true)" % (pos1, num), "visible": True,
|
||||
"lvalues": quality_list}
|
||||
list_controls.append(set_quality)
|
||||
dict_values["quality_%s" % num] = settings_node.get("quality_%s" % num, 0)
|
||||
if settings_node.get("quality_%s" % num, 0) > len(quality_list) - 1:
|
||||
dict_values["quality_%s" % num] = 0
|
||||
|
||||
# Plan B
|
||||
dict_values['plan_b'] = settings_node.get('plan_b', False)
|
||||
enabled = "eq(-" + str(custom_servers_pos) + ",true)|eq(-" + str(custom_quality_pos) + ",true)"
|
||||
plan_b = {"id": "plan_b", "label": config.get_localized_string(70172),"type": "bool", "default": False, "enabled": enabled, "visible": True}
|
||||
list_controls.append(plan_b)
|
||||
|
||||
|
||||
# Priorities Section
|
||||
priority_list = [config.get_localized_string(70174), config.get_localized_string(70175)]
|
||||
set_priority = {"id": "priority", "label": config.get_localized_string(60085), "type": "list", "default": 0,
|
||||
"enabled": True, "visible": "eq(-5,true)+eq(-9,true)+eq(-12,true)", "lvalues": priority_list}
|
||||
list_controls.append(set_priority)
|
||||
dict_values["priority"] = settings_node.get("priority", 0)
|
||||
|
||||
|
||||
|
||||
# Open dialog box
|
||||
platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, callback='save',
|
||||
item=item, caption='%s - AutoPlay' % channel_name,
|
||||
custom_button={'visible': True,
|
||||
'function': "reset",
|
||||
'close': True,
|
||||
'label': 'Reset'})
|
||||
|
||||
|
||||
def save(item, dict_data_saved):
|
||||
'''
|
||||
Save the data from the configuration window
|
||||
|
||||
:param item: item
|
||||
:param dict_data_saved: dict
|
||||
:return:
|
||||
'''
|
||||
logger.info()
|
||||
global autoplay_node
|
||||
|
||||
if not autoplay_node:
|
||||
# Get AUTOPLAY node from json
|
||||
autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
|
||||
|
||||
new_config = dict_data_saved
|
||||
if not new_config['active']:
|
||||
new_config['language']=0
|
||||
channel_node = autoplay_node.get(item.from_channel)
|
||||
config.set_setting("filter_languages", dict_data_saved.pop("language"), item.from_channel)
|
||||
channel_node['settings'] = dict_data_saved
|
||||
|
||||
result, json_data = jsontools.update_node(autoplay_node, 'autoplay', 'AUTOPLAY')
|
||||
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def get_languages(channel):
|
||||
'''
|
||||
Get the languages from the channel's json
|
||||
|
||||
:param channel: str
|
||||
:return: list
|
||||
'''
|
||||
logger.info()
|
||||
list_language = ['Non filtrare']
|
||||
list_controls, dict_settings = channeltools.get_channel_controls_settings(channel)
|
||||
for control in list_controls:
|
||||
try:
|
||||
if control["id"] == 'filter_languages':
|
||||
list_language = control["lvalues"]
|
||||
except:
|
||||
pass
|
||||
|
||||
return list_language
|
||||
|
||||
|
||||
def is_active(channel):
|
||||
'''
|
||||
Returns a boolean that indicates whether or not autoplay is active on the channel from which it is called
|
||||
|
||||
:return:True if autoplay is active for the channel from which it is called, False otherwise.
|
||||
'''
|
||||
logger.info()
|
||||
global autoplay_node
|
||||
|
||||
if not config.is_xbmc():
|
||||
return False
|
||||
|
||||
if not autoplay_node:
|
||||
# Get AUTOPLAY node from json
|
||||
autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
|
||||
|
||||
# Get the channel from which the call is made
|
||||
#import inspect
|
||||
#module = inspect.getmodule(inspect.currentframe().f_back)
|
||||
#canal = module.__name__.split('.')[1]
|
||||
canal = channel
|
||||
|
||||
# Get the channel node from autoplay_node
|
||||
channel_node = autoplay_node.get(canal, {})
|
||||
# Get the autoplay settings for this channel
|
||||
settings_node = channel_node.get('settings', {})
|
||||
|
||||
return settings_node.get('active', False) or get_setting('autoplay')
|
||||
|
||||
|
||||
def reset(item, dict):
|
||||
|
||||
channel_name = item.from_channel
|
||||
channel = __import__('channels.%s' % channel_name, fromlist=["channels.%s" % channel_name])
|
||||
list_servers = channel.list_servers
|
||||
list_quality = channel.list_quality
|
||||
|
||||
init(channel_name, list_servers, list_quality, reset=True)
|
||||
platformtools.dialog_notification('AutoPlay', config.get_localized_string(70523) % item.category)
|
||||
|
||||
return
|
||||
|
||||
# def set_status(status):
|
||||
# logger.info()
|
||||
# # Get AUTOPLAY node from json
|
||||
# autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
|
||||
# autoplay_node['status'] = status
|
||||
#
|
||||
# result, json_data = jsontools.update_node(autoplay_node, 'autoplay', 'AUTOPLAY')
|
||||
|
||||
# return if item channel has autoplay and hideserver enabled
|
||||
def get_channel_AP_HS(item):
|
||||
autoplay_node = jsontools.get_node_from_file('autoplay', 'AUTOPLAY')
|
||||
channel_node = autoplay_node.get(item.channel, {})
|
||||
if not channel_node: # never opened the channel menu so in autoplay_data.json there is no key
|
||||
try:
|
||||
channelFile = __import__('channels.' + item.channel, fromlist=["channels.%s" % item.channel])
|
||||
except:
|
||||
channelFile = __import__('specials.' + item.channel, fromlist=["specials.%s" % item.channel])
|
||||
if hasattr(channelFile, 'list_servers') and hasattr(channelFile, 'list_quality'):
|
||||
init(item.channel, channelFile.list_servers, channelFile.list_quality)
|
||||
|
||||
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 'active' in settings_node else False)
|
||||
HS = config.get_setting('hide_servers') or (
|
||||
settings_node['hide_servers'] if 'hide_server' in settings_node else False)
|
||||
|
||||
return AP, HS
|
||||
|
||||
def play_multi_channel(item, itemlist):
|
||||
logger.info()
|
||||
global PLAYED
|
||||
video_dict = dict()
|
||||
# set_status(True)
|
||||
|
||||
for video_item in itemlist:
|
||||
if is_active(video_item.contentChannel):
|
||||
if config.get_setting('autoplay'):
|
||||
if video_item.contentChannel not in video_dict.keys():
|
||||
video_dict[video_item.contentChannel] = [video_item]
|
||||
else:
|
||||
@@ -762,5 +290,6 @@ def play_multi_channel(item, itemlist):
|
||||
else:
|
||||
break
|
||||
|
||||
AP, HS = get_channel_AP_HS(item)
|
||||
return HS
|
||||
def servername(server):
|
||||
path = filetools.join(config.get_runtime_path(), 'servers', server.lower() + '.json')
|
||||
return jsontools.load(open(path, "r").read())['name'].upper()
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
# Backup and restore video library
|
||||
# ------------------------------------------------------------
|
||||
|
||||
import datetime, xbmc
|
||||
import datetime, xbmc
|
||||
|
||||
from core import ziptools, videolibrarytools, filetools
|
||||
from platformcode import logger, config, platformtools, xbmc_videolibrary
|
||||
|
||||
+16
-6
@@ -174,7 +174,7 @@ def peliculas(item, json='', key='', itemlist=[]):
|
||||
infoLabels = item.infoLabels if item.infoLabels else {}
|
||||
contentType = 'tvshow' if 'tvshow' in key else 'movie'
|
||||
itlist = filterkey = []
|
||||
action = 'show_menu'
|
||||
action = 'findvideos'
|
||||
|
||||
if inspect.stack()[1][3] not in ['add_tvshow', 'get_episodes', 'update', 'find_episodes', 'search'] and not item.filterkey and not item.disable_pagination:
|
||||
Pagination = int(defp) if defp.isdigit() else ''
|
||||
@@ -192,8 +192,8 @@ def peliculas(item, json='', key='', itemlist=[]):
|
||||
|
||||
title = option['title'] if 'title' in option else ''
|
||||
|
||||
# if 'tvshows_list' in key and 'links' not in option:
|
||||
# action = 'episodios'
|
||||
if 'tvshows_list' in key and 'links' not in option:
|
||||
action = 'episodios'
|
||||
|
||||
# filter elements
|
||||
if (not item.filter or item.filter.lower() in filterkey) and item.search.lower() in title.lower() and title:
|
||||
@@ -236,8 +236,9 @@ def get_seasons(item):
|
||||
support.log()
|
||||
itemlist = []
|
||||
infoLabels = item.infoLabels
|
||||
json = item.url['seasons_list'] if type(item.url) == dict else item.url
|
||||
|
||||
json = item.url if type(item.url) == dict else item.url
|
||||
if 'seasons_list' in json: json = json['seasons_list']
|
||||
elif 'tvshows_list' in json: return show_menu(item)
|
||||
for option in json:
|
||||
infoLabels['season'] = option['season']
|
||||
title = config.get_localized_string(60027) % option['season']
|
||||
@@ -275,11 +276,20 @@ def episodios(item, json ='', key='', itemlist =[]):
|
||||
if type(item.url) == dict:
|
||||
if 'seasons_list' in item.url:
|
||||
return get_seasons(item)
|
||||
elif 'tvshows_list' in item.url:
|
||||
return peliculas(item, item.url, 'tvshows_list')
|
||||
else:
|
||||
json = {}
|
||||
json = item.url['episodes_list']
|
||||
else:
|
||||
json = load_json(item)['episodes_list']
|
||||
json = load_json(item)
|
||||
if 'episodes_list' in json:
|
||||
json = json['episodes_list']
|
||||
elif 'seasons_list' in json:
|
||||
item.url = json['episodes_list']
|
||||
return get_seasons(item)
|
||||
elif 'tvshows_list' in json:
|
||||
return peliculas(item, json, 'tvshows_list')
|
||||
|
||||
# set variable
|
||||
ep = 1
|
||||
|
||||
+2
-34
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"id": "downloads",
|
||||
"name": "Descargas",
|
||||
"name": "Download",
|
||||
"active": false,
|
||||
"language": ["*"],
|
||||
"categories": [
|
||||
@@ -84,38 +84,6 @@
|
||||
"default": 5,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"type": "label",
|
||||
"label": "@70237",
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "server_reorder",
|
||||
"type": "list",
|
||||
"label": "@70238",
|
||||
"lvalues": [
|
||||
"@70244",
|
||||
"@70245"
|
||||
],
|
||||
"default": 0,
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "language",
|
||||
"type": "list",
|
||||
"label": "@70246",
|
||||
"lvalues": [
|
||||
"Ita, Sub, Eng",
|
||||
"Eng, Ita, Sub",
|
||||
"Sub, Ita, Eng",
|
||||
"Eng, Sub, Ita"
|
||||
],
|
||||
"default": 0,
|
||||
"enabled": "eq(-1,'@70245')",
|
||||
"visible": "eq(-1,'@70245')"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
@@ -539,10 +539,10 @@ def get_match_list(data, match_list, order_list=None, only_ascii=False, ignoreca
|
||||
|
||||
def sort_method(item):
|
||||
"""
|
||||
Puntua cada item en funcion de varios parametros:
|
||||
Score each item based on various parameters:
|
||||
@type item: item
|
||||
@param item: elemento que se va a valorar.
|
||||
@return: puntuacion otenida
|
||||
@param item: item to be valued.
|
||||
@return: punctuation obtained
|
||||
@rtype: int
|
||||
"""
|
||||
lang_orders = {}
|
||||
|
||||
+284
-196
@@ -2,226 +2,314 @@
|
||||
# ------------------------------------------------------------
|
||||
# Canale film in tv
|
||||
# ------------------------------------------------------------
|
||||
|
||||
import re
|
||||
import urllib
|
||||
from channelselector import get_thumb
|
||||
from core import httptools, scrapertools, support, tmdb, filetools
|
||||
from datetime import datetime
|
||||
import glob, time, gzip, xbmc
|
||||
from core import filetools, downloadtools, support, scrapertools
|
||||
from core.item import Item
|
||||
from platformcode import logger, config, platformtools
|
||||
from platformcode import logger
|
||||
|
||||
host = "https://www.superguidatv.it"
|
||||
|
||||
TIMEOUT_TOTAL = 60
|
||||
host = "http://epg-guide.com/kltv.gz"
|
||||
blacklisted_genres = ['attualita', 'scienza', 'religione', 'cucina', 'notiziario', 'altro', 'soap opera', 'viaggi', 'economia', 'tecnologia', 'magazine', 'show', 'reality show', 'lifestyle', 'societa', 'wrestling', 'azione', 'Musica', 'real life', 'real adventure', 'dplay original', 'natura', 'news', 'food', 'sport', 'moda', 'arte e cultura', 'crime', 'box set e serie tv', 'casa', 'storia', 'talk show', 'motori', 'attualit\xc3\xa0 e inchiesta', 'documentari', 'musica', 'spettacolo', 'medical', 'talent show', 'sex and love', 'beauty and style', 'news/current affairs', "children's/youth programmes", 'leisure hobbies', 'social/political issues/economics', 'education/science/factual topics', 'undefined content', 'show/game show', 'music/ballet/dance', 'sports', 'arts/culture', 'biografico', 'informazione', 'documentario']
|
||||
|
||||
|
||||
def mainlist(item):
|
||||
logger.info(" mainlist")
|
||||
itemlist = [#Item(channel="search", action='discover_list', title=config.get_localized_string(70309),
|
||||
#search_type='list', list_type='movie/now_playing',
|
||||
# thumbnail=get_thumb("now_playing.png")),
|
||||
#Item(channel="search", action='discover_list', title=config.get_localized_string(70312),
|
||||
# search_type='list', list_type='tv/on_the_air', thumbnail=get_thumb("on_the_air.png")),
|
||||
Item(channel=item.channel,
|
||||
title=config.get_setting("film1", channel="filmontv"),
|
||||
action="now_on_tv",
|
||||
url="%s/film-in-tv/" % host,
|
||||
thumbnail=item.thumbnail),
|
||||
Item(channel=item.channel,
|
||||
title=config.get_setting("film2", channel="filmontv"),
|
||||
action="now_on_tv",
|
||||
url="%s/film-in-tv/oggi/premium/" % host,
|
||||
thumbnail=item.thumbnail),
|
||||
Item(channel=item.channel,
|
||||
title=config.get_setting("film3", channel="filmontv"),
|
||||
action="now_on_tv",
|
||||
url="%s/film-in-tv/oggi/sky-intrattenimento/" % host,
|
||||
thumbnail=item.thumbnail),
|
||||
Item(channel=item.channel,
|
||||
title=config.get_setting("film4", channel="filmontv"),
|
||||
action="now_on_tv",
|
||||
url="%s/film-in-tv/oggi/sky-cinema/" % host,
|
||||
thumbnail=item.thumbnail),
|
||||
Item(channel=item.channel,
|
||||
title=config.get_setting("film5", channel="filmontv"),
|
||||
action="now_on_tv",
|
||||
url="%s/film-in-tv/oggi/sky-primafila/" % host,
|
||||
thumbnail=item.thumbnail),
|
||||
Item(channel=item.channel,
|
||||
title=config.get_setting("now1", channel="filmontv"),
|
||||
action="now_on_misc",
|
||||
url="%s/ora-in-onda/" % host,
|
||||
thumbnail=item.thumbnail),
|
||||
Item(channel=item.channel,
|
||||
title=config.get_setting("now2", channel="filmontv"),
|
||||
action="now_on_misc",
|
||||
url="%s/ora-in-onda/premium/" % host,
|
||||
thumbnail=item.thumbnail),
|
||||
Item(channel=item.channel,
|
||||
title=config.get_setting("now3", channel="filmontv"),
|
||||
action="now_on_misc",
|
||||
url="%s/ora-in-onda/sky-intrattenimento/" % host,
|
||||
thumbnail=item.thumbnail),
|
||||
Item(channel=item.channel,
|
||||
title=config.get_setting("now4", channel="filmontv"),
|
||||
action="now_on_misc",
|
||||
url="%s/ora-in-onda/sky-doc-e-lifestyle/" % host,
|
||||
thumbnail=item.thumbnail),
|
||||
Item(channel=item.channel,
|
||||
title=config.get_setting("now5", channel="filmontv"),
|
||||
action="now_on_misc_film",
|
||||
url="%s/ora-in-onda/sky-cinema/" % host,
|
||||
thumbnail=item.thumbnail),
|
||||
Item(channel=item.channel,
|
||||
title="Personalizza Oggi in TV",
|
||||
action="server_config",
|
||||
config="filmontv",
|
||||
folder=False,
|
||||
thumbnail=item.thumbnail)]
|
||||
support.log()
|
||||
|
||||
itemlist = [Item(title=support.typo('Film in onda oggi', 'bold'), channel=item.channel, action='category', contentType='movie', thumbnail=support.thumb(thumb='movie.png')),
|
||||
Item(title=support.typo('Serie Tv in onda oggi', 'bold'), channel=item.channel, action='peliculas', contentType='tvshow', thumbnail=support.thumb(thumb='tvshow.png')),
|
||||
Item(title=support.typo('Guida tv per canale', 'bold'), channel=item.channel, action='listaCanali', thumbnail=support.thumb(thumb='on_the_air.png')),
|
||||
Item(title=support.typo('Canali live', 'bold'), channel=item.channel, action='live', thumbnail=support.thumb(thumb='tvshow_on_the_air.png'))]
|
||||
|
||||
return itemlist
|
||||
|
||||
def server_config(item):
|
||||
return platformtools.show_channel_settings(channelpath=filetools.join(config.get_runtime_path(), "server", item.config))
|
||||
|
||||
def now_on_misc_film(item):
|
||||
logger.info("filmontv tvoggi")
|
||||
def getEpg():
|
||||
now = datetime.now()
|
||||
fileName = support.config.get_temp_file('guidatv-') + now.strftime('%Y %m %d')
|
||||
archiveName = fileName + '.gz'
|
||||
xmlName = fileName + '.xml'
|
||||
if not filetools.exists(archiveName):
|
||||
support.log('downloading epg')
|
||||
# cancello quelli vecchi
|
||||
for f in glob.glob(support.config.get_temp_file('guidatv-') + '*'):
|
||||
filetools.remove(f, silent=True)
|
||||
# inmemory = io.BytesIO(httptools.downloadpage(host).data)
|
||||
downloadtools.downloadfile(host, archiveName)
|
||||
support.log('opening gzip and writing xml')
|
||||
fStream = gzip.GzipFile(archiveName, mode='rb')
|
||||
guide = fStream.read().replace('\n', ' ').replace('><', '>\n<')
|
||||
with open(xmlName, 'w') as f:
|
||||
f.write(guide)
|
||||
# else:
|
||||
guide = open(xmlName)
|
||||
return guide
|
||||
|
||||
|
||||
def category(item):
|
||||
itemlist = [Item(title="Tutti", all=True, channel=item.channel, action='peliculas', contentType=item.contentType)]
|
||||
category = ['Animazione', 'Avventura', 'Azione', 'Biografico', 'Brillante', 'Comico', 'Commedia', 'Crime', 'Documentario', 'Documentaristico', 'Drammatico', 'Famiglia', 'Fantascienza', 'Fantastico', 'Giallo', 'Guerra', 'Horror', 'Mistero', 'Musicale', 'Poliziesco', 'Sexy', 'Storico', 'Thriller', 'Western']
|
||||
|
||||
for cat in category:
|
||||
itemlist.append(Item(title=cat, category=cat, channel=item.channel, action='peliculas', contentType=item.contentType))
|
||||
return support.thumb(itemlist)
|
||||
|
||||
|
||||
def peliculas(item, f=None, ):
|
||||
f = getEpg()
|
||||
titles = [item.lastTitle] if not item.titles else item.titles
|
||||
itemlist = []
|
||||
pag = item.pag if item.pag else 0
|
||||
|
||||
# Carica la pagina
|
||||
data = httptools.downloadpage(item.url).data
|
||||
#patron = r'spanTitleMovie">([A-Za-z À-ÖØ-öø-ÿ\-\']*)[a-z \n<>\/="_\-:0-9;A-Z.]*GenresMovie">([\-\'A-Za-z À-ÖØ-öø-ÿ\/]*)[a-z \n<>\/="_\-:0-9;A-Z.%]*src="([a-zA-Z:\/\.0-9?]*)[a-z \n<>\/="_\-:0-9;A-Z.%\-\']*Year">([A-Z 0-9a-z]*)'
|
||||
patron = r'table-cell[;" ]*alt="([^"]+)".*?backdrop" alt="([^"]+)"[ ]*src="([^"]+)'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
for scrapedchannel, scrapedtitle, scrapedthumbnail in matches:
|
||||
# for scrapedthumbnail, scrapedtitle, scrapedtv in matches:
|
||||
scrapedurl = ""
|
||||
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle).strip()
|
||||
infoLabels = {}
|
||||
#infoLabels["year"] = ""
|
||||
infoLabels['title'] = "movie"
|
||||
itemlist.append(
|
||||
Item(channel=item.channel,
|
||||
action="new_search",
|
||||
extra=urllib.quote_plus(scrapedtitle) + '{}' + 'movie',
|
||||
title="[B]" + scrapedtitle + "[/B] - " + scrapedchannel,
|
||||
fulltitle=scrapedtitle,
|
||||
mode='all',
|
||||
search_text=scrapedtitle,
|
||||
url=scrapedurl,
|
||||
thumbnail=scrapedthumbnail.replace("?width=320", "?width=640"),
|
||||
contentTitle=scrapedtitle,
|
||||
contentType='movie',
|
||||
infoLabels=infoLabels,
|
||||
folder=True))
|
||||
channel = ''
|
||||
title = ''
|
||||
episode = ''
|
||||
plot = ''
|
||||
thumbnail = ''
|
||||
actors = []
|
||||
director = ''
|
||||
year = ''
|
||||
genres = []
|
||||
genre = ''
|
||||
country = ''
|
||||
skip = False
|
||||
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
f.seek(pag)
|
||||
line = True
|
||||
while line:
|
||||
line = f.readline()
|
||||
if '<programme' in line:
|
||||
channel = scrapertools.find_single_match(line, r'channel="([^"]+)"')
|
||||
elif '<title' in line:
|
||||
title = scrapertools.find_single_match(line, r'>([^<]+?)(?: - (?:1\s*\^\s*TV|Prima\s*T[Vv]))?<')
|
||||
if not title or title in titles or title == 'EPG non disponibile':
|
||||
skip = True
|
||||
elif not skip and '<desc' in line:
|
||||
genre, episode, plot = scrapertools.find_single_match(line, r'>(?:\[([^\]]+)\])?(S[0-9]+\s*Ep?[0-9]+)?(?:\s*-\s*)?([^<]+)')
|
||||
if plot:
|
||||
CY = scrapertools.find_single_match(plot, r'(\D{3}) (\d{4})')
|
||||
if CY: country, year = CY
|
||||
director = scrapertools.find_single_match(plot, r'Regia di ([^;|<]+)')
|
||||
if episode and item.contentType == 'movie': skip = True
|
||||
elif not skip and '<category' in line:
|
||||
genre = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
# elif not skip and '<actor' in line:
|
||||
# match = scrapertools.find_single_match(line, r'(?:role="([^"]*)")?>([^<]+)<')
|
||||
# actors.append([match[1], match[0]])
|
||||
# elif not skip and '<director' in line:
|
||||
# director = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
# elif not skip and '<date' in line:
|
||||
# year = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
# elif not skip and '<country' in line:
|
||||
# country = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
# elif not skip and '<episode-num' in line:
|
||||
# episode = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
# if item.contentType == 'movie':
|
||||
# skip = True
|
||||
# elif not skip and '<icon' in line:
|
||||
# thumbnail = scrapertools.find_single_match(line, r'src="([^"]+)"')
|
||||
elif '</programme' in line:
|
||||
if genre in blacklisted_genres: skip = True
|
||||
elif genre: genres = genre.split('/')
|
||||
if not skip:
|
||||
titles.append(title)
|
||||
if (item.contentType == 'movie' and genres and (item.category in genres or item.all == True)) or (item.contentType == 'tvshow' and episode):
|
||||
if episode:
|
||||
episode = scrapertools.get_season_and_episode(episode)
|
||||
se, ep = episode.split('x')
|
||||
else:
|
||||
se, ep = ('', '')
|
||||
itemlist.append(Item(
|
||||
channel=item.channel,
|
||||
action='new_search',
|
||||
title=support.typo(title + (' - ' + episode if episode else ''), 'bold'),
|
||||
contentTitle=title if item.contentType == 'movie' else '',
|
||||
contentSerieName=title if item.contentType == 'tvshow' else '',
|
||||
contentSeason=se,
|
||||
contentEpisodeNumber=ep,
|
||||
fulltitle=title,
|
||||
search_text=title,
|
||||
mode=item.contentType,
|
||||
thumbnail=thumbnail if thumbnail else item.thumbnail,
|
||||
contentType=item.contentType,
|
||||
channel_name=channel,
|
||||
plot=plot,
|
||||
infoLabels={
|
||||
'director': director,
|
||||
'genre': genres,
|
||||
'country': country,
|
||||
'year': year,
|
||||
'season': se,
|
||||
'episode': ep
|
||||
}
|
||||
))
|
||||
|
||||
channel = ''
|
||||
title = ''
|
||||
episode = ''
|
||||
plot = ''
|
||||
thumbnail = ''
|
||||
actors = []
|
||||
director = ''
|
||||
year = ''
|
||||
genres = []
|
||||
genre = ''
|
||||
country = ''
|
||||
skip = False
|
||||
|
||||
if len(itemlist) >= 40:
|
||||
itemlist.append(item.clone(title=support.typo(support.config.get_localized_string(30992), 'color kod bold'), pag= f.tell(), thumbnail=support.thumb(), lastTitle=titles[-1]))
|
||||
break
|
||||
support.tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
f.close()
|
||||
return itemlist
|
||||
|
||||
def now_on_misc(item):
|
||||
logger.info("filmontv tvoggi")
|
||||
def listaCanali(item):
|
||||
itemlist = []
|
||||
f = getEpg()
|
||||
thumbnail = None
|
||||
skip = False
|
||||
line = True
|
||||
while line:
|
||||
line = f.readline()
|
||||
if '<channel' in line:
|
||||
channelID = scrapertools.find_single_match(line, r'id="([^"]+)"')
|
||||
elif '<display-name' in line:
|
||||
channelName = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
elif not skip and '<icon' in line:
|
||||
thumbnail = scrapertools.find_single_match(line, r'src="([^"]+)"')
|
||||
elif not skip and '<programme' in line:
|
||||
break
|
||||
if '</channel' in line:
|
||||
if not skip and thumbnail: #and 'channel="' + channel + '"' in f:
|
||||
itemlist.append(Item(
|
||||
channel=item.channel,
|
||||
action='guidatv',
|
||||
title=support.typo(channelName, 'bold'),
|
||||
channelID=channelID,
|
||||
thumbnail=thumbnail
|
||||
))
|
||||
thumbnail = None
|
||||
skip = False
|
||||
# return itemlist
|
||||
# logger.info([i.title for i in itemlist])
|
||||
f.close()
|
||||
return sorted(itemlist, key=lambda x: x.title)
|
||||
|
||||
# Carica la pagina
|
||||
data = httptools.downloadpage(item.url).data
|
||||
#patron = r'spanTitleMovie">([A-Za-z À-ÖØ-öø-ÿ\-\']*)[a-z \n<>\/="_\-:0-9;A-Z.]*GenresMovie">([\-\'A-Za-z À-ÖØ-öø-ÿ\/]*)[a-z \n<>\/="_\-:0-9;A-Z.%]*src="([a-zA-Z:\/\.0-9?]*)[a-z \n<>\/="_\-:0-9;A-Z.%\-\']*Year">([A-Z 0-9a-z]*)'
|
||||
patron = r'table-cell[;" ]*alt="([^"]+)".*?backdrop" alt="([^"]+)"[ ]*src="([^"]+)'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
for scrapedchannel, scrapedtitle, scrapedthumbnail in matches:
|
||||
# for scrapedthumbnail, scrapedtitle, scrapedtv in matches:
|
||||
scrapedurl = ""
|
||||
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle).strip()
|
||||
infoLabels = {}
|
||||
infoLabels["year"] = ""
|
||||
infoLabels['tvshowtitle'] = scrapedtitle
|
||||
itemlist.append(
|
||||
Item(channel=item.channel,
|
||||
action="new_search",
|
||||
extra=urllib.quote_plus(scrapedtitle) + '{}' + 'tvshow',
|
||||
title="[B]" + scrapedtitle + "[/B] - " + scrapedchannel,
|
||||
fulltitle=scrapedtitle,
|
||||
mode='all',
|
||||
search_text=scrapedtitle,
|
||||
url=scrapedurl,
|
||||
thumbnail=scrapedthumbnail.replace("?width=320", "?width=640"),
|
||||
contentTitle=scrapedtitle,
|
||||
contentType='tvshow',
|
||||
infoLabels=infoLabels,
|
||||
folder=True))
|
||||
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
|
||||
return itemlist
|
||||
|
||||
def now_on_tv(item):
|
||||
logger.info("filmontv tvoggi")
|
||||
def guidatv(item):
|
||||
itemlist = []
|
||||
f = getEpg()
|
||||
days = []
|
||||
for day in range(11, 18):days.append(xbmc.getLocalizedString(day))
|
||||
|
||||
# Carica la pagina
|
||||
data = httptools.downloadpage(item.url).data.replace('\n','')
|
||||
#patron = r'spanTitleMovie">([A-Za-z À-ÖØ-öø-ÿ\-\']*)[a-z \n<>\/="_\-:0-9;A-Z.]*GenresMovie">([\-\'A-Za-z À-ÖØ-öø-ÿ\/]*)[a-z \n<>\/="_\-:0-9;A-Z.%]*src="([a-zA-Z:\/\.0-9?]*)[a-z \n<>\/="_\-:0-9;A-Z.%\-\']*Year">([A-Z 0-9a-z]*)'
|
||||
patron = r'alt="([a-zA-Z 0-9]*)".*?spanMovieDuration">([^<]+).*?spanTitleMovie">([A-Za-z ,0-9\.À-ÖØ-öø-ÿ\-\']*).*?GenresMovie">([\-\'A-Za-z À-ÖØ-öø-ÿ\/]*).*?src="([a-zA-Z:\/\.0-9?]*).*?Year">([A-Z 0-9a-z]*)'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
for scrapedchannel, scrapedduration, scrapedtitle, scrapedgender, scrapedthumbnail, scrapedyear in matches:
|
||||
# for scrapedthumbnail, scrapedtitle, scrapedtv in matches:
|
||||
scrapedurl = ""
|
||||
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle).strip()
|
||||
infoLabels = {}
|
||||
infoLabels["year"] = scrapedyear
|
||||
itemlist.append(
|
||||
Item(channel=item.channel,
|
||||
action="new_search",
|
||||
extra=urllib.quote_plus(scrapedtitle) + '{}' + 'movie',
|
||||
title="[B]" + scrapedtitle + "[/B] - " + scrapedchannel + " - " + scrapedduration,
|
||||
fulltitle="[B]" + scrapedtitle + "[/B] - " + scrapedchannel+ " - " + scrapedduration,
|
||||
url=scrapedurl,
|
||||
mode='all',
|
||||
search_text=scrapedtitle,
|
||||
thumbnail=scrapedthumbnail.replace("?width=240", "?width=480"),
|
||||
contentTitle=scrapedtitle,
|
||||
contentType='movie',
|
||||
infoLabels=infoLabels,
|
||||
folder=True))
|
||||
channel = ''
|
||||
title = ''
|
||||
episode = ''
|
||||
plot = ''
|
||||
thumbnail = ''
|
||||
actors = []
|
||||
director = ''
|
||||
year = ''
|
||||
genres = []
|
||||
country = ''
|
||||
start = ''
|
||||
stop = ''
|
||||
skip = False
|
||||
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
line = True
|
||||
while line:
|
||||
line = f.readline()
|
||||
if '<programme' in line:
|
||||
start, stop, channel = scrapertools.find_single_match(line,r'start="([^"]*)" stop="([^"]*)" channel="([^"]+)"')
|
||||
if channel != item.channelID:
|
||||
skip = True
|
||||
elif not skip and '<title' in line:
|
||||
title = scrapertools.find_single_match(line, r'>([^<]+?)<')
|
||||
if title == 'EPG non disponibile':
|
||||
skip = True
|
||||
elif not skip and '<desc' in line:
|
||||
genre, episode, plot = scrapertools.find_single_match(line, r'>(?:\[([^\]]+)\])?(S[0-9]+\s*Ep?[0-9]+)?(?:\s*-\s*)?([^<]+)')
|
||||
if plot:
|
||||
CY = scrapertools.find_single_match(plot, r'(\D{3}) (\d{4})')
|
||||
if CY: country, year = CY
|
||||
director = scrapertools.find_single_match(plot, r'Regia di ([^;|<]+)')
|
||||
if genre: genres.append(genre)
|
||||
if episode and item.contentType == 'movie':skip = True
|
||||
elif not skip and '<category' in line:
|
||||
genre = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
# elif not skip and '<actor' in line:
|
||||
# match = scrapertools.find_single_match(line, r'(?:role="([^"]*)")?>([^<]+)<')
|
||||
# actors.append([match[1], match[0]])
|
||||
# elif not skip and '<director' in line:
|
||||
# director = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
# elif not skip and '<date' in line:
|
||||
# year = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
# elif not skip and '<category' in line:
|
||||
# genres.append(scrapertools.find_single_match(line, r'>([^<]+)<'))
|
||||
# elif not skip and '<country' in line:
|
||||
# country = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
# elif not skip and '<episode-num' in line:
|
||||
# episode = scrapertools.find_single_match(line, r'>([^<]+)<')
|
||||
# elif not skip and '<icon' in line:
|
||||
# thumbnail = scrapertools.find_single_match(line, r'src="([^"]+)"')
|
||||
elif '</programme' in line:
|
||||
if not skip:
|
||||
if genre: genres = genre.split('/')
|
||||
tzHour = int(start.split('+')[1][:2])
|
||||
start = time.strptime(start.split(' ')[0], '%Y%m%d%H%M%S')
|
||||
stop = time.strptime(stop.split(' ')[0], '%Y%m%d%H%M%S')
|
||||
duration = days[start.tm_wday] + ' alle ' + str(start.tm_hour + tzHour).zfill(2) + ':' + str(start.tm_min).zfill(2) + ' - ' + str(stop.tm_hour + tzHour).zfill(2) + ':' + str(stop.tm_min).zfill(2) + ' - '
|
||||
itemlist.append(Item(
|
||||
channel=item.channel,
|
||||
action='new_search',
|
||||
title=duration + support.typo(title + (' - ' + episode if episode else ''), 'bold'),
|
||||
fulltitle=title,
|
||||
search_text=title,
|
||||
mode=item.contentType,
|
||||
thumbnail=thumbnail if thumbnail else item.thumbnail,
|
||||
contentType=item.contentType,
|
||||
channel_name=channel,
|
||||
infoLabels={
|
||||
'title': title,
|
||||
'plot': plot,
|
||||
'castandrole': actors,
|
||||
'director': director,
|
||||
'genre': genres,
|
||||
'country': country,
|
||||
'year': year
|
||||
}
|
||||
))
|
||||
|
||||
channel = ''
|
||||
title = ''
|
||||
episode = ''
|
||||
plot = ''
|
||||
thumbnail = ''
|
||||
actors = []
|
||||
director = ''
|
||||
year = ''
|
||||
genres = []
|
||||
country = ''
|
||||
start = ''
|
||||
stop = ''
|
||||
skip = False
|
||||
f.close()
|
||||
return itemlist
|
||||
|
||||
def primafila(item):
|
||||
logger.info("filmontv tvoggi")
|
||||
itemlist = []
|
||||
|
||||
# Carica la pagina
|
||||
data = httptools.downloadpage(item.url).data
|
||||
#patron = r'spanTitleMovie">([A-Za-z À-ÖØ-öø-ÿ]*)[a-z \n<>\/="_\-:0-9;A-Z.]*GenresMovie">([A-Za-z À-ÖØ-öø-ÿ\/]*)[a-z \n<>\/="_\-:0-9;A-Z.%]*src="([a-zA-Z:\/\.0-9?=]*)'
|
||||
patron = r'spanTitleMovie">([A-Za-z À-ÖØ-öø-ÿ\-\']*)[a-z \n<>\/="_\-:0-9;A-Z.]*GenresMovie">([\-\'A-Za-z À-ÖØ-öø-ÿ\/]*)[a-z \n<>\/="_\-:0-9;A-Z.%]*src="([a-zA-Z:\/\.0-9?]*)[a-z \n<>\/="_\-:0-9;A-Z.%\-\']*Year">([A-Z 0-9a-z]*)'
|
||||
matches = re.compile(patron, re.DOTALL).findall(data)
|
||||
for scrapedtitle, scrapedgender, scrapedthumbnail, scrapedyear in matches:
|
||||
# for scrapedthumbnail, scrapedtitle, scrapedtv in matches:
|
||||
scrapedurl = ""
|
||||
scrapedtitle = scrapertools.decodeHtmlentities(scrapedtitle).strip()
|
||||
infoLabels = {}
|
||||
infoLabels["year"] = scrapedyear
|
||||
itemlist.append(
|
||||
Item(channel=item.channel,
|
||||
action="new_search",
|
||||
extra=urllib.quote_plus(scrapedtitle) + '{}' + 'movie',
|
||||
title=scrapedtitle,
|
||||
fulltitle=scrapedtitle,
|
||||
url=scrapedurl,
|
||||
mode='all',
|
||||
search_text=scrapedtitle,
|
||||
thumbnail=scrapedthumbnail.replace("?width=240", "?width=480"),
|
||||
contentTitle=scrapedtitle,
|
||||
contentType='movie',
|
||||
infoLabels=infoLabels,
|
||||
folder=True))
|
||||
|
||||
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
|
||||
|
||||
return itemlist
|
||||
|
||||
def new_search(item):
|
||||
from specials import search
|
||||
return search.new_search(item)
|
||||
item.channel = 'search'
|
||||
# se risultato certo, vai dritto alla ricerca per id
|
||||
if item.infoLabels['tmdb_id']:
|
||||
return search.channel_search(item)
|
||||
else:
|
||||
return search.new_search(item)
|
||||
|
||||
|
||||
def live(item):
|
||||
itemlist = []
|
||||
from channels import raiplay#, mediasetplay
|
||||
itemlist += raiplay.live(raiplay.mainlist(Item())[0])
|
||||
# itemlist += mediasetplay.live(mediasetplay.mainlist(Item())[0])
|
||||
return itemlist
|
||||
|
||||
@@ -288,10 +288,6 @@ def get_links(list_item, item, list_language, list_quality=None, global_filter_l
|
||||
|
||||
second_lang = config.get_setting('second_language')
|
||||
|
||||
# Sort by favorite servers, delete blacklist servers and disabled
|
||||
from core import servertools
|
||||
list_item= servertools.filter_servers(list_item)
|
||||
|
||||
logger.debug("total de items : %s" % len(list_item))
|
||||
|
||||
new_itemlist = []
|
||||
|
||||
+1
-1
@@ -124,7 +124,7 @@ def set_category_context(item):
|
||||
"extra": item.extra,
|
||||
"action": "setting_channel",
|
||||
"channel": item.channel}]
|
||||
item.category = config.get_localized_string(60679) % item.extra
|
||||
item.category = config.get_localized_string(60679) % re.sub('\[[^\]]+\]','',item.title).strip()
|
||||
|
||||
|
||||
def get_channels_list():
|
||||
|
||||
@@ -1,207 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
import xbmc, xbmcgui
|
||||
from platformcode import config, platformtools
|
||||
from time import time, sleep
|
||||
from core import jsontools, filetools
|
||||
from core.support import log
|
||||
from core.item import Item
|
||||
from platformcode.launcher import play_from_library
|
||||
|
||||
import sys
|
||||
if sys.version_info[0] >= 3:
|
||||
from concurrent import futures
|
||||
else:
|
||||
from concurrent_py2 import futures
|
||||
|
||||
next_dialogs = ['NextDialog.xml', 'NextDialogExtended.xml', 'NextDialogCompact.xml']
|
||||
next_ep_type = config.get_setting('next_ep_type')
|
||||
|
||||
# compatibility with previous version
|
||||
if type(next_ep_type) == bool:
|
||||
ND = 'NextDialogCompact.xml' if config.get_setting('next_ep_type') else 'NextDialog.xml'
|
||||
else:
|
||||
ND = next_dialogs[next_ep_type]
|
||||
|
||||
def check(item):
|
||||
return True if config.get_setting('next_ep') > 0 and item.contentType != 'movie' else False
|
||||
|
||||
|
||||
def return_item(item):
|
||||
log()
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
future = executor.submit(next_ep, item)
|
||||
item = future.result()
|
||||
return item
|
||||
|
||||
def run(item):
|
||||
log()
|
||||
with futures.ThreadPoolExecutor() as executor:
|
||||
future = executor.submit(next_ep, item)
|
||||
item = future.result()
|
||||
if item.next_ep:
|
||||
return play_from_library(item)
|
||||
|
||||
|
||||
def videolibrary(item):
|
||||
from threading import Thread
|
||||
item.videolibrary = True
|
||||
Thread(target=next_ep, args=[item]).start()
|
||||
|
||||
|
||||
def next_ep(item):
|
||||
log()
|
||||
condition = config.get_setting('next_ep')
|
||||
item.next_ep = False
|
||||
item.show_server = True
|
||||
|
||||
VL = True if item.videolibrary else False
|
||||
|
||||
time_over = False
|
||||
time_limit = time() + 30
|
||||
time_setting = config.get_setting('next_ep_seconds')
|
||||
TimeFromEnd = time_setting
|
||||
|
||||
# wait until the video plays
|
||||
while not platformtools.is_playing() and time() < time_limit:
|
||||
sleep(1)
|
||||
|
||||
while platformtools.is_playing() and not time_over:
|
||||
try:
|
||||
Total = xbmc.Player().getTotalTime()
|
||||
Actual = xbmc.Player().getTime()
|
||||
Difference = Total - Actual
|
||||
if Total > TimeFromEnd >= Difference:
|
||||
time_over = True
|
||||
except:
|
||||
break
|
||||
|
||||
if time_over:
|
||||
if condition == 1: # hide server afther x second
|
||||
item.show_server = False
|
||||
elif condition == 2: # play next file if exist
|
||||
|
||||
# check if next file exist
|
||||
current_filename = filetools.basename(item.strm_path)
|
||||
base_path = filetools.basename(filetools.dirname(item.strm_path))
|
||||
path = filetools.join(config.get_videolibrary_path(), config.get_setting("folder_tvshows"),base_path)
|
||||
fileList = []
|
||||
for file in filetools.listdir(path):
|
||||
if file.endswith('.strm'):
|
||||
fileList.append(file)
|
||||
|
||||
fileList.sort()
|
||||
|
||||
nextIndex = fileList.index(current_filename) + 1
|
||||
if nextIndex == 0 or nextIndex == len(fileList):
|
||||
next_file = None
|
||||
else:
|
||||
next_file = fileList[nextIndex]
|
||||
log('Next File:', next_file)
|
||||
|
||||
# start next episode window afther x time
|
||||
if next_file:
|
||||
season_ep = next_file.split('.')[0]
|
||||
season = season_ep.split('x')[0]
|
||||
episode = season_ep.split('x')[1]
|
||||
next_ep = '%sx%s' % (season, episode)
|
||||
item = Item(
|
||||
action= 'play_from_library',
|
||||
channel= 'videolibrary',
|
||||
contentEpisodeNumber= episode,
|
||||
contentSeason= season,
|
||||
contentTitle= next_ep,
|
||||
contentType= 'episode',
|
||||
infoLabels= {'episode': episode, 'mediatype': 'episode', 'season': season, 'title': next_ep},
|
||||
strm_path= filetools.join(base_path, next_file))
|
||||
|
||||
global INFO
|
||||
INFO = filetools.join(path, next_file.replace("strm", "nfo"))
|
||||
log('Next Info:',INFO)
|
||||
|
||||
nextDialog = NextDialog(ND, config.get_runtime_path())
|
||||
nextDialog.show()
|
||||
while platformtools.is_playing() and not nextDialog.is_still_watching():
|
||||
xbmc.sleep(100)
|
||||
pass
|
||||
|
||||
nextDialog.close()
|
||||
log('Next Episode:', nextDialog.stillwatching)
|
||||
|
||||
if nextDialog.stillwatching or nextDialog.continuewatching:
|
||||
item.next_ep = True
|
||||
xbmc.Player().stop()
|
||||
if VL:
|
||||
sleep(1)
|
||||
xbmc.executebuiltin('Action(Back)')
|
||||
sleep(0.5)
|
||||
return play_from_library(item)
|
||||
else:
|
||||
item.show_server = False
|
||||
if VL:
|
||||
sleep(1)
|
||||
xbmc.executebuiltin('Action(Back)')
|
||||
sleep(0.5)
|
||||
return None
|
||||
|
||||
return item
|
||||
|
||||
|
||||
class NextDialog(xbmcgui.WindowXMLDialog):
|
||||
item = None
|
||||
cancel = False
|
||||
stillwatching = False
|
||||
continuewatching = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
log()
|
||||
self.action_exitkeys_id = [xbmcgui.ACTION_STOP, xbmcgui.ACTION_BACKSPACE, xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.ACTION_NAV_BACK]
|
||||
self.progress_control = None
|
||||
|
||||
# set info
|
||||
f = filetools.file_open(INFO, 'r')
|
||||
full_info = f.read().split('\n')
|
||||
full_info = full_info[1:]
|
||||
f.close()
|
||||
full_info = "".join(full_info)
|
||||
info = jsontools.load(full_info)
|
||||
info = info["infoLabels"]
|
||||
self.setProperty("title", info["tvshowtitle"])
|
||||
self.setProperty("ep_title", "%dx%02d - %s" % (info["season"], info["episode"], info["title"]))
|
||||
if "episodio_imagen" in info:
|
||||
img = info["episodio_imagen"]
|
||||
else:
|
||||
img = filetools.join(config.get_runtime_path(), "resources", "noimage.png")
|
||||
self.setProperty("next_img", img)
|
||||
|
||||
def set_still_watching(self, stillwatching):
|
||||
self.stillwatching = stillwatching
|
||||
|
||||
def set_continue_watching(self, continuewatching):
|
||||
self.continuewatching = continuewatching
|
||||
|
||||
def is_still_watching(self):
|
||||
return self.stillwatching
|
||||
|
||||
def onFocus(self, controlId):
|
||||
pass
|
||||
|
||||
def doAction(self):
|
||||
pass
|
||||
|
||||
def closeDialog(self):
|
||||
self.close()
|
||||
|
||||
def onClick(self, controlId):
|
||||
if controlId == 3012: # Still watching
|
||||
self.set_still_watching(True)
|
||||
self.set_continue_watching(False)
|
||||
self.close()
|
||||
elif controlId == 3013: # Cancel
|
||||
self.set_continue_watching(False)
|
||||
self.close()
|
||||
|
||||
def onAction(self, action):
|
||||
log()
|
||||
if action in self.action_exitkeys_id:
|
||||
self.set_continue_watching(False)
|
||||
self.close()
|
||||
+1
-1
@@ -520,7 +520,7 @@ def setting_channel_new(item):
|
||||
preselect.append(i)
|
||||
|
||||
# Dialog to select
|
||||
ret = xbmcgui.Dialog().multiselect(config.get_localized_string(59994), lista, preselect=preselect, useDetails=True)
|
||||
ret = platformtools.dialog_multiselect(config.get_localized_string(59994), lista, preselect=preselect, useDetails=True)
|
||||
if not ret:
|
||||
return False # order cancel
|
||||
seleccionados = [ids[i] for i in ret]
|
||||
|
||||
+47
-39
@@ -292,52 +292,42 @@ def server_debrid_config(item):
|
||||
|
||||
def servers_blacklist(item):
|
||||
server_list = servertools.get_servers_list()
|
||||
dict_values = {}
|
||||
blacklisted = []
|
||||
|
||||
list_controls = []
|
||||
list_servers = []
|
||||
|
||||
list_controls = [{"id": "filter_servers",
|
||||
"type": "bool",
|
||||
"label": "@30068",
|
||||
"default": False,
|
||||
"enabled": True,
|
||||
"visible": True}]
|
||||
dict_values['filter_servers'] = config.get_setting('filter_servers')
|
||||
if dict_values['filter_servers'] == None:
|
||||
dict_values['filter_servers'] = False
|
||||
for i, server in enumerate(sorted(server_list.keys())):
|
||||
server_parameters = server_list[server]
|
||||
controls, defaults = servertools.get_server_controls_settings(server)
|
||||
dict_values[server] = config.get_setting("black_list", server=server)
|
||||
defaults = servertools.get_server_parameters(server)
|
||||
|
||||
control = server_parameters["name"]
|
||||
# control.setArt({'thumb:': server_parameters['thumb'] if 'thumb' in server_parameters else config.get_online_server_thumb(server)})
|
||||
if defaults.get("black_list", False) or config.get_setting("black_list", server=server):
|
||||
blacklisted.append(i)
|
||||
|
||||
control = {"id": server,
|
||||
"type": "bool",
|
||||
"label": ' %s' % server_parameters["name"],
|
||||
"default": defaults.get("black_list", False),
|
||||
"enabled": "eq(-%s,True)" % (i + 1),
|
||||
"visible": True}
|
||||
list_controls.append(control)
|
||||
|
||||
return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values,
|
||||
caption=config.get_localized_string(60550), callback="cb_servers_blacklist")
|
||||
list_servers.append(server)
|
||||
ris = platformtools.dialog_multiselect(config.get_localized_string(60550), list_controls, preselect=blacklisted)
|
||||
if ris is not None:
|
||||
cb_servers_blacklist({list_servers[n]: True if n in ris else False for n, it in enumerate(list_controls)})
|
||||
# return platformtools.show_channel_settings(list_controls=list_controls, dict_values=dict_values, caption=config.get_localized_string(60550), callback="cb_servers_blacklist")
|
||||
|
||||
|
||||
def cb_servers_blacklist(item, dict_values):
|
||||
f = False
|
||||
def cb_servers_blacklist(dict_values):
|
||||
blaklisted = []
|
||||
progreso = platformtools.dialog_progress(config.get_localized_string(60557), config.get_localized_string(60558))
|
||||
n = len(dict_values)
|
||||
i = 1
|
||||
for k, v in list(dict_values.items()):
|
||||
if k == 'filter_servers':
|
||||
config.set_setting('filter_servers', v)
|
||||
else:
|
||||
config.set_setting("black_list", v, server=k)
|
||||
if v: # If the server is blacklisted it cannot be in the favorites list
|
||||
config.set_setting("favorites_servers_list", 100, server=k)
|
||||
f = True
|
||||
progreso.update(old_div((i * 100), n), config.get_localized_string(60559) % k)
|
||||
config.set_setting("black_list", v, server=k)
|
||||
if v: # If the server is blacklisted it cannot be in the favorites list
|
||||
config.set_setting("favorites_servers_list", 0, server=k)
|
||||
blaklisted.append(k)
|
||||
f = True
|
||||
progreso.update(old_div((i * 100), n), config.get_localized_string(60559) % k)
|
||||
i += 1
|
||||
|
||||
if not f: # If there is no server in the list, deactivate it
|
||||
config.set_setting('filter_servers', False)
|
||||
config.set_setting("black_list", blaklisted, server='servers')
|
||||
|
||||
progreso.close()
|
||||
|
||||
@@ -347,12 +337,19 @@ def servers_favorites(item):
|
||||
dict_values = {}
|
||||
|
||||
list_controls = [{'id': 'favorites_servers',
|
||||
'type': "bool",
|
||||
'type': 'bool',
|
||||
'label': config.get_localized_string(60577),
|
||||
'default': False,
|
||||
'enabled': True,
|
||||
'visible': True},
|
||||
{'id': 'quality_priority',
|
||||
'type': 'bool',
|
||||
'label': config.get_localized_string(30069),
|
||||
'default': False,
|
||||
'enabled': 'eq(-1,True)',
|
||||
'visible': True}]
|
||||
dict_values['favorites_servers'] = config.get_setting('favorites_servers')
|
||||
dict_values['quality_priority'] = config.get_setting('quality_priority')
|
||||
if dict_values['favorites_servers'] == None:
|
||||
dict_values['favorites_servers'] = False
|
||||
|
||||
@@ -369,13 +366,13 @@ def servers_favorites(item):
|
||||
if orden > 0:
|
||||
dict_values[orden] = len(server_names) - 1
|
||||
|
||||
for x in range(1, 6):
|
||||
for x in range(1, 12):
|
||||
control = {'id': x,
|
||||
'type': "list",
|
||||
'type': 'list',
|
||||
'label': config.get_localized_string(60597) % x,
|
||||
'lvalues': server_names,
|
||||
'default': 0,
|
||||
'enabled': "eq(-%s,True)" % x,
|
||||
'enabled': 'eq(-%s,True)' % str(x + 1),
|
||||
'visible': True}
|
||||
list_controls.append(control)
|
||||
|
||||
@@ -385,11 +382,14 @@ def servers_favorites(item):
|
||||
|
||||
def cb_servers_favorites(server_names, dict_values):
|
||||
dict_name = {}
|
||||
dict_favorites = {}
|
||||
progreso = platformtools.dialog_progress(config.get_localized_string(60557), config.get_localized_string(60558))
|
||||
|
||||
for i, v in list(dict_values.items()):
|
||||
if i == "favorites_servers":
|
||||
config.set_setting("favorites_servers", v)
|
||||
elif i == "quality_priority":
|
||||
config.set_setting("quality_priority", v)
|
||||
elif int(v) > 0:
|
||||
dict_name[server_names[v]] = int(i)
|
||||
|
||||
@@ -398,12 +398,20 @@ def cb_servers_favorites(server_names, dict_values):
|
||||
i = 1
|
||||
for server, server_parameters in servers_list:
|
||||
if server_parameters['name'] in list(dict_name.keys()):
|
||||
dict_favorites[dict_name[server_parameters['name']]] = server
|
||||
config.set_setting("favorites_servers_list", dict_name[server_parameters['name']], server=server)
|
||||
else:
|
||||
config.set_setting("favorites_servers_list", 0, server=server)
|
||||
progreso.update(old_div((i * 100), n), config.get_localized_string(60559) % server_parameters['name'])
|
||||
i += 1
|
||||
|
||||
c = 2
|
||||
favorites_servers_list = []
|
||||
while c in dict_favorites:
|
||||
favorites_servers_list.append(dict_favorites[c])
|
||||
c += 1
|
||||
config.set_setting("favorites_servers_list", favorites_servers_list, server='servers')
|
||||
|
||||
if not dict_name: # If there is no server in the list, deactivate it
|
||||
config.set_setting("favorites_servers", False)
|
||||
|
||||
@@ -716,7 +724,7 @@ def channels_onoff(item):
|
||||
|
||||
# Dialog to select
|
||||
# ------------------------
|
||||
ret = xbmcgui.Dialog().multiselect(config.get_localized_string(60545), lista, preselect=preselect, useDetails=True)
|
||||
ret = platformtools.dialog_multiselect(config.get_localized_string(60545), lista, preselect=preselect, useDetails=True)
|
||||
if ret == None: return False # order cancel
|
||||
seleccionados = [ids[i] for i in ret]
|
||||
|
||||
|
||||
@@ -209,21 +209,6 @@
|
||||
"enabled": true,
|
||||
"visible": true
|
||||
},
|
||||
{
|
||||
"id": "watched_setting",
|
||||
"type": "list",
|
||||
"label": "@60635",
|
||||
"default": 3,
|
||||
"visible": true,
|
||||
"enabled": "eq(-1,true)",
|
||||
"lvalues": [
|
||||
"5 min",
|
||||
"30%",
|
||||
"50%",
|
||||
"80%",
|
||||
"@60636"
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "sync_trakt",
|
||||
"type": "label",
|
||||
|
||||
@@ -78,7 +78,7 @@ def list_movies(item, silent=False):
|
||||
# Verify the existence of the channels. If the channel does not exist, ask yourself if you want to remove the links from that channel.
|
||||
|
||||
for canal_org in new_item.library_urls:
|
||||
canal = generictools.verify_channel(canal_org)
|
||||
canal = canal_org
|
||||
try:
|
||||
if canal in ['community', 'downloads']:
|
||||
channel_verify = __import__('specials.%s' % canal, fromlist=["channels.%s" % canal])
|
||||
@@ -202,7 +202,6 @@ def list_tvshows(item):
|
||||
# Verify the existence of the channels. If the channel does not exist, ask yourself if you want to remove the links from that channel.
|
||||
|
||||
for canal in item_tvshow.library_urls:
|
||||
canal = generictools.verify_channel(canal)
|
||||
try:
|
||||
if canal in ['community', 'downloads']:
|
||||
channel_verify = __import__('specials.%s' % canal, fromlist=["channels.%s" % canal])
|
||||
@@ -339,7 +338,7 @@ def configure_update_videolibrary(item):
|
||||
preselect.append(i)
|
||||
|
||||
# Select Dialog
|
||||
ret = xbmcgui.Dialog().multiselect(config.get_localized_string(60601), lista, preselect=preselect, useDetails=True)
|
||||
ret = platformtools.dialog_multiselect(config.get_localized_string(60601), lista, preselect=preselect, useDetails=True)
|
||||
if ret < 0:
|
||||
return False # order cancel
|
||||
seleccionados = [ids[i] for i in ret]
|
||||
@@ -567,6 +566,7 @@ def findvideos(item):
|
||||
|
||||
item_json = Item().fromjson(filetools.read(json_path))
|
||||
list_servers = []
|
||||
# from core.support import dbg;dbg()
|
||||
|
||||
try:
|
||||
# FILTERTOOLS
|
||||
@@ -578,12 +578,14 @@ def findvideos(item):
|
||||
|
||||
# We run find_videos, from the channel or common
|
||||
item_json.contentChannel = 'videolibrary'
|
||||
item_json.play_from = item.play_from
|
||||
item_json.nfo = item.nfo
|
||||
item_json.strm_path = item.strm_path
|
||||
if hasattr(channel, 'findvideos'):
|
||||
from core import servertools
|
||||
if item_json.videolibray_emergency_urls:
|
||||
del item_json.videolibray_emergency_urls
|
||||
list_servers = getattr(channel, 'findvideos')(item_json)
|
||||
list_servers = servertools.filter_servers(list_servers)
|
||||
elif item_json.action == 'play':
|
||||
from platformcode import platformtools
|
||||
# autoplay.set_status(True)
|
||||
@@ -625,10 +627,7 @@ def findvideos(item):
|
||||
|
||||
if autoplay.play_multi_channel(item, itemlist): # hideserver
|
||||
return []
|
||||
from inspect import stack
|
||||
from specials import nextep
|
||||
if nextep.check(item) and stack()[1][3] == 'run':
|
||||
nextep.videolibrary(item)
|
||||
|
||||
add_download_items(item, itemlist)
|
||||
return itemlist
|
||||
|
||||
|
||||
Reference in New Issue
Block a user