Merge branch 'master' of github.com:kodiondemand/addon

This commit is contained in:
marco
2020-01-10 21:17:40 +01:00
5 changed files with 109 additions and 93 deletions
+1
View File
@@ -1,6 +1,7 @@
# Kodi On Demand # Kodi On Demand
### Un fork italiano di [Alfa](https://github.com/alfa-addon) ### Un fork italiano di [Alfa](https://github.com/alfa-addon)
Ognuno è libero (anzi, invitato!) a collaborare, per farlo è possibile utilizzare i pull request. Ognuno è libero (anzi, invitato!) a collaborare, per farlo è possibile utilizzare i pull request.
KOD funziona con Kodi fino alla versione 18 (Python 2).
KOD, come Alfa, è sotto licenza GPL v3, pertanto siete liberi di utilizzare parte del codice, a patto di rispettare i termini di suddetta licenza, che si possono riassumere in: KOD, come Alfa, è sotto licenza GPL v3, pertanto siete liberi di utilizzare parte del codice, a patto di rispettare i termini di suddetta licenza, che si possono riassumere in:
+9 -2
View File
@@ -469,13 +469,16 @@ def play_from_library(item):
xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")") xbmc.executebuiltin("Container.Update(" + sys.argv[0] + "?" + item.tourl() + ")")
else: else:
# Ventana emergente # Ventana emergente
item.play_from = 'window'
from specials import videolibrary from specials import videolibrary
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(70004)) p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(20000), config.get_localized_string(70004))
p_dialog.update(0, '') p_dialog.update(0, '')
itemlist = videolibrary.findvideos(item) itemlist = videolibrary.findvideos(item)
while platformtools.is_playing(): while platformtools.is_playing():
# Ventana convencional # Ventana convencional
sleep(5) sleep(5)
@@ -518,17 +521,21 @@ def play_from_library(item):
else: else:
cabecera = config.get_localized_string(30163) cabecera = config.get_localized_string(30163)
if (not config.get_setting('autoplay') and not config.get_setting('hide_servers')) or item.no_window: SHOW = True
if config.get_setting('autoplay') and config.get_setting('hide_servers'):
SHOW = False
if SHOW:
seleccion = platformtools.dialog_select(cabecera, opciones) seleccion = platformtools.dialog_select(cabecera, opciones)
if seleccion == -1: if seleccion == -1:
return return
else: else:
item = videolibrary.play(itemlist[seleccion])[0] item = videolibrary.play(itemlist[seleccion])[0]
item.play_from = 'window'
platformtools.play_video(item) platformtools.play_video(item)
from specials import autoplay from specials import autoplay
if (platformtools.is_playing() and item.action) or item.server == 'torrent' or autoplay.is_active(item.contentChannel): if (platformtools.is_playing() and item.action) or item.server == 'torrent' or autoplay.is_active(item.contentChannel):
break break
+7 -10
View File
@@ -12,7 +12,7 @@ import os
import sys import sys
import urllib import urllib
import config # import config
import xbmc import xbmc
import xbmcaddon import xbmcaddon
import xbmcgui import xbmcgui
@@ -22,7 +22,7 @@ from channelselector import get_thumb
from core import channeltools from core import channeltools
from core import trakt_tools, scrapertools from core import trakt_tools, scrapertools
from core.item import Item from core.item import Item
from platformcode import logger, keymaptools from platformcode import logger, keymaptools, config
from platformcode import unify from platformcode import unify
addon = xbmcaddon.Addon('plugin.video.kod') addon = xbmcaddon.Addon('plugin.video.kod')
@@ -683,8 +683,8 @@ def is_playing():
def play_video(item, strm=False, force_direct=False, autoplay=False): def play_video(item, strm=False, force_direct=False, autoplay=False):
logger.info() logger.info()
if item.play_from == 'window': # if item.play_from == 'window':
force_direct=True # force_direct=True
# logger.debug(item.tostring('\n')) # logger.debug(item.tostring('\n'))
logger.debug('item play: %s'%item) logger.debug('item play: %s'%item)
xbmc_player = XBMCPlayer() xbmc_player = XBMCPlayer()
@@ -758,9 +758,6 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
# Reproduce # Reproduce
xbmc_player.play(playlist, xlistitem) xbmc_player.play(playlist, xlistitem)
if not item.launcher and (strm or item.strm_path) and config.get_setting('next_ep') > 0 and item.contentType != 'movie':
from specials.nextep import afther_stop
afther_stop(item)
else: else:
set_player(item, xlistitem, mediaurl, view, strm) set_player(item, xlistitem, mediaurl, view, strm)
@@ -1082,7 +1079,7 @@ def get_video_seleccionado(item, seleccion, video_urls):
def set_player(item, xlistitem, mediaurl, view, strm): def set_player(item, xlistitem, mediaurl, view, strm):
logger.info() logger.info()
logger.debug("item:\n" + item.tostring('\n')) # logger.debug("item:\n" + item.tostring('\n'))
# Movido del conector "torrent" aqui # Movido del conector "torrent" aqui
if item.server == "torrent": if item.server == "torrent":
@@ -1104,7 +1101,7 @@ def set_player(item, xlistitem, mediaurl, view, strm):
download_and_play.download_and_play(mediaurl, "download_and_play.mp4", config.get_setting("downloadpath")) download_and_play.download_and_play(mediaurl, "download_and_play.mp4", config.get_setting("downloadpath"))
return return
elif config.get_setting("player_mode") == 0 or\ elif config.get_setting("player_mode") == 0 or item.play_from == 'window' or\
(config.get_setting("player_mode") == 3 and mediaurl.startswith("rtmp")): (config.get_setting("player_mode") == 3 and mediaurl.startswith("rtmp")):
# Añadimos el listitem a una lista de reproducción (playlist) # Añadimos el listitem a una lista de reproducción (playlist)
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO) playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
@@ -1143,7 +1140,7 @@ def set_player(item, xlistitem, mediaurl, view, strm):
from platformcode import xbmc_videolibrary from platformcode import xbmc_videolibrary
xbmc_videolibrary.mark_auto_as_watched(item) xbmc_videolibrary.mark_auto_as_watched(item)
if not item.launcher and (strm or item.strm_path) and config.get_setting('next_ep') > 0 and item.contentType != 'movie': if (strm or item.strm_path) and config.get_setting('next_ep') > 0 and item.contentType != 'movie' and item.play_from != 'window':
from specials.nextep import afther_stop from specials.nextep import afther_stop
afther_stop(item) afther_stop(item)
+91 -81
View File
@@ -4,107 +4,117 @@ from platformcode import config, platformtools, logger
from time import time, sleep from time import time, sleep
from core import scrapertools from core import scrapertools
from core import jsontools, filetools from core import jsontools, filetools
import threading
normal_window = True if config.get_setting("window_type", "videolibrary") == 0 else False
def afther_stop(item): def afther_stop(item):
logger.info() logger.info('AS ITEM\n'+str(item))
condition = config.get_setting('next_ep') def next_ep(item):
# from core.support import dbg; dbg() logger.info()
condition = config.get_setting('next_ep')
if condition == 1: # Hide servers afther stop video
while not platformtools.is_playing():
pass
while platformtools.is_playing():
pass
sleep(0.5)
xbmc.executebuiltin('Action(Back)')
elif condition == 2: # Bring servers afther stop video
from platformcode.launcher import play_from_library
# Check if next episode exist
current_filename = os.path.basename(item.strm_path)
base_path = os.path.basename(os.path.normpath(os.path.dirname(item.strm_path)))
logger.info('PATH:' + base_path)
path = filetools.join(config.get_videolibrary_path(), config.get_setting("folder_tvshows"),base_path)
logger.info('PATH:' + path)
fileList = []
for file in os.listdir(path):
if file.endswith('.strm'):
fileList.append(file)
# from core.support import dbg; dbg() # from core.support import dbg; dbg()
nextIndex = fileList.index(current_filename) + 1
if nextIndex == 0 or nextIndex == len(fileList):
next_file = None
else:
next_file = fileList[nextIndex]
# start next episode window afther x time if condition == 1: # Hide servers afther stop video
if next_file: while not platformtools.is_playing():
play_next = False pass
time_limit = time() + 30 while platformtools.is_playing():
time_steps = [20,30,40,50,60] pass
TimeFromEnd = time_steps[config.get_setting('next_ep_seconds')] sleep(0.5)
logger.info('TEMPO: '+str(TimeFromEnd)) xbmc.executebuiltin('Action(Back)')
while not platformtools.is_playing() and time() < time_limit:
elif condition == 2: # Bring servers afther stop video
from platformcode.launcher import play_from_library
# Check if next episode exist
current_filename = os.path.basename(item.strm_path)
base_path = os.path.basename(os.path.normpath(os.path.dirname(item.strm_path)))
logger.info('PATH:' + base_path)
path = filetools.join(config.get_videolibrary_path(), config.get_setting("folder_tvshows"),base_path)
logger.info('PATH:' + path)
fileList = []
for file in os.listdir(path):
if file.endswith('.strm'):
fileList.append(file)
# from core.support import dbg; dbg()
nextIndex = fileList.index(current_filename) + 1
if nextIndex == 0 or nextIndex == len(fileList):
next_file = None
else:
next_file = fileList[nextIndex]
# start next episode window afther x time
if next_file:
play_next = False
time_limit = time() + 30
time_steps = [20,30,40,50,60]
TimeFromEnd = time_steps[config.get_setting('next_ep_seconds')]
logger.info('TEMPO: '+str(TimeFromEnd))
while not platformtools.is_playing() and time() < time_limit:
sleep(1)
sleep(1) sleep(1)
sleep(1) while platformtools.is_playing() and play_next == False:
try:
Total = xbmc.Player().getTotalTime()
Actual = xbmc.Player().getTime()
Difference = Total - Actual
if Total > TimeFromEnd >= Difference:
play_next = True
except:
break
while platformtools.is_playing() and play_next == False:
try:
Total = xbmc.Player().getTotalTime()
Actual = xbmc.Player().getTime()
Difference = Total - Actual
if Total > TimeFromEnd >= Difference:
play_next = True
except:
break
# from core.support import dbg; dbg()
if play_next:
play_next = False
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.contentSeason = item.infoLabels['season'] = season
item.contentEpisodeNumber = item.infoLabels['episode'] = episode
item.contentTitle = item.infoLabels['title'] = next_ep
item.strm_path = filetools.join(base_path, next_file)
# from core.support import dbg; dbg() # from core.support import dbg; dbg()
if play_next:
from core.item import Item
play_next = False
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= 'tvshow',
infoLabels= {'episode': episode, 'mediatype': 'tvshow', 'season': season, 'title': next_ep},
strm_path= filetools.join(base_path, next_file))
# item.contentSeason = item.infoLabels['season'] = season
# item.contentEpisodeNumber = item.infoLabels['episode'] = episode
# item.contentTitle = item.infoLabels['title'] = next_ep
# item.strm_path = filetools.join(base_path, next_file)
# logger.info('ITEM SUBMITTED:\n'+str(item))
global ITEM global ITEM
ITEM = item ITEM = item
nextDialog = NextDialog('NextDialog.xml', config.get_runtime_path()) nextDialog = NextDialog('NextDialog.xml', config.get_runtime_path())
nextDialog.show() nextDialog.show()
while platformtools.is_playing() and not nextDialog.is_still_watching(): while platformtools.is_playing() and not nextDialog.is_still_watching():
xbmc.sleep(100) xbmc.sleep(100)
pass pass
nextDialog.close() nextDialog.close()
logger.info('CONTINUA: ' +str(nextDialog.stillwatching)) logger.info('CONTINUA: ' +str(nextDialog.stillwatching))
if nextDialog.stillwatching or nextDialog.continuewatching: if nextDialog.stillwatching or nextDialog.continuewatching:
xbmc.Player().stop() xbmc.Player().stop()
if normal_window:
sleep(1) sleep(1)
logger.info('BACK STILL') logger.info('BACK STILL')
xbmc.executebuiltin('Action(Back)') xbmc.executebuiltin('Action(Back)')
sleep(0.5)
return play_from_library(item)
else: else:
item.no_window = True
sleep(0.5)
play_from_library(item)
else:
if normal_window:
sleep(1) sleep(1)
logger.info('BACK NOT STILL') logger.info('BACK NOT STILL')
xbmc.executebuiltin('Action(Back)') xbmc.executebuiltin('Action(Back)')
else:
item.no_window = True
else:
return None
thread = threading.Thread(target = next_ep, args = [item])
thread.start()
import xbmcgui import xbmcgui
+1
View File
@@ -558,6 +558,7 @@ def findvideos(item):
server.channel = "videolibrary" server.channel = "videolibrary"
server.nfo = item.nfo server.nfo = item.nfo
server.strm_path = item.strm_path server.strm_path = item.strm_path
server.play_from = item.play_from
#### Compatibilidad con Kodi 18: evita que se quede la ruedecedita dando vueltas en enlaces Directos #### Compatibilidad con Kodi 18: evita que se quede la ruedecedita dando vueltas en enlaces Directos
if server.action == 'play': if server.action == 'play':