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:
@@ -462,3 +462,7 @@ def verify_directories_created():
|
||||
import traceback
|
||||
logger.error("When checking or creating the resolution folder")
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
|
||||
def get_online_server_thumb(server):
|
||||
return "https://raw.github.com/kodiondemand/media/master/resources/servers/" + server.lower() + '.png'
|
||||
@@ -3,19 +3,9 @@
|
||||
# XBMC Launcher (xbmc / kodi)
|
||||
# ------------------------------------------------------------
|
||||
|
||||
#from future import standard_library
|
||||
#standard_library.install_aliases()
|
||||
#from builtins import str
|
||||
import sys
|
||||
import sys, os
|
||||
PY3 = False
|
||||
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
||||
|
||||
# if PY3:
|
||||
# import urllib.error as urllib2 # It is very slow in PY2. In PY3 it is native
|
||||
# else:
|
||||
# import urllib2 # We use the native of PY2 which is faster
|
||||
|
||||
import os
|
||||
if sys.version_info[0] >= 3:PY3 = True; unicode = str; unichr = chr; long = int
|
||||
|
||||
from core.item import Item
|
||||
from platformcode import config, logger, platformtools
|
||||
@@ -65,11 +55,7 @@ def run(item=None):
|
||||
config.get_localized_string(70137): 'peliculas',
|
||||
config.get_localized_string(30123): 'series',
|
||||
config.get_localized_string(30124): 'anime',
|
||||
config.get_localized_string(70018): 'infantiles',
|
||||
config.get_localized_string(60513): 'documentales',
|
||||
config.get_localized_string(70013): 'terror',
|
||||
config.get_localized_string(70014): 'castellano',
|
||||
config.get_localized_string(59976): 'latino',
|
||||
config.get_localized_string(70171): 'torrent',
|
||||
}
|
||||
if not config.get_setting("category") in dictCategory.keys():
|
||||
@@ -142,7 +128,6 @@ def run(item=None):
|
||||
if tmdb.drop_bd():
|
||||
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60011), time=2000, sound=False)
|
||||
elif item.action == "itemInfo":
|
||||
import base64
|
||||
platformtools.dialog_textviewer('Item info', item.parent)
|
||||
elif item.action == "open_browser":
|
||||
import webbrowser
|
||||
@@ -155,18 +140,10 @@ def run(item=None):
|
||||
import urllib.request as urllib
|
||||
except ImportError:
|
||||
import urllib
|
||||
short = urllib.urlopen(
|
||||
'https://u.nu/api.php?action=shorturl&format=simple&url=' + item.url).read().decode('utf-8')
|
||||
platformtools.dialog_ok(config.get_localized_string(20000),
|
||||
config.get_localized_string(70740) % short)
|
||||
short = urllib.urlopen('https://u.nu/api.php?action=shorturl&format=simple&url=' + item.url).read().decode('utf-8')
|
||||
platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(70740) % short)
|
||||
# Action in certain channel specified in "action" and "channel" parameters
|
||||
else:
|
||||
# # Actualiza el canal individual
|
||||
# if (item.action == "mainlist" and item.channel != "channelselector" and
|
||||
# config.get_setting("check_for_channel_updates") == True):
|
||||
# from core import updater
|
||||
# updater.update_channel(item.channel)
|
||||
|
||||
# Checks if channel exists
|
||||
if os.path.isfile(os.path.join(config.get_runtime_path(), 'channels', item.channel + ".py")):
|
||||
CHANNELS = 'channels'
|
||||
@@ -181,8 +158,7 @@ def run(item=None):
|
||||
|
||||
if os.path.exists(channel_file):
|
||||
try:
|
||||
channel = __import__('%s.%s' % (CHANNELS, item.channel), None,
|
||||
None, ['%s.%s' % (CHANNELS, item.channel)])
|
||||
channel = __import__('%s.%s' % (CHANNELS, item.channel), None, None, ['%s.%s' % (CHANNELS, item.channel)])
|
||||
except ImportError:
|
||||
exec("import " + CHANNELS + "." + item.channel + " as channel")
|
||||
|
||||
@@ -211,7 +187,7 @@ def run(item=None):
|
||||
item.isFavourite = True
|
||||
platformtools.play_video(item)
|
||||
|
||||
# Permitir varias calidades desde play en el canal
|
||||
# Permitir varias calidades desde play en el Channel
|
||||
elif len(itemlist) > 0 and isinstance(itemlist[0], list):
|
||||
item.video_urls = itemlist
|
||||
platformtools.play_video(item)
|
||||
@@ -232,7 +208,6 @@ def run(item=None):
|
||||
# First checks if channel has a "findvideos" function
|
||||
if hasattr(channel, 'findvideos'):
|
||||
itemlist = getattr(channel, item.action)(item)
|
||||
itemlist = servertools.filter_servers(itemlist)
|
||||
|
||||
# If not, uses the generic findvideos function
|
||||
else:
|
||||
@@ -310,32 +285,18 @@ def run(item=None):
|
||||
|
||||
platformtools.render_items(itemlist, item)
|
||||
|
||||
# except urllib2.URLError as e:
|
||||
# import traceback
|
||||
# logger.error(traceback.format_exc())
|
||||
#
|
||||
# # Grab inner and third party errors
|
||||
# if hasattr(e, 'reason'):
|
||||
# logger.error("Reason for the error, code: %s | Reason: %s" % (str(e.reason[0]), str(e.reason[1])))
|
||||
# texto = config.get_localized_string(30050) # "No se puede conectar con el sitio web"
|
||||
# platformtools.dialog_ok(config.get_localized_string(20000), texto)
|
||||
#
|
||||
# # Grab server response errors
|
||||
# elif hasattr(e, 'code'):
|
||||
# logger.error("HTTP error code: %d" % e.code)
|
||||
# # "El sitio web no funciona correctamente (error http %d)"
|
||||
# platformtools.dialog_ok(config.get_localized_string(20000), config.get_localized_string(30051) % e.code)
|
||||
|
||||
except WebErrorException as e:
|
||||
import traceback
|
||||
from core import scrapertools
|
||||
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\", "\\\\") + '([^.]+)\.py"'
|
||||
canal = scrapertools.find_single_match(traceback.format_exc(), patron)
|
||||
patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\", "\\\\") + r'([^.]+)\.py"'
|
||||
Channel = scrapertools.find_single_match(traceback.format_exc(), patron)
|
||||
|
||||
platformtools.dialog_ok(
|
||||
config.get_localized_string(59985) + canal,
|
||||
config.get_localized_string(59985) + Channel,
|
||||
config.get_localized_string(60013) %(e))
|
||||
except:
|
||||
import traceback
|
||||
@@ -343,8 +304,8 @@ def run(item=None):
|
||||
|
||||
logger.error(traceback.format_exc())
|
||||
|
||||
patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\", "\\\\") + '([^.]+)\.py"'
|
||||
canal = scrapertools.find_single_match(traceback.format_exc(), patron)
|
||||
patron = 'File "' + os.path.join(config.get_runtime_path(), "channels", "").replace("\\", "\\\\") + r'([^.]+)\.py"'
|
||||
Channel = scrapertools.find_single_match(traceback.format_exc(), patron)
|
||||
|
||||
try:
|
||||
import xbmc
|
||||
@@ -356,15 +317,12 @@ def run(item=None):
|
||||
except:
|
||||
log_message = ""
|
||||
|
||||
if canal:
|
||||
if Channel:
|
||||
if item.url:
|
||||
if platformtools.dialog_yesno(config.get_localized_string(60087) % canal, config.get_localized_string(60014),
|
||||
log_message, nolabel='ok', yeslabel=config.get_localized_string(70739)):
|
||||
if platformtools.dialog_yesno(config.get_localized_string(60087) % Channel, config.get_localized_string(60014), log_message, nolabel='ok', yeslabel=config.get_localized_string(70739)):
|
||||
run(Item(action="open_browser", url=item.url))
|
||||
else:
|
||||
platformtools.dialog_ok(config.get_localized_string(60087) % canal,
|
||||
config.get_localized_string(60014),
|
||||
log_message)
|
||||
platformtools.dialog_ok(config.get_localized_string(60087) % Channel, config.get_localized_string(60014), log_message)
|
||||
else:
|
||||
platformtools.dialog_ok(
|
||||
config.get_localized_string(60038),
|
||||
@@ -384,8 +342,7 @@ def reorder_itemlist(itemlist):
|
||||
modified = 0
|
||||
not_modified = 0
|
||||
|
||||
to_change = [[config.get_localized_string(60335), '[V]'],
|
||||
[config.get_localized_string(60336), '[D]']]
|
||||
to_change = [[config.get_localized_string(60335), '[V]'], [config.get_localized_string(60336), '[D]']]
|
||||
|
||||
for item in itemlist:
|
||||
if not PY3:
|
||||
@@ -441,7 +398,6 @@ def limit_itemlist(itemlist):
|
||||
|
||||
|
||||
def play_from_library(item):
|
||||
itemlist=[]
|
||||
"""
|
||||
The .strm files when played from kodi, this expects it to be a "playable" file so it cannot contain
|
||||
more items, at most a selection dialog can be placed.
|
||||
@@ -452,115 +408,67 @@ def play_from_library(item):
|
||||
@type item: item
|
||||
@param item: item with information
|
||||
"""
|
||||
import xbmcgui, xbmcplugin, xbmc
|
||||
from time import sleep
|
||||
|
||||
itemlist=[]
|
||||
item.fromLibrary = True
|
||||
logger.info()
|
||||
# logger.debug("item: \n" + item.tostring('\n'))
|
||||
|
||||
import xbmcgui
|
||||
import xbmcplugin
|
||||
import xbmc
|
||||
from time import sleep, time
|
||||
from specials import nextep
|
||||
|
||||
# We try to reproduce an image (this does nothing and also does not give an error)
|
||||
# Try to reproduce an image (this does nothing and also does not give an error)
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4")))
|
||||
|
||||
# Just in case the image did (in future versions) we give stop to stop the reproduction
|
||||
# sleep(0.5) ### If you don't put this on you crash Kodi
|
||||
xbmc.Player().stop()
|
||||
|
||||
# we modify the action (currently the video library needs "findvideos" since this is where the sources are searched
|
||||
# Modify the action (currently the video library needs "findvideos" since this is where the sources are searched
|
||||
item.action = "findvideos"
|
||||
check_next_ep = nextep.check(item)
|
||||
|
||||
|
||||
window_type = config.get_setting("window_type", "videolibrary")
|
||||
|
||||
# and we launch kodi again
|
||||
# and launch kodi again
|
||||
if xbmc.getCondVisibility('Window.IsMedia') and not window_type == 1:
|
||||
# Conventional window
|
||||
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")")
|
||||
|
||||
else:
|
||||
|
||||
# Pop-up window
|
||||
item.show_server = True
|
||||
|
||||
from specials import videolibrary, autoplay
|
||||
from specials import videolibrary
|
||||
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(60683))
|
||||
p_dialog.update(0, '')
|
||||
|
||||
item.play_from = 'window'
|
||||
itemlist = videolibrary.findvideos(item)
|
||||
p_dialog.update(100, ''); sleep(0.5); p_dialog.close()
|
||||
while platformtools.is_playing(): # Conventional window
|
||||
sleep(1)
|
||||
play_time = platformtools.resume_playback(item, True)
|
||||
if not play_time and config.get_setting('autoplay'):
|
||||
return
|
||||
|
||||
if check_next_ep and autoplay.is_active(item.contentChannel):
|
||||
p_dialog.update(100, '')
|
||||
sleep(0.5)
|
||||
p_dialog.close()
|
||||
item = nextep.return_item(item)
|
||||
if item.next_ep:
|
||||
return play_from_library(item)
|
||||
# The number of links to show is limited
|
||||
if config.get_setting("max_links", "videolibrary") != 0: itemlist = limit_itemlist(itemlist)
|
||||
# The list of links is slightly "cleaned"
|
||||
if config.get_setting("replace_VD", "videolibrary") == 1: itemlist = reorder_itemlist(itemlist)
|
||||
|
||||
else:
|
||||
while platformtools.is_playing():
|
||||
# Conventional window
|
||||
sleep(5)
|
||||
p_dialog.update(50, '')
|
||||
|
||||
it = item
|
||||
if item.show_server or not check_next_ep:
|
||||
|
||||
# The links are filtered according to the blacklist
|
||||
# if config.get_setting('filter_servers', "servers"):
|
||||
# itemlist = servertools.filter_servers(itemlist)
|
||||
|
||||
# The number of links to show is limited
|
||||
if config.get_setting("max_links", "videolibrary") != 0:
|
||||
itemlist = limit_itemlist(itemlist)
|
||||
|
||||
# The list of links is slightly "cleaned"
|
||||
if config.get_setting("replace_VD", "videolibrary") == 1:
|
||||
itemlist = reorder_itemlist(itemlist)
|
||||
|
||||
|
||||
p_dialog.update(100, '')
|
||||
sleep(0.5)
|
||||
p_dialog.close()
|
||||
|
||||
|
||||
if len(itemlist) > 0:
|
||||
while not xbmc.Monitor().abortRequested():
|
||||
# The user chooses the mirror
|
||||
opciones = []
|
||||
for item in itemlist:
|
||||
opciones.append(item.title)
|
||||
|
||||
# The selection window opens
|
||||
if (item.contentSerieName != "" and
|
||||
item.contentSeason != "" and
|
||||
item.contentEpisodeNumber != ""):
|
||||
cabecera = ("%s - %sx%s -- %s" %
|
||||
(item.contentSerieName,
|
||||
item.contentSeason,
|
||||
item.contentEpisodeNumber,
|
||||
config.get_localized_string(30163)))
|
||||
if len(itemlist) > 0:
|
||||
while not xbmc.Monitor().abortRequested():
|
||||
# The user chooses the mirror
|
||||
options = []
|
||||
selection_implementation = 0
|
||||
for item in itemlist:
|
||||
item.thumbnail = config.get_online_server_thumb(item.server)
|
||||
quality = '[B][' + item.quality + '][/B]' if item.quality else ''
|
||||
if item.server:
|
||||
it = xbmcgui.ListItem('\n[B]%s[/B] %s - %s' % (item.server, quality, item.contentTitle))
|
||||
it.setArt({'thumb':item.thumbnail})
|
||||
options.append(it)
|
||||
else:
|
||||
cabecera = config.get_localized_string(30163)
|
||||
|
||||
|
||||
seleccion = platformtools.dialog_select(cabecera, opciones)
|
||||
|
||||
if seleccion == -1:
|
||||
return
|
||||
else:
|
||||
item = videolibrary.play(itemlist[seleccion])[0]
|
||||
item.play_from = 'window'
|
||||
platformtools.play_video(item)
|
||||
|
||||
if (platformtools.is_playing() and item.action) or item.server == 'torrent' or autoplay.is_active(item.contentChannel):
|
||||
break
|
||||
|
||||
if it.show_server and check_next_ep:
|
||||
nextep.run(it)
|
||||
sleep(0.5)
|
||||
p_dialog.close()
|
||||
|
||||
selection_implementation += 1
|
||||
# The selection window opens
|
||||
if (item.contentSerieName and item.contentSeason and item.contentEpisodeNumber): head = ("%s - %sx%s | %s" % (item.contentSerieName, item.contentSeason, item.contentEpisodeNumber, config.get_localized_string(30163)))
|
||||
else: head = config.get_localized_string(30163)
|
||||
selection = platformtools.dialog_select(head, options, preselect= -1, useDetails=True)
|
||||
if selection == -1:
|
||||
return
|
||||
else:
|
||||
item = videolibrary.play(itemlist[selection + selection_implementation])[0]
|
||||
platformtools.play_video(item)
|
||||
if (platformtools.is_playing() and item.action) or item.server == 'torrent' or config.get_setting('autoplay'): break
|
||||
@@ -6,24 +6,18 @@
|
||||
# version 2.0
|
||||
# ------------------------------------------------------------
|
||||
|
||||
from __future__ import division
|
||||
from __future__ import absolute_import
|
||||
from past.utils import old_div
|
||||
import sys
|
||||
PY3 = False
|
||||
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
||||
|
||||
if PY3:
|
||||
if sys.version_info[0] >= 3:
|
||||
import urllib.parse as urllib
|
||||
else:
|
||||
import urllib
|
||||
|
||||
import os, xbmc, xbmcgui, xbmcplugin
|
||||
|
||||
from past.utils import old_div
|
||||
from channelselector import get_thumb
|
||||
from core import channeltools, trakt_tools, scrapertools
|
||||
from core import trakt_tools, scrapertools
|
||||
from core.item import Item
|
||||
from platformcode import logger, config, unify
|
||||
from platformcode import logger, config
|
||||
|
||||
addon = config.__settings__
|
||||
addon_icon = os.path.join( addon.getAddonInfo( "path" ), "logo.png" )
|
||||
@@ -73,8 +67,8 @@ def dialog_yesno(heading, line1, line2="", line3="", nolabel="No", yeslabel="Si"
|
||||
return dialog.yesno(heading, makeMessage(line1, line2, line3), nolabel=nolabel, yeslabel=yeslabel)
|
||||
|
||||
|
||||
def dialog_select(heading, _list, preselect=0):
|
||||
return xbmcgui.Dialog().select(heading, _list, preselect=preselect)
|
||||
def dialog_select(heading, _list, preselect=0, useDetails=False):
|
||||
return xbmcgui.Dialog().select(heading, _list, preselect=preselect, useDetails=useDetails)
|
||||
|
||||
|
||||
def dialog_multiselect(heading, _list, autoclose=0, preselect=[], useDetails=False):
|
||||
@@ -122,15 +116,15 @@ def dialog_browse(_type, heading, default=""):
|
||||
|
||||
|
||||
def itemlist_refresh():
|
||||
pos = Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition
|
||||
logger.info('Current position: ' + str(pos))
|
||||
# pos = Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition
|
||||
# logger.info('Current position: ' + str(pos))
|
||||
xbmc.executebuiltin("Container.Refresh")
|
||||
|
||||
while Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition != pos:
|
||||
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
|
||||
cid = win.getFocusId()
|
||||
ctl = win.getControl(cid)
|
||||
ctl.selectItem(pos)
|
||||
# while Item().fromurl(xbmc.getInfoLabel('ListItem.FileNameAndPath')).itemlistPosition != pos:
|
||||
# win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
|
||||
# cid = win.getFocusId()
|
||||
# ctl = win.getControl(cid)
|
||||
# ctl.selectItem(pos)
|
||||
|
||||
|
||||
def itemlist_update(item, replace=False):
|
||||
@@ -168,7 +162,7 @@ def render_items(itemlist, parent_item):
|
||||
|
||||
dirItems = []
|
||||
for n, item in enumerate(itemlist):
|
||||
item.itemlistPosition = n + 1
|
||||
# item.itemlistPosition = n + 1
|
||||
item_url = item.tourl()
|
||||
|
||||
if item.category == "":
|
||||
@@ -181,7 +175,7 @@ def render_items(itemlist, parent_item):
|
||||
if item.fanart == "":
|
||||
item.fanart = parent_item.fanart
|
||||
if item.action == 'play' and thumb_type == 1 and not item.forcethumb:
|
||||
item.thumbnail = "https://github.com/kodiondemand/media/raw/master/resources/servers/" + item.server.lower() + '.png'
|
||||
item.thumbnail = config.get_online_server_thumb(item.server)
|
||||
|
||||
# if cloudflare and cloudscraper is used, cookies are needed to display images taken from site
|
||||
# before checking domain (time consuming), checking if tmdb failed (so, images scraped from website are used)
|
||||
@@ -198,7 +192,7 @@ def render_items(itemlist, parent_item):
|
||||
listitem.setArt({'icon': icon_image, 'thumb': item.thumbnail, 'poster': item.thumbnail,
|
||||
'fanart': item.fanart if item.fanart else default_fanart})
|
||||
|
||||
if config.get_setting("player_mode") == 1 and item.action == "play":
|
||||
if config.get_setting("player_mode") == 1 and item.action == "play" and not item.nfo:
|
||||
listitem.setProperty('IsPlayable', 'true')
|
||||
|
||||
set_infolabels(listitem, item)
|
||||
@@ -254,7 +248,7 @@ def getCurrentView(item=None, parent_item=None):
|
||||
elif (item.contentType in ['movie'] and parent_item.action in parent_actions) \
|
||||
or (item.channel in ['videolibrary'] and parent_item.action in ['list_movies']) \
|
||||
or (parent_item.channel in ['favorites'] and parent_item.action in ['mainlist']) \
|
||||
or parent_item.action in ['now_on_tv', 'now_on_misc', 'now_on_misc_film', 'mostrar_perfil']:
|
||||
or parent_item.action in ['now_on_tv', 'now_on_misc', 'now_on_misc_film', 'mostrar_perfil', 'live']:
|
||||
return 'movie', 'movies'
|
||||
|
||||
elif (item.contentType in ['tvshow'] and parent_item.action in parent_actions) \
|
||||
@@ -293,255 +287,6 @@ def set_view_mode(item, parent_item):
|
||||
logger.info('TYPE: ' + Type + ' - ' + 'CONTENT: ' + content)
|
||||
|
||||
|
||||
# def render_items_old(itemlist, parent_item):
|
||||
# """
|
||||
# Function responsible for displaying the itemlist in kodi, the itemlist and the item it comes from are passed as parameters
|
||||
# @type itemlist: list
|
||||
# @param itemlist: list of elements to show
|
||||
|
||||
# @type parent_item: item
|
||||
# @param parent_item: parent element
|
||||
# """
|
||||
# logger.info('START render_items')
|
||||
# from core import httptools
|
||||
|
||||
# # If the itemlist is not a list we leave
|
||||
# if not isinstance(itemlist, list):
|
||||
# return
|
||||
|
||||
# if parent_item.start:
|
||||
# menu_icon = get_thumb('menu.png')
|
||||
# menu = Item(channel="channelselector", action="getmainlist", viewmode="movie", thumbnail=menu_icon, title='Menu')
|
||||
# itemlist.insert(0, menu)
|
||||
|
||||
# # If there is no item, we show a notice
|
||||
# if not len(itemlist):
|
||||
# itemlist.append(Item(title=config.get_localized_string(60347), thumbnail=get_thumb('nofolder.png')))
|
||||
|
||||
# genre = False
|
||||
# if 'nero' in parent_item.title:
|
||||
# genre = True
|
||||
# anime = False
|
||||
# if 'anime' in channeltools.get_channel_parameters(parent_item.channel)['categories']:
|
||||
# anime = True
|
||||
# # try:
|
||||
# # force_unify = channeltools.get_channel_parameters(parent_item.channel)['force_unify']
|
||||
# # except:
|
||||
# force_unify = False
|
||||
|
||||
# unify_enabled = False
|
||||
|
||||
# has_extendedinfo = xbmc.getCondVisibility('System.HasAddon(script.extendedinfo)')
|
||||
|
||||
# # Add SuperFavourites to context menu (1.0.53 or higher required)
|
||||
# sf_file_path = xbmc.translatePath("special://home/addons/plugin.program.super.favourites/LaunchSFMenu.py")
|
||||
# check_sf = os.path.exists(sf_file_path)
|
||||
# superfavourites = check_sf and xbmc.getCondVisibility('System.HasAddon("plugin.program.super.favourites")')
|
||||
# # try:
|
||||
# # if channeltools.get_channel_parameters(parent_item.channel)['adult']:
|
||||
# # unify_enabled = False
|
||||
# # except:
|
||||
# # pass
|
||||
# # logger.debug('unify_enabled: %s' % unify_enabled)
|
||||
|
||||
# # We go through the itemlist
|
||||
# for item in itemlist:
|
||||
# # logger.debug(item)
|
||||
# # If the item does not contain a category, we will add the parent item
|
||||
# item_url = item.tourl()
|
||||
# if item.category == "":
|
||||
# item.category = parent_item.category
|
||||
|
||||
# # If title does not exist, we start it as str, to avoid "NoType" mistakes
|
||||
# if not item.title:
|
||||
# item.title = ''
|
||||
|
||||
# # If there is no action or it is findvideos / play, folder = False because no listing will be returned
|
||||
# if item.action in ['play', '']:
|
||||
# item.folder = False
|
||||
|
||||
# # If the item does not contain fanart, we put the one of the parent item
|
||||
# if item.fanart == "":
|
||||
# item.fanart = parent_item.fanart
|
||||
|
||||
# if genre:
|
||||
# valid_genre = True
|
||||
# thumb = get_thumb(item.title, auto=True)
|
||||
# if thumb != '':
|
||||
# item.thumbnail = thumb
|
||||
# valid_genre = True
|
||||
# elif anime:
|
||||
# valid_genre = True
|
||||
# elif (('siguiente' in item.title.lower() and '>' in item.title) or ('pagina:' in item.title.lower())):
|
||||
# item.thumbnail = get_thumb("next.png")
|
||||
# elif 'add' in item.action:
|
||||
# if 'pelicula' in item.action:
|
||||
# item.thumbnail = get_thumb("add_to_videolibrary.png")
|
||||
# elif 'serie' in item.action:
|
||||
# item.thumbnail = get_thumb("add_to_videolibrary.png")
|
||||
|
||||
# if (unify_enabled or force_unify) and parent_item.channel not in ['kodfavourites']:
|
||||
# # Format title with unify
|
||||
# item = unify.title_format(item)
|
||||
# else:
|
||||
# # Format title method old school
|
||||
# if item.text_color:
|
||||
# item.title = '[COLOR %s]%s[/COLOR]' % (item.text_color, item.title)
|
||||
# if item.text_bold:
|
||||
# item.title = '[B]%s[/B]' % item.title
|
||||
# if item.text_italic:
|
||||
# item.title = '[I]%s[/I]' % item.title
|
||||
|
||||
# # Add headers to images if they are on a server with cloudflare
|
||||
# if item.action == 'play':
|
||||
# item.thumbnail = unify.thumbnail_type(item)
|
||||
# else:
|
||||
# item.thumbnail = httptools.get_url_headers(item.thumbnail)
|
||||
# item.fanart = httptools.get_url_headers(item.fanart)
|
||||
|
||||
# # Icon Image for folder and video
|
||||
# if item.folder:
|
||||
# icon_image = "DefaultFolder.png"
|
||||
# else:
|
||||
# icon_image = "DefaultVideo.png"
|
||||
|
||||
# # fanart
|
||||
# if item.fanart:
|
||||
# fanart = item.fanart
|
||||
# else:
|
||||
# fanart = config.get_fanart()
|
||||
|
||||
# # Create listitem
|
||||
# listitem = xbmcgui.ListItem(item.title)
|
||||
|
||||
# # values icon, thumb or poster are skin dependent.. so we set all to avoid problems
|
||||
# # if not exists thumb it's used icon value
|
||||
# if config.get_platform(True)['num_version'] >= 16.0:
|
||||
# listitem.setArt({'icon': icon_image, 'thumb': item.thumbnail, 'poster': item.thumbnail,
|
||||
# 'fanart': fanart})
|
||||
# else:
|
||||
# listitem.setIconImage(icon_image)
|
||||
# listitem.setThumbnailImage(item.thumbnail)
|
||||
# listitem.setProperty('fanart_image', fanart)
|
||||
|
||||
# # No need it, use fanart instead
|
||||
# # xbmcplugin.setPluginFanart(int(sys.argv[1]), os.path.join(config.get_runtime_path(), "fanart.jpg"))
|
||||
|
||||
# # This option is to be able to use the xbmcplugin.setResolvedUrl()
|
||||
# # if item.isPlayable == True or (config.get_setting("player_mode") == 1 and item.action == "play"):
|
||||
# if config.get_setting("player_mode") == 1 and item.action == "play":
|
||||
# listitem.setProperty('IsPlayable', 'true')
|
||||
|
||||
# # Add infoLabels
|
||||
# set_infolabels(listitem, item)
|
||||
|
||||
# # Do not drag plot if it is not a movie / series / season / episode
|
||||
# if item.plot and item.contentType not in ['movie', 'tvshow', 'season', 'episode']:
|
||||
# item.__dict__['infoLabels'].pop('plot')
|
||||
|
||||
# # Mount context menu
|
||||
# if parent_item.channel != 'special':
|
||||
# context_commands = set_context_commands(item, item_url, parent_item, has_extendedinfo=has_extendedinfo, superfavourites=superfavourites)
|
||||
# else:
|
||||
# context_commands = []
|
||||
# # Add context menu
|
||||
# if config.get_platform(True)['num_version'] >= 17.0 and parent_item.list_type == '':
|
||||
# listitem.addContextMenuItems(context_commands)
|
||||
# elif parent_item.list_type == '':
|
||||
# listitem.addContextMenuItems(context_commands, replaceItems=True)
|
||||
|
||||
# from specials import shortcuts
|
||||
# context_commands += shortcuts.context()
|
||||
|
||||
# if not item.totalItems:
|
||||
# item.totalItems = 0
|
||||
# xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url='%s?%s' % (sys.argv[0], item_url),
|
||||
# listitem=listitem, isFolder=item.folder,
|
||||
# totalItems=item.totalItems)
|
||||
|
||||
# # Set types of views ...
|
||||
# if config.get_setting("forceview"): # ...force according to the viewcontent
|
||||
# xbmcplugin.setContent(int(sys.argv[1]), parent_item.viewcontent)
|
||||
|
||||
# elif parent_item.channel not in ["channelselector", "", "kodfavourites"]: # ... or according to the channel
|
||||
# xbmcplugin.setContent(int(sys.argv[1]), "movies")
|
||||
|
||||
# elif parent_item.channel == "kodfavourites" and parent_item.action == 'mostrar_perfil':
|
||||
# xbmcplugin.setContent(int(sys.argv[1]), "movies")
|
||||
|
||||
# # set "breadcrumb"
|
||||
# if parent_item.list_type == '':
|
||||
# breadcrumb = parent_item.category.capitalize()
|
||||
# else:
|
||||
# if 'similar' in parent_item.list_type:
|
||||
# if parent_item.contentTitle != '':
|
||||
# breadcrumb = config.get_localized_string(70693) + parent_item.contentTitle
|
||||
# else:
|
||||
# breadcrumb = config.get_localized_string(70693) + parent_item.contentSerieName
|
||||
# else:
|
||||
# breadcrumb = config.get_localized_string(70693)
|
||||
|
||||
# xbmcplugin.setPluginCategory(handle=int(sys.argv[1]), category=breadcrumb)
|
||||
|
||||
# # Do not sort items
|
||||
# xbmcplugin.addSortMethod(handle=int(sys.argv[1]), sortMethod=xbmcplugin.SORT_METHOD_NONE)
|
||||
|
||||
# # We close the directory
|
||||
# xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=True)
|
||||
|
||||
# # Fix the view
|
||||
# # if config.get_setting("forceview"):
|
||||
# # viewmode_id = get_viewmode_id(parent_item)
|
||||
# # xbmc.executebuiltin("Container.SetViewMode(%s)" % viewmode_id)
|
||||
# # if parent_item.mode in ['silent', 'get_cached', 'set_cache', 'finish']:
|
||||
# # xbmc.executebuiltin("Container.SetViewMode(500)")
|
||||
|
||||
# logger.info('END render_items')
|
||||
|
||||
|
||||
# def get_viewmode_id(parent_item):
|
||||
# # viewmode_json would have to save it in a file and create a method for the user to set their preferences in:
|
||||
# # user_files, user_movies, user_tvshows, user_season and user_episodes.
|
||||
# viewmode_json = {'skin.confluence': {'default_files': 50,
|
||||
# 'default_movies': 515,
|
||||
# 'default_tvshows': 508,
|
||||
# 'default_seasons': 503,
|
||||
# 'default_episodes': 504,
|
||||
# 'view_list': 50,
|
||||
# 'view_thumbnails': 500,
|
||||
# 'view_movie_with_plot': 503},
|
||||
# 'skin.estuary': {'default_files': 50,
|
||||
# 'default_movies': 54,
|
||||
# 'default_tvshows': 502,
|
||||
# 'default_seasons': 500,
|
||||
# 'default_episodes': 53,
|
||||
# 'view_list': 50,
|
||||
# 'view_thumbnails': 500,
|
||||
# 'view_movie_with_plot': 54}}
|
||||
|
||||
# # If the parent_item had a viewmode set we use that view ...
|
||||
# if parent_item.viewmode == 'movie':
|
||||
# # We replace the old viewmode 'movie' with 'thumbnails'
|
||||
# parent_item.viewmode = 'thumbnails'
|
||||
|
||||
# if parent_item.viewmode in ["list", "movie_with_plot", "thumbnails"]:
|
||||
# view_name = "view_" + parent_item.viewmode
|
||||
|
||||
# '''elif isinstance(parent_item.viewmode, int):
|
||||
# # only for debug
|
||||
# viewName = parent_item.viewmode'''
|
||||
|
||||
# # ...otherwise we put the default view according to the viewcontent
|
||||
# else:
|
||||
# view_name = "default_" + parent_item.viewcontent
|
||||
|
||||
# skin_name = xbmc.getSkinDir()
|
||||
# if skin_name not in viewmode_json:
|
||||
# skin_name = 'skin.confluence'
|
||||
# view_skin = viewmode_json[skin_name]
|
||||
# return view_skin.get(view_name, 50)
|
||||
|
||||
|
||||
def set_infolabels(listitem, item, player=False):
|
||||
"""
|
||||
Method to pass the information to the listitem (see tmdb.set_InfoLabels())
|
||||
@@ -582,32 +327,6 @@ def set_infolabels(listitem, item, player=False):
|
||||
listitem.setInfo("video", item.infoLabels)
|
||||
# logger.error(item.infoLabels)
|
||||
|
||||
# if item.infoLabels:
|
||||
# if 'mediatype' not in item.infoLabels:
|
||||
# item.infoLabels['mediatype'] = item.contentType
|
||||
#
|
||||
# try:
|
||||
# for label_tag, label_value in list(item.infoLabels.items()):
|
||||
# try:
|
||||
# # logger.debug(str(label_tag) + ': ' + str(infoLabels_dict[label_tag]))
|
||||
# if infoLabels_dict[label_tag] != 'None':
|
||||
# infoLabels_kodi.update({infoLabels_dict[label_tag]: item.infoLabels[label_tag]})
|
||||
# except:
|
||||
# continue
|
||||
#
|
||||
# listitem.setInfo("video", infoLabels_kodi)
|
||||
#
|
||||
# except:
|
||||
# listitem.setInfo("video", item.infoLabels)
|
||||
# logger.error(item.infoLabels)
|
||||
# logger.error(infoLabels_kodi)
|
||||
#
|
||||
# if player and not item.contentTitle:
|
||||
# listitem.setInfo("video", {"Title": item.title})
|
||||
#
|
||||
# elif not player:
|
||||
# listitem.setInfo("video", {"Title": item.title})
|
||||
|
||||
|
||||
def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
"""
|
||||
@@ -686,17 +405,12 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
# ExtendedInfo: If the addon is installed and a series of conditions are met
|
||||
if kwargs.get('has_extendedinfo') \
|
||||
and config.get_setting("extended_info") == True:
|
||||
if item.contentType == "episode" and item.contentEpisodeNumber and item.contentSeason \
|
||||
and (item.infoLabels['tmdb_id'] or item.contentSerieName):
|
||||
param = "tvshow_id =%s, tvshow=%s, season=%s, episode=%s" \
|
||||
% (item.infoLabels['tmdb_id'], item.contentSerieName, item.contentSeason,
|
||||
item.contentEpisodeNumber)
|
||||
if item.contentType == "episode" and item.contentEpisodeNumber and item.contentSeason and (item.infoLabels['tmdb_id'] or item.contentSerieName):
|
||||
param = "tvshow_id =%s, tvshow=%s, season=%s, episode=%s" % (item.infoLabels['tmdb_id'], item.contentSerieName, item.contentSeason, item.contentEpisodeNumber)
|
||||
context_commands.append(("ExtendedInfo", "XBMC.RunScript(script.extendedinfo,info=extendedepisodeinfo,%s)" % param))
|
||||
|
||||
elif item.contentType == "season" and item.contentSeason \
|
||||
and (item.infoLabels['tmdb_id'] or item.contentSerieName):
|
||||
param = "tvshow_id =%s,tvshow=%s, season=%s" \
|
||||
% (item.infoLabels['tmdb_id'], item.contentSerieName, item.contentSeason)
|
||||
elif item.contentType == "season" and item.contentSeason and (item.infoLabels['tmdb_id'] or item.contentSerieName):
|
||||
param = "tvshow_id =%s,tvshow=%s, season=%s" % (item.infoLabels['tmdb_id'], item.contentSerieName, item.contentSeason)
|
||||
context_commands.append(("ExtendedInfo", "XBMC.RunScript(script.extendedinfo,info=seasoninfo,%s)" % param))
|
||||
|
||||
elif item.contentType == "tvshow" and (item.infoLabels['tmdb_id'] or item.infoLabels['tvdb_id'] or item.infoLabels['imdb_id'] or item.contentSerieName):
|
||||
@@ -705,15 +419,14 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
|
||||
elif item.contentType == "movie" and (item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.contentTitle):
|
||||
param = "id =%s,imdb_id=%s,name=%s" % (item.infoLabels['tmdb_id'], item.infoLabels['imdb_id'], item.contentTitle)
|
||||
|
||||
context_commands.append(("ExtendedInfo", "XBMC.RunScript(script.extendedinfo,info=extendedinfo,%s)" % param))
|
||||
# InfoPlus
|
||||
|
||||
# InfoPlus
|
||||
if config.get_setting("infoplus"):
|
||||
#if item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.infoLabels['tvdb_id'] or \
|
||||
# (item.contentTitle and item.infoLabels["year"]) or item.contentSerieName:
|
||||
if item.infoLabels['tmdb_id'] or item.infoLabels['imdb_id'] or item.infoLabels['tvdb_id']:
|
||||
context_commands.append(("InfoPlus", "XBMC.RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url,
|
||||
'channel=infoplus&action=start&from_channel=' + item.channel)))
|
||||
context_commands.append(("InfoPlus", "XBMC.RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=infoplus&action=start&from_channel=' + item.channel)))
|
||||
|
||||
# Go to the Main Menu (channel.mainlist)
|
||||
if parent_item.channel not in ["news", "channelselector", "downloads"] and item.action != "mainlist":
|
||||
@@ -721,13 +434,6 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
context_commands.insert(0, (config.get_localized_string(60349), "XBMC.Container.Refresh (%s?%s)" % (sys.argv[0], Item(channel=item.channel, action="mainlist").tourl())))
|
||||
context_commands.insert(1, (config.get_localized_string(70739), "XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(action="open_browser", url=item.url).tourl())))
|
||||
|
||||
# Add to Favorites
|
||||
# if num_version_xbmc < 17.0 and \
|
||||
# ((item.channel not in ["favorites", "videolibrary", "help", ""]
|
||||
# or item.action in ["update_videolibrary"]) and parent_item.channel != "favorites"):
|
||||
# context_commands.append((config.get_localized_string(30155), "XBMC.RunPlugin(%s?%s&%s)" %
|
||||
# (sys.argv[0], item_url, 'channel=favorites&action=addFavourite&from_channel=' + item.channel + '&from_action=' + item.action)))
|
||||
|
||||
# Add to kodfavoritos (My links)
|
||||
if item.channel not in ["favorites", "videolibrary", "help", ""] and parent_item.channel != "favorites":
|
||||
context_commands.append( (config.get_localized_string(70557), "XBMC.RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': "kodfavorites", 'action': "addFavourite", 'from_channel': item.channel, 'from_action': item.action}))))
|
||||
@@ -748,6 +454,7 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
context_commands.append((config.get_localized_string(60350), "XBMC.Container.Update (%s?%s&%s)" % (sys.argv[0], item_url, urllib.urlencode({'channel': 'search', 'action': "from_context", 'from_channel': item.channel, 'contextual': True, 'text': item.wanted}))))
|
||||
|
||||
context_commands.append( (config.get_localized_string(70561), "XBMC.Container.Update (%s?%s&%s)" % (sys.argv[0], item_url, 'channel=search&action=from_context&search_type=list&page=1&list_type=%s/%s/similar' % (mediatype, item.infoLabels['tmdb_id']))))
|
||||
|
||||
# Set as Home Page
|
||||
if config.get_setting('start_page'):
|
||||
if item.action not in ['episodios', 'seasons', 'findvideos', 'play']:
|
||||
@@ -780,11 +487,6 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
elif item.contentType == "season":
|
||||
context_commands.append((config.get_localized_string(60357), "XBMC.RunPlugin(%s?%s&%s)" % (sys.argv[0], item_url, 'channel=downloads&action=save_download&download=season&from_channel=' + item.channel + '&from_action=' + item.action)))
|
||||
|
||||
# # Open settings
|
||||
# if parent_item.channel not in ["setting", "news", "search"] and item.action == "play":
|
||||
# context_commands.append((config.get_localized_string(60358), "XBMC.Container.Update(%s?%s)" %
|
||||
# (sys.argv[0], Item(channel="setting", action="mainlist").tourl())))
|
||||
|
||||
# Open settings...
|
||||
if item.action in ["findvideos", 'episodios', 'check', 'new_search'] or "buscar_trailer" in context:
|
||||
context_commands.append((config.get_localized_string(60359), "XBMC.RunPlugin(%s?%s)" % (sys.argv[0], urllib.urlencode({ 'channel': "trailertools", 'action': "buscartrailer", 'search_title': item.contentTitle if item.contentTitle else item.fulltitle, 'contextual': True}))))
|
||||
@@ -792,14 +494,6 @@ def set_context_commands(item, item_url, parent_item, **kwargs):
|
||||
if kwargs.get('superfavourites'):
|
||||
context_commands.append((config.get_localized_string(60361), "XBMC.RunScript(special://home/addons/plugin.program.super.favourites/LaunchSFMenu.py)"))
|
||||
|
||||
# context_commands = sorted(context_commands, key=lambda comand: comand[0])
|
||||
|
||||
# Quick Menu
|
||||
# context_commands.insert(0, (config.get_localized_string(60360),
|
||||
# "XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(channel='side_menu',
|
||||
# action="open_menu",
|
||||
# parent=parent_item.tourl()).tourl(
|
||||
# ))))
|
||||
if config.dev_mode():
|
||||
context_commands.insert(0, ("item info", "XBMC.Container.Update (%s?%s)" % (sys.argv[0], Item(action="itemInfo", parent=item.tojson()).tourl())))
|
||||
return context_commands
|
||||
@@ -812,19 +506,12 @@ def is_playing():
|
||||
def play_video(item, strm=False, force_direct=False, autoplay=False):
|
||||
logger.info()
|
||||
# logger.debug(item.tostring('\n'))
|
||||
logger.debug('item play: %s' % item)
|
||||
xbmc_player = XBMCPlayer()
|
||||
if item.channel == 'downloads':
|
||||
logger.info("Reproducir video local: %s [%s]" % (item.title, item.url))
|
||||
logger.info("Play local video: %s [%s]" % (item.title, item.url))
|
||||
xlistitem = xbmcgui.ListItem(path=item.url)
|
||||
if config.get_platform(True)['num_version'] >= 16.0:
|
||||
xlistitem.setArt({"thumb": item.thumbnail})
|
||||
else:
|
||||
xlistitem.setThumbnailImage(item.thumbnail)
|
||||
|
||||
xlistitem.setArt({"thumb": item.thumbnail})
|
||||
set_infolabels(xlistitem, item, True)
|
||||
set_player(item, xlistitem, item.url, True, None) # Fix Play From Download Section
|
||||
# xbmc_player.play(item.url, xlistitem)
|
||||
return
|
||||
|
||||
default_action = config.get_setting("default_action")
|
||||
@@ -832,13 +519,11 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
|
||||
|
||||
# Open the selection dialog to see the available options
|
||||
opciones, video_urls, seleccion, salir = get_dialogo_opciones(item, default_action, strm, autoplay)
|
||||
if salir:
|
||||
return
|
||||
if salir: return
|
||||
|
||||
# get default option of addon configuration
|
||||
seleccion = get_seleccion(default_action, opciones, seleccion, video_urls)
|
||||
if seleccion < 0: # Canceled box
|
||||
return
|
||||
if seleccion < 0: return # Canceled box
|
||||
|
||||
logger.info("selection=%d" % seleccion)
|
||||
logger.info("selection=%s" % opciones[seleccion])
|
||||
@@ -850,42 +535,25 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
|
||||
|
||||
# we get the selected video
|
||||
mediaurl, view, mpd = get_video_seleccionado(item, seleccion, video_urls)
|
||||
if mediaurl == "":
|
||||
return
|
||||
# # no certificate verification
|
||||
# mediaurl = mediaurl.replace('https://', 'http://')
|
||||
if not mediaurl: return
|
||||
|
||||
# video information is obtained.
|
||||
if not item.contentThumbnail:
|
||||
thumb = item.thumbnail
|
||||
else:
|
||||
thumb = item.contentThumbnail
|
||||
|
||||
xlistitem = xbmcgui.ListItem(path=item.url)
|
||||
if config.get_platform(True)['num_version'] >= 16.0:
|
||||
xlistitem.setArt({"thumb": thumb})
|
||||
else:
|
||||
xlistitem.setThumbnailImage(thumb)
|
||||
|
||||
xlistitem.setArt({"thumb": item.contentThumbnail if item.contentThumbnail else item.thumbnail})
|
||||
set_infolabels(xlistitem, item, True)
|
||||
|
||||
# if it is a video in mpd format, the listitem is configured to play it
|
||||
# with the inpustreamaddon addon implemented in Kodi 17
|
||||
# if it is a video in mpd format, the listitem is configured to play it ith the inpustreamaddon addon implemented in Kodi 17
|
||||
# from core.support import dbg;dbg()
|
||||
if mpd:
|
||||
if not os.path.exists(os.path.join(xbmc.translatePath('special://home/addons/'),'inputstream.adaptive')): install_inputstream()
|
||||
xlistitem.setProperty('inputstreamaddon', 'inputstream.adaptive')
|
||||
xlistitem.setProperty('inputstream.adaptive.manifest_type', 'mpd')
|
||||
|
||||
# player launches
|
||||
if force_direct: # when it comes from a window and not directly from the addon base
|
||||
# We add the listitem to a playlist
|
||||
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
||||
playlist.clear()
|
||||
playlist.add(mediaurl, xlistitem)
|
||||
if force_direct: item.play_from = 'window'
|
||||
|
||||
# Reproduce
|
||||
xbmc_player.play(playlist, xlistitem)
|
||||
else:
|
||||
set_player(item, xlistitem, mediaurl, view, strm)
|
||||
|
||||
item, nfo_path, head_nfo, item_nfo = resume_playback(item)
|
||||
set_player(item, xlistitem, mediaurl, view, strm, nfo_path, head_nfo, item_nfo)
|
||||
|
||||
|
||||
def stop_video():
|
||||
@@ -1196,6 +864,9 @@ def get_video_seleccionado(item, seleccion, video_urls):
|
||||
wait_time = video_urls[seleccion][2]
|
||||
view = True
|
||||
|
||||
if 'mpd' in video_urls[seleccion][0]:
|
||||
mpd = True
|
||||
|
||||
# If there is no mediaurl it is because the video is not there :)
|
||||
logger.info("mediaurl=" + mediaurl)
|
||||
if mediaurl == "":
|
||||
@@ -1213,68 +884,64 @@ def get_video_seleccionado(item, seleccion, video_urls):
|
||||
return mediaurl, view, mpd
|
||||
|
||||
|
||||
def set_player(item, xlistitem, mediaurl, view, strm):
|
||||
def set_player(item, xlistitem, mediaurl, view, strm, nfo_path=None, head_nfo=None, item_nfo=None):
|
||||
logger.info()
|
||||
logger.debug("item:\n" + item.tostring('\n'))
|
||||
# logger.debug("item:\n" + item.tostring('\n'))
|
||||
# Moved del conector "torrent" here
|
||||
if item.server == "torrent":
|
||||
play_torrent(item, xlistitem, mediaurl)
|
||||
return
|
||||
|
||||
# If it is a strm file, play is not necessary
|
||||
elif strm:
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xlistitem)
|
||||
if item.subtitle != "":
|
||||
if item.subtitle:
|
||||
xbmc.sleep(2000)
|
||||
xbmc_player.setSubtitles(item.subtitle)
|
||||
|
||||
else:
|
||||
logger.info("player_mode=%s" % config.get_setting("player_mode"))
|
||||
player_mode = config.get_setting("player_mode")
|
||||
if (player_mode == 3 and mediaurl.startswith("rtmp")) or item.play_from == 'window' or item.nfo: player_mode = 0
|
||||
elif "megacrypter.com" in mediaurl: player_mode = 3
|
||||
logger.info("mediaurl=" + mediaurl)
|
||||
if config.get_setting("player_mode") == 3 or "megacrypter.com" in mediaurl:
|
||||
from platformcode import download_and_play
|
||||
download_and_play.download_and_play(mediaurl, "download_and_play.tmp", config.get_setting("downloadpath"))
|
||||
return
|
||||
|
||||
elif config.get_setting("player_mode") == 0 or item.play_from == 'window' or \
|
||||
(config.get_setting("player_mode") == 3 and mediaurl.startswith("rtmp")):
|
||||
# We add the listitem to a playlist
|
||||
if player_mode == 0:
|
||||
logger.info('Player Mode: Direct')
|
||||
# Add the listitem to a playlist
|
||||
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
||||
playlist.clear()
|
||||
playlist.add(mediaurl, xlistitem)
|
||||
|
||||
# Reproduce
|
||||
# xbmc_player = xbmc_player
|
||||
xbmc_player.play(playlist, xlistitem)
|
||||
if config.get_setting('trakt_sync'):
|
||||
trakt_tools.wait_for_update_trakt()
|
||||
|
||||
# elif config.get_setting("player_mode") == 1 or item.isPlayable:
|
||||
elif config.get_setting("player_mode") == 1:
|
||||
logger.info("Tras setResolvedUrl")
|
||||
# if it is a video library file send to mark as seen
|
||||
|
||||
if strm or item.strm_path:
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.mark_auto_as_watched(item)
|
||||
logger.debug(item)
|
||||
elif player_mode == 1:
|
||||
logger.info('Player Mode: setResolvedUrl')
|
||||
xlistitem.setPath(mediaurl)
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xlistitem)
|
||||
xbmc.sleep(2500)
|
||||
|
||||
elif config.get_setting("player_mode") == 2:
|
||||
elif player_mode == 2:
|
||||
logger.info('Player Mode: Built-In')
|
||||
xbmc.executebuiltin("PlayMedia(" + mediaurl + ")")
|
||||
|
||||
elif player_mode == 3:
|
||||
logger.info('Player Mode: Download and Play')
|
||||
from platformcode import download_and_play
|
||||
download_and_play.download_and_play(mediaurl, "download_and_play.tmp", config.get_setting("downloadpath"))
|
||||
return
|
||||
|
||||
# ALL LOOKING TO REMOVE VIEW
|
||||
if item.subtitle != "" and view:
|
||||
logger.info("Subtítulos externos: " + item.subtitle)
|
||||
if item.subtitle and view:
|
||||
logger.info("External subtitles: " + item.subtitle)
|
||||
xbmc.sleep(2000)
|
||||
xbmc_player.setSubtitles(item.subtitle)
|
||||
|
||||
# if it is a video library file send to mark as seen
|
||||
if strm or item.strm_path:
|
||||
from platformcode import xbmc_videolibrary
|
||||
xbmc_videolibrary.mark_auto_as_watched(item)
|
||||
xbmc_videolibrary.mark_auto_as_watched(item, nfo_path, head_nfo, item_nfo)
|
||||
|
||||
|
||||
def torrent_client_installed(show_tuple=False):
|
||||
@@ -1334,4 +1001,83 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
|
||||
|
||||
def log(texto):
|
||||
xbmc.log(texto, xbmc.LOGNOTICE)
|
||||
xbmc.log(texto, xbmc.LOGNOTICE)
|
||||
|
||||
def resume_playback(item, return_played_time=False):
|
||||
class ResumePlayback(xbmcgui.WindowXMLDialog):
|
||||
Close = False
|
||||
Resume = False
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.action_exitkeys_id = [xbmcgui.ACTION_BACKSPACE, xbmcgui.ACTION_PREVIOUS_MENU, xbmcgui.ACTION_NAV_BACK]
|
||||
self.progress_control = None
|
||||
self.item = kwargs.get('item')
|
||||
m, s = divmod(float(self.item.played_time), 60)
|
||||
h, m = divmod(m, 60)
|
||||
self.setProperty("time", '%02d:%02d:%02d' % (h, m, s))
|
||||
|
||||
def set_values(self, value):
|
||||
self.Resume = value
|
||||
self.Close = True
|
||||
|
||||
def is_close(self):
|
||||
return self.Close
|
||||
|
||||
def onClick(self, controlId):
|
||||
if controlId == 3012: # Resume
|
||||
self.set_values(True)
|
||||
self.close()
|
||||
elif controlId == 3013: # Cancel
|
||||
self.set_values(False)
|
||||
self.close()
|
||||
|
||||
def onAction(self, action):
|
||||
if action in self.action_exitkeys_id:
|
||||
self.set_values(False)
|
||||
self.close()
|
||||
|
||||
|
||||
from core import videolibrarytools, filetools
|
||||
|
||||
# Read NFO FILE
|
||||
if item.contentType == 'movie':
|
||||
nfo_path = item.nfo
|
||||
else:
|
||||
nfo_path = item.strm_path.replace('strm','nfo')
|
||||
|
||||
if filetools.isfile(nfo_path):
|
||||
head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path)
|
||||
|
||||
if return_played_time:
|
||||
return item_nfo.played_time
|
||||
# Show Window
|
||||
elif (config.get_setting("player_mode") not in [3] or item.play_from == 'window') and item_nfo.played_time:
|
||||
Dialog = ResumePlayback('ResumePlayback.xml', config.get_runtime_path(), item=item_nfo)
|
||||
Dialog.show()
|
||||
t = 0
|
||||
while not Dialog.is_close() and t < 100:
|
||||
t += 1
|
||||
xbmc.sleep(100)
|
||||
if not Dialog.Resume: item_nfo.played_time = 0
|
||||
else:
|
||||
item_nfo.played_time = 0
|
||||
|
||||
return item, nfo_path, head_nfo, item_nfo
|
||||
else:
|
||||
item.nfo = item.strm_path = ""
|
||||
return item, None, None, None
|
||||
|
||||
def install_inputstream():
|
||||
from xbmcaddon import Addon
|
||||
try:
|
||||
# See if there's an installed repo that has it
|
||||
xbmc.executebuiltin('InstallAddon(inputstream.adaptive)', wait=True)
|
||||
|
||||
# Check if InputStream add-on exists!
|
||||
Addon('inputstream.adaptive')
|
||||
|
||||
logger.info('InputStream add-on installed from repo.')
|
||||
return True
|
||||
except RuntimeError:
|
||||
logger.info('InputStream add-on not installed.')
|
||||
return False
|
||||
@@ -184,7 +184,7 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
|
||||
# The call is made from a channel
|
||||
self.list_controls, default_values = servertools.get_server_controls_settings(self.channel)
|
||||
self.kwargs = {"server": self.channel}
|
||||
self.channelName = servertools.get_server_json(self.channel)['name']
|
||||
self.channelName = servertools.get_server_parameters(self.channel)['name']
|
||||
|
||||
# Else Exit
|
||||
else:
|
||||
@@ -378,8 +378,8 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
|
||||
textColor=c["color"], font=self.font, isPassword=c["hidden"], window=self)
|
||||
|
||||
else:
|
||||
control = xbmcgui.ControlEdit(0, -100, self.controls_width - 5, self.height_control,
|
||||
c["label"], self.font, c["color"], '', 4, isPassword=c["hidden"],
|
||||
control = xbmcgui.ControlEdit(0, -100, self.controls_width, self.height_control,
|
||||
c["label"], self.font, c["color"], '', 1 | 4, isPassword=c["hidden"],
|
||||
focusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemFO.png'),
|
||||
noFocusTexture=os.path.join(self.mediapath, 'Controls', 'MenuItemNF.png'))
|
||||
|
||||
@@ -393,7 +393,7 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
|
||||
s = ''
|
||||
control.setText(s)
|
||||
# control.setText(self.values[c["id"]])
|
||||
control.setWidth(self.controls_width - 5)
|
||||
control.setWidth(self.controls_width + 10)
|
||||
control.setHeight(self.height_control)
|
||||
|
||||
c["control"] = control
|
||||
@@ -446,8 +446,8 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
|
||||
self.getControl(10006).setLabel(self.custom_button['label'])
|
||||
else:
|
||||
self.getControl(10006).setVisible(False)
|
||||
self.getControl(10004).setPosition(self.getControl(10004).getPosition()[0] + 80, self.getControl(10004).getPosition()[1])
|
||||
self.getControl(10005).setPosition(self.getControl(10005).getPosition()[0] + 80, self.getControl(10005).getPosition()[1])
|
||||
# self.getControl(10004).setPosition(self.getControl(10004).getPosition()[0], self.getControl(10004).getPosition()[1])
|
||||
# self.getControl(10005).setPosition(self.getControl(10005).getPosition()[0], self.getControl(10005).getPosition()[1])
|
||||
|
||||
# Control Area Dimensions
|
||||
self.controls_width = self.getControl(10007).getWidth() - 30
|
||||
@@ -506,7 +506,6 @@ class SettingsWindow(xbmcgui.WindowXMLDialog):
|
||||
elif c["type"] == 'text': self.add_control_text(c)
|
||||
elif c["type"] == 'list': self.add_control_list(c)
|
||||
elif c["type"] == 'label': self.add_control_label(c)
|
||||
|
||||
self.list_controls = [c for c in self.list_controls if "control" in c]
|
||||
|
||||
self.evaluate_conditions()
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
from future import standard_library
|
||||
standard_library.install_aliases()
|
||||
#from builtins import str
|
||||
import sys, os, threading, time, re, math, xbmc
|
||||
import sys, os, threading, time, re, math, xbmc, xbmcgui
|
||||
PY3 = False
|
||||
if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
|
||||
|
||||
@@ -15,73 +15,84 @@ from core import scrapertools
|
||||
from xml.dom import minidom
|
||||
|
||||
|
||||
def mark_auto_as_watched(item):
|
||||
def mark_as_watched_subThread(item):
|
||||
def mark_auto_as_watched(item, nfo_path=None, head_nfo=None, item_nfo=None):
|
||||
def mark_as_watched_subThread(item, nfo_path, head_nfo, item_nfo):
|
||||
logger.info()
|
||||
# logger.debug("item:\n" + item.tostring('\n'))
|
||||
# if nfo and strm_path not exist
|
||||
if not item.nfo:
|
||||
if item.contentType == 'movie':
|
||||
vl = xbmc.translatePath(filetools.join(config.get_setting("videolibrarypath"), config.get_setting("folder_movies")))
|
||||
path = '%s [%s]' % (item.contentTitle, item.infoLabels['IMDBNumber'])
|
||||
item.nfo = filetools.join(vl, path, path + '.nfo')
|
||||
item.strm_path = filetools.join(path, item.contentTitle + '.strm')
|
||||
else:
|
||||
vl = xbmc.translatePath(filetools.join(config.get_setting("videolibrarypath"), config.get_setting("folder_tvshows")))
|
||||
path = '%s [%s]' % (item.contentSerieName, item.infoLabels['IMDBNumber'])
|
||||
item.nfo = filetools.join(vl, path, 'tvshow.nfo')
|
||||
if item.contentSeason and item.contentEpisodeNumber:
|
||||
title = str(item.contentSeason) + 'x' + str(item.contentEpisodeNumber).zfill(2)
|
||||
else:
|
||||
season, episode = scrapertools.find_single_match(item.title, r'(\d+)x(\d+)')
|
||||
title = season + 'x' + episode.zfill(2)
|
||||
item.strm_path = filetools.join(path, title + '.strm')
|
||||
condicion = config.get_setting("watched_setting", "videolibrary")
|
||||
|
||||
time_limit = time.time() + 30
|
||||
while not platformtools.is_playing() and time.time() < time_limit:
|
||||
time.sleep(1)
|
||||
|
||||
sync_with_trakt = False
|
||||
marked = False
|
||||
next_episode = None
|
||||
show_server = True
|
||||
|
||||
percentage = float(config.get_setting("watched_setting")) / 100
|
||||
time_from_end = config.get_setting('next_ep_seconds')
|
||||
if item.contentType != 'movie' and config.get_setting('next_ep'):
|
||||
next_dialogs = ['NextDialog.xml', 'NextDialogExtended.xml', 'NextDialogCompact.xml']
|
||||
next_ep_type = config.get_setting('next_ep_type')
|
||||
ND = next_dialogs[next_ep_type]
|
||||
next_episode = next_ep(item)
|
||||
|
||||
while platformtools.is_playing():
|
||||
tiempo_actual = xbmc.Player().getTime()
|
||||
totaltime = xbmc.Player().getTotalTime()
|
||||
actual_time = xbmc.Player().getTime()
|
||||
total_time = xbmc.Player().getTotalTime()
|
||||
if item_nfo.played_time and item_nfo.played_time > actual_time > 1:
|
||||
xbmc.Player().seekTime(item_nfo.played_time)
|
||||
item_nfo.played_time = 0 # Fix for Slow Devices
|
||||
|
||||
mark_time = 0
|
||||
if condicion == 0: # '5 minutos'
|
||||
mark_time = 300
|
||||
elif condicion == 1: # '30%'
|
||||
mark_time = totaltime * 0.3
|
||||
elif condicion == 2: # '50%'
|
||||
mark_time = totaltime * 0.5
|
||||
elif condicion == 3: # '80%'
|
||||
mark_time = totaltime * 0.8
|
||||
elif condicion == 4: # '0 seg'
|
||||
mark_time = -1
|
||||
mark_time = total_time * percentage
|
||||
difference = total_time - actual_time
|
||||
|
||||
# logger.debug(str(tiempo_actual))
|
||||
# logger.debug(str(mark_time))
|
||||
|
||||
if tiempo_actual > mark_time:
|
||||
# Mark as Watched
|
||||
if actual_time > mark_time and not marked:
|
||||
logger.debug("Marked as Watched")
|
||||
item.playcount = 1
|
||||
sync_with_trakt = True
|
||||
marked = True
|
||||
show_server = False
|
||||
from specials import videolibrary
|
||||
videolibrary.mark_content_as_watched2(item)
|
||||
break
|
||||
if not next_episode:
|
||||
break
|
||||
|
||||
time.sleep(5)
|
||||
# check for next Episode
|
||||
if next_episode and marked and time_from_end >= difference:
|
||||
nextdialog = NextDialog(ND, config.get_runtime_path())
|
||||
nextdialog.show()
|
||||
while platformtools.is_playing() and not nextdialog.is_exit():
|
||||
xbmc.sleep(100)
|
||||
if nextdialog.continuewatching:
|
||||
next_episode.next_ep = True
|
||||
xbmc.Player().stop()
|
||||
nextdialog.close()
|
||||
break
|
||||
xbmc.sleep(1000)
|
||||
|
||||
# Set played time
|
||||
item_nfo.played_time = int(actual_time) if not marked and actual_time > 120 else 0
|
||||
filetools.write(nfo_path, head_nfo + item_nfo.tojson())
|
||||
|
||||
# Silent sync with Trakt
|
||||
if sync_with_trakt and config.get_setting("trakt_sync"):
|
||||
sync_trakt_kodi()
|
||||
if marked and config.get_setting("trakt_sync"): sync_trakt_kodi()
|
||||
|
||||
# logger.debug("Fin del hilo")
|
||||
while platformtools.is_playing():
|
||||
xbmc.sleep(100)
|
||||
if not show_server and item.play_from != 'window':
|
||||
xbmc.sleep(700)
|
||||
xbmc.executebuiltin('Action(Back)')
|
||||
xbmc.sleep(500)
|
||||
if next_episode and next_episode.next_ep:
|
||||
from platformcode.launcher import play_from_library
|
||||
return play_from_library(next_episode)
|
||||
|
||||
# If it is configured to mark as seen
|
||||
if config.get_setting("mark_as_watched", "videolibrary"):
|
||||
threading.Thread(target=mark_as_watched_subThread, args=[item]).start()
|
||||
threading.Thread(target=mark_as_watched_subThread, args=[item, nfo_path, head_nfo, item_nfo]).start()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
def sync_trakt_addon(path_folder):
|
||||
@@ -110,7 +121,7 @@ def sync_trakt_addon(path_folder):
|
||||
shows = list(shows.items())
|
||||
|
||||
# we get the series id to compare
|
||||
_id = re.findall("\[(.*?)\]", path_folder, flags=re.DOTALL)[0]
|
||||
_id = re.findall(r"\[(.*?)\]", path_folder, flags=re.DOTALL)[0]
|
||||
logger.debug("the id is %s" % _id)
|
||||
|
||||
if "tt" in _id:
|
||||
@@ -152,7 +163,7 @@ def sync_trakt_addon(path_folder):
|
||||
logger.debug("dict_trakt_show %s " % dict_trakt_show)
|
||||
|
||||
# we get the keys that are episodes
|
||||
regex_epi = re.compile('\d+x\d+')
|
||||
regex_epi = re.compile(r'\d+x\d+')
|
||||
keys_episodes = [key for key in serie.library_playcounts if regex_epi.match(key)]
|
||||
# we get the keys that are seasons
|
||||
keys_seasons = [key for key in serie.library_playcounts if 'season ' in key]
|
||||
@@ -210,14 +221,14 @@ def sync_trakt_kodi(silent=True):
|
||||
# So that the synchronization is not silent it is worth with silent = False
|
||||
if xbmc.getCondVisibility('System.HasAddon("script.trakt")'):
|
||||
notificacion = True
|
||||
if (not config.get_setting("sync_trakt_notification", "videolibrary") and platformtools.is_playing()):
|
||||
if not config.get_setting("sync_trakt_notification", "videolibrary") and platformtools.is_playing():
|
||||
notificacion = False
|
||||
|
||||
xbmc.executebuiltin('RunScript(script.trakt,action=sync,silent=%s)' % silent)
|
||||
logger.info("Synchronization with Trakt started")
|
||||
|
||||
if notificacion:
|
||||
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60045), time=2000)
|
||||
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(60045), sound=False, time=2000)
|
||||
|
||||
|
||||
def mark_content_as_watched_on_kodi(item, value=1):
|
||||
@@ -276,7 +287,6 @@ def mark_content_as_watched_on_kodi(item, value=1):
|
||||
path = filetools.join(tail, filename)
|
||||
|
||||
for d in data['result']['episodes']:
|
||||
|
||||
if d['file'].replace("/", "\\").endswith(path.replace("/", "\\")):
|
||||
# logger.debug("I mark the episode as seen")
|
||||
episodeid = d['episodeid']
|
||||
@@ -376,7 +386,7 @@ def mark_content_as_watched_on_kod(path):
|
||||
path1 = path.replace("\\\\", "\\") # Windows format
|
||||
if not path2:
|
||||
path2 = path1.replace("\\", "/") # Format no Windows
|
||||
nfo_name = scrapertools.find_single_match(path2, '\]\/(.*?)$') # I build the name of the .nfo
|
||||
nfo_name = scrapertools.find_single_match(path2, r'\]\/(.*?)$') # I build the name of the .nfo
|
||||
path1 = path1.replace(nfo_name, '') # for SQL I just need the folder
|
||||
path2 = path2.replace(nfo_name, '') # for SQL I just need the folder
|
||||
path2 = filetools.remove_smb_credential(path2) # If the file is on an SMB server, we remove the credentials
|
||||
@@ -394,7 +404,7 @@ def mark_content_as_watched_on_kod(path):
|
||||
if contentType == "episode_view":
|
||||
title_plain = title.replace('.strm', '') # If it is Serial, we remove the suffix .strm
|
||||
else:
|
||||
title_plain = scrapertools.find_single_match(item.strm_path, '.(.*?\s\[.*?\])') # if it's a movie, we remove the title
|
||||
title_plain = scrapertools.find_single_match(item.strm_path, r'.(.*?\s\[.*?\])') # if it's a movie, we remove the title
|
||||
if playCount is None or playCount == 0: # not yet seen, we set it to 0
|
||||
playCount_final = 0
|
||||
elif playCount >= 1:
|
||||
@@ -409,7 +419,7 @@ def mark_content_as_watched_on_kod(path):
|
||||
if item.infoLabels['mediatype'] == "tvshow": # We update the Season and Series playCounts
|
||||
for season in item.library_playcounts:
|
||||
if "season" in season: # we look for the tags "season" inside playCounts
|
||||
season_num = int(scrapertools.find_single_match(season, 'season (\d+)')) # we save the season number
|
||||
season_num = int(scrapertools.find_single_match(season, r'season (\d+)')) # we save the season number
|
||||
item = videolibrary.check_season_playcount(item, season_num) # We call the method that updates Temps. and series
|
||||
|
||||
filetools.write(path, head_nfo + item.tojson())
|
||||
@@ -497,7 +507,7 @@ def update(folder_content=config.get_setting("folder_tvshows"), folder=""):
|
||||
# update_path = filetools.join(videolibrarypath, folder_content, folder) + "/" # Encoder problems in "folder"
|
||||
update_path = filetools.join(videolibrarypath, folder_content, ' ').rstrip()
|
||||
|
||||
if videolibrarypath.startswith("special:") or not scrapertools.find_single_match(update_path, '(^\w+:\/\/)'):
|
||||
if videolibrarypath.startswith("special:") or not scrapertools.find_single_match(update_path, r'(^\w+:\/\/)'):
|
||||
payload["params"] = {"directory": update_path}
|
||||
|
||||
while xbmc.getCondVisibility('Library.IsScanningVideo()'):
|
||||
@@ -539,7 +549,7 @@ def set_content(content_type, silent=False, custom=False):
|
||||
if not xbmc.getCondVisibility('System.HasAddon(metadata.themoviedb.org)'):
|
||||
if not silent:
|
||||
# Ask if we want to install metadata.themoviedb.org
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60046))
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60046),'')
|
||||
else:
|
||||
install = True
|
||||
|
||||
@@ -563,7 +573,7 @@ def set_content(content_type, silent=False, custom=False):
|
||||
continuar = False
|
||||
if not silent:
|
||||
# Ask if we want to install metadata.universal
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(70095))
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(70095),'')
|
||||
else:
|
||||
install = True
|
||||
|
||||
@@ -593,7 +603,7 @@ def set_content(content_type, silent=False, custom=False):
|
||||
if not xbmc.getCondVisibility('System.HasAddon(metadata.tvdb.com)'):
|
||||
if not silent:
|
||||
#Ask if we want to install metadata.tvdb.com
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60048))
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60048),'')
|
||||
else:
|
||||
install = True
|
||||
|
||||
@@ -617,7 +627,7 @@ def set_content(content_type, silent=False, custom=False):
|
||||
continuar = False
|
||||
if not silent:
|
||||
# Ask if we want to install metadata.tvshows.themoviedb.org
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60050))
|
||||
install = platformtools.dialog_yesno(config.get_localized_string(60050),'')
|
||||
else:
|
||||
install = True
|
||||
|
||||
@@ -651,7 +661,7 @@ def set_content(content_type, silent=False, custom=False):
|
||||
if sql_videolibrarypath.startswith("special://"):
|
||||
sql_videolibrarypath = sql_videolibrarypath.replace('/profile/', '/%/').replace('/home/userdata/', '/%/')
|
||||
sep = '/'
|
||||
elif scrapertools.find_single_match(sql_videolibrarypath, '(^\w+:\/\/)'):
|
||||
elif scrapertools.find_single_match(sql_videolibrarypath, r'(^\w+:\/\/)'):
|
||||
sep = '/'
|
||||
else:
|
||||
sep = os.sep
|
||||
@@ -1228,4 +1238,110 @@ def ask_set_content(silent=False):
|
||||
# configuration from the settings menu
|
||||
else:
|
||||
platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(80023))
|
||||
do_config(True)
|
||||
do_config(True)
|
||||
|
||||
|
||||
def next_ep(item):
|
||||
from core.item import Item
|
||||
logger.info()
|
||||
item.next_ep = False
|
||||
|
||||
# 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]
|
||||
logger.info('Next File:' + str(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),
|
||||
play_from = item.play_from)
|
||||
|
||||
global INFO
|
||||
INFO = filetools.join(path, next_file.replace("strm", "nfo"))
|
||||
else:
|
||||
item=None
|
||||
|
||||
return item
|
||||
|
||||
|
||||
class NextDialog(xbmcgui.WindowXMLDialog):
|
||||
item = None
|
||||
cancel = False
|
||||
EXIT = False
|
||||
continuewatching = True
|
||||
|
||||
def __init__(self, *args, **kwargs):
|
||||
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)
|
||||
if "thumbnail" in info:
|
||||
img = info["thumbnail"]
|
||||
else:
|
||||
img = filetools.join(config.get_runtime_path(), "resources", "noimage.png")
|
||||
self.setProperty("next_img", img)
|
||||
info = info["infoLabels"]
|
||||
self.setProperty("title", info["tvshowtitle"])
|
||||
self.setProperty("ep_title", "%dx%02d - %s" % (info["season"], info["episode"], info["title"]))
|
||||
|
||||
def set_exit(self, EXIT):
|
||||
self.EXIT = EXIT
|
||||
|
||||
def set_continue_watching(self, continuewatching):
|
||||
self.continuewatching = continuewatching
|
||||
|
||||
def is_exit(self):
|
||||
return self.EXIT
|
||||
|
||||
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_exit(True)
|
||||
self.set_continue_watching(True)
|
||||
self.close()
|
||||
elif controlId == 3013: # Cancel
|
||||
self.set_exit(True)
|
||||
self.set_continue_watching(False)
|
||||
self.close()
|
||||
|
||||
def onAction(self, action):
|
||||
if action in self.action_exitkeys_id:
|
||||
self.set_exit(True)
|
||||
self.set_continue_watching(False)
|
||||
self.close()
|
||||
Reference in New Issue
Block a user