Fix Riproduzione e Download Torrent
This commit is contained in:
@@ -13,7 +13,7 @@ if sys.version_info[0] >= 3:PY3 = True; unicode = str; unichr = chr; long = int
|
||||
|
||||
from core.item import Item
|
||||
from core import filetools, jsontools
|
||||
from platformcode import config, logger, platformtools
|
||||
from platformcode import config, logger, platformtools, xbmc_videolibrary
|
||||
from platformcode.logger import WebErrorException
|
||||
temp_search_file = config.get_temp_file('temp-search')
|
||||
|
||||
@@ -261,7 +261,6 @@ def run(item=None):
|
||||
|
||||
# Special action for searching, first asks for the words then call the "search" function
|
||||
elif item.action == "search":
|
||||
# from core.support import dbg;dbg()
|
||||
if filetools.isfile(temp_search_file) and config.get_setting('videolibrary_kodi'):
|
||||
itemlist = []
|
||||
f = filetools.read(temp_search_file)
|
||||
@@ -445,21 +444,39 @@ def play_from_library(item):
|
||||
"""
|
||||
|
||||
def get_played_time(item):
|
||||
if item.contentType == 'movie': nfo_path = item.nfo
|
||||
else: nfo_path = item.strm_path.replace('strm','nfo')
|
||||
from core import videolibrarytools
|
||||
|
||||
if item.contentType == 'movie':
|
||||
nfo_path = item.nfo
|
||||
if nfo_path.startswith('\\') or nfo_path.startswith('/'):
|
||||
nfo_path = filetools.join(videolibrarytools.MOVIES_PATH, nfo_path)
|
||||
|
||||
else:
|
||||
nfo_path =item.strm_path.replace('strm','nfo')
|
||||
if nfo_path.startswith('\\') or nfo_path.startswith('/'):
|
||||
nfo_path = filetools.join(videolibrarytools.TVSHOWS_PATH, nfo_path)
|
||||
|
||||
if nfo_path and filetools.isfile(nfo_path):
|
||||
from core import videolibrarytools
|
||||
head_nfo, item_nfo = videolibrarytools.read_nfo(nfo_path)
|
||||
sleep(1)
|
||||
played_time = platformtools.get_played_time(item_nfo)
|
||||
|
||||
else: played_time = 0
|
||||
|
||||
return played_time
|
||||
|
||||
import xbmcgui, xbmcplugin, xbmc
|
||||
from time import sleep
|
||||
|
||||
# logger.debug("item: \n" + item.tostring('\n'))
|
||||
platformtools.prevent_busy(item)
|
||||
# xbmc.Player().play(os.path.join(config.get_runtime_path(), "resources", "kod.mp4"))
|
||||
if not item.autoplay:
|
||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4")))
|
||||
while not platformtools.is_playing():
|
||||
xbmc.sleep(10)
|
||||
xbmc.Player().stop()
|
||||
platformtools.prevent_busy()
|
||||
|
||||
|
||||
itemlist=[]
|
||||
item.fromLibrary = True
|
||||
@@ -469,7 +486,9 @@ def play_from_library(item):
|
||||
# Modify the action (currently the video library needs "findvideos" since this is where the sources are searched
|
||||
item.action = item.next_action if item.next_action else "findvideos"
|
||||
|
||||
window_type = config.get_setting("window_type", "videolibrary") if config.get_setting('next_ep') < 3 and item.contentType != 'movie' else 1
|
||||
if item.contentType == 'movie' or item.contentType != 'movie' and config.get_setting('next_ep') < 3:
|
||||
window_type = config.get_setting("window_type", "videolibrary")
|
||||
else: window_type = 1
|
||||
|
||||
# and launch kodi again
|
||||
if (xbmc.getCondVisibility('Window.IsMedia') and not window_type == 1) or item.action != 'findvideos':
|
||||
@@ -490,10 +509,10 @@ def play_from_library(item):
|
||||
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)
|
||||
# from core.support import dbg;dbg()
|
||||
|
||||
if len(itemlist) > 0:
|
||||
reopen = False
|
||||
# from core.support import dbg;dbg()
|
||||
|
||||
while not xbmc.Monitor().abortRequested():
|
||||
played = True
|
||||
# if config.get_setting('next_ep') == 3 and xbmc.Player().playnext:
|
||||
@@ -531,7 +550,7 @@ def play_from_library(item):
|
||||
if selection == -1:
|
||||
return
|
||||
else:
|
||||
item = videolibrary.play(itemlist[selection + selection_implementation])[0]
|
||||
item = videolibrary.play(itemlist[selection + selection_implementation])[0]
|
||||
platformtools.play_video(item)
|
||||
reopen = True
|
||||
# if (platformtools.is_playing() and item.action) or item.server == 'torrent' or config.get_setting('autoplay'): break
|
||||
|
||||
@@ -396,9 +396,11 @@ def viewmodeMonitor():
|
||||
win = xbmcgui.Window(xbmcgui.getCurrentWindowId())
|
||||
currentMode = int(win.getFocusId())
|
||||
# logger.debug('CM', currentMode, 'CN',currentModeName, 'label',xbmc.getInfoLabel('Container.FolderPath'))
|
||||
if currentModeName and 'plugin.video.kod' in xbmc.getInfoLabel('Container.FolderPath') and 50 <= currentMode < 1000:# and currentMode >= 50: # inside addon and in itemlist view
|
||||
content, Type = getCurrentView()
|
||||
# logger.debug(content, Type)
|
||||
# if not parent_info:
|
||||
|
||||
if currentModeName and 'plugin.video.kod' in parent_info and 50 <= currentMode < 1000:# and currentMode >= 50: # inside addon and in itemlist view
|
||||
# logger.debug('CAMBIO VISUALE')
|
||||
content, Type = getCurrentView(Item().fromurl(item_info) if item_info else Item(), Item().fromurl(parent_info))
|
||||
if content:
|
||||
defaultMode = int(config.get_setting('view_mode_%s' % content).split(',')[-1])
|
||||
if currentMode != defaultMode:
|
||||
@@ -414,16 +416,20 @@ def viewmodeMonitor():
|
||||
|
||||
def getCurrentView(item=None, parent_item=None):
|
||||
if not parent_item:
|
||||
info = xbmc.getInfoLabel('Container.FolderPath')
|
||||
if not info:
|
||||
return None, None
|
||||
parent_item = Item().fromurl(info)
|
||||
if not item:
|
||||
info = xbmc.getInfoLabel('Container.ListItemPosition(2).FileNameAndPath') # first addon listitem (consider "..")
|
||||
if not info:
|
||||
item = Item()
|
||||
else:
|
||||
item = Item().fromurl(info) if info else Item()
|
||||
logger.debug('ESCO')
|
||||
return None, None
|
||||
|
||||
# if not parent_item:
|
||||
# info = xbmc.getInfoLabel('Container.FolderPath')
|
||||
# if not info:
|
||||
# return None, None
|
||||
# parent_item = Item().fromurl(info)
|
||||
# if not item:
|
||||
# info = xbmc.getInfoLabel('Container.ListItemPosition(2).FileNameAndPath') # first addon listitem (consider "..")
|
||||
# if not info:
|
||||
# item = Item()
|
||||
# else:
|
||||
# item = Item().fromurl(info) if info else Item()
|
||||
parent_actions = ['peliculas', 'novedades', 'search', 'get_from_temp', 'newest', 'discover_list', 'new_search', 'channel_search']
|
||||
|
||||
addons = 'addons' if config.get_setting('touch_view') else ''
|
||||
@@ -984,7 +990,6 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
|
||||
set_infolabels(xlistitem, item, True)
|
||||
|
||||
# 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 or item.manifest =='mpd':
|
||||
if not install_inputstream():
|
||||
return
|
||||
@@ -1370,7 +1375,7 @@ def set_player(item, xlistitem, mediaurl, view, strm):
|
||||
logger.info("mediaurl=" + mediaurl)
|
||||
|
||||
if player_mode in [0,1]:
|
||||
prevent_busy(item)
|
||||
prevent_busy()
|
||||
if player_mode in [1]:
|
||||
item.played_time = resume_playback(get_played_time(item))
|
||||
|
||||
@@ -1461,7 +1466,6 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
from servers import torrent
|
||||
|
||||
torrent_options = torrent_client_installed(show_tuple=True)
|
||||
# from core.support import dbg;dbg()
|
||||
if len(torrent_options) == 0:
|
||||
from platformcode import elementum_download
|
||||
install = elementum_download.download()
|
||||
@@ -1475,9 +1479,7 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
selection = 0
|
||||
|
||||
if selection >= 0:
|
||||
xbmc.Player().play(os.path.join(config.get_runtime_path(), "resources", "kod.mp4"))
|
||||
xbmc.sleep(200)
|
||||
xbmc.Player().stop()
|
||||
prevent_busy()
|
||||
|
||||
mediaurl = urllib.quote_plus(item.url)
|
||||
torr_client = torrent_options[selection][0]
|
||||
@@ -1491,9 +1493,14 @@ def play_torrent(item, xlistitem, mediaurl):
|
||||
if torr_client in ['elementum'] and item.downloadFilename:
|
||||
torrent.elementum_download(item)
|
||||
else:
|
||||
time.sleep(3)
|
||||
# xbmc.Player().play(torrent_options[selection][1] % mediaurl)
|
||||
xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")")
|
||||
if item.fromLibrary and item.play_from == 'window':
|
||||
xlistitem.setPath(torrent_options[selection][1] % mediaurl)
|
||||
playlist = xbmc.PlayList(xbmc.PLAYLIST_VIDEO)
|
||||
playlist.clear()
|
||||
playlist.add(torrent_options[selection][1] % mediaurl, xlistitem)
|
||||
xbmc_player.play(playlist, xlistitem)
|
||||
else:
|
||||
xbmc.executebuiltin("PlayMedia(" + torrent_options[selection][1] % mediaurl + ")")
|
||||
|
||||
# torrent.mark_auto_as_watched(item)
|
||||
|
||||
@@ -1802,11 +1809,5 @@ def set_played_time(item):
|
||||
del db['viewed'][ID]
|
||||
|
||||
|
||||
|
||||
def prevent_busy(item):
|
||||
logger.debug()
|
||||
if item.action == 'play_from_library' or (not item.autoplay and not item.window):
|
||||
if item.globalsearch: xbmc.Player().play(os.path.join(config.get_runtime_path(), "resources", "kod.mp4"))
|
||||
else: xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xbmcgui.ListItem(path=os.path.join(config.get_runtime_path(), "resources", "kod.mp4")))
|
||||
xbmc.sleep(200)
|
||||
xbmc.Player().stop()
|
||||
def prevent_busy():
|
||||
xbmc.executebuiltin('Dialog.Close(all,true)')
|
||||
|
||||
@@ -100,10 +100,10 @@ def mark_auto_as_watched(item):
|
||||
xbmc.sleep(700)
|
||||
xbmc.executebuiltin('Action(ParentDir)')
|
||||
xbmc.sleep(500)
|
||||
|
||||
# from core.support import dbg;dbg()
|
||||
if next_episode and next_episode.next_ep and config.get_setting('next_ep') < 3:
|
||||
from platformcode.launcher import play_from_library
|
||||
play_from_library(next_episode)
|
||||
from platformcode.launcher import run
|
||||
run(next_episode)
|
||||
|
||||
# db need to be closed when not used, it will cause freezes
|
||||
from core import db
|
||||
@@ -377,7 +377,10 @@ def set_watched_on_kod(data):
|
||||
|
||||
path = filetools.join(path, filename)
|
||||
head_nfo, item = videolibrarytools.read_nfo(path)
|
||||
item.library_playcounts.update({title: playcount})
|
||||
if item.library_playcounts:
|
||||
item.library_playcounts.update({title: playcount})
|
||||
else:
|
||||
item.library_playcounts = {title: playcount}
|
||||
filetools.write(path, head_nfo + item.tojson())
|
||||
|
||||
if item.infoLabels['mediatype'] == "tvshow":
|
||||
|
||||
Reference in New Issue
Block a user