diff --git a/platformcode/platformtools.py b/platformcode/platformtools.py index a01fafcc..4a24345f 100644 --- a/platformcode/platformtools.py +++ b/platformcode/platformtools.py @@ -393,16 +393,21 @@ def viewmodeMonitor(): if get_window() == 'WINDOW_VIDEO_NAV': try: currentModeName = xbmc.getInfoLabel('Container.Viewmode') - win = xbmcgui.Window(xbmcgui.getCurrentWindowId()) + parent_info = xbmc.getInfoLabel('Container.FolderPath') + item_info = xbmc.getInfoLabel('Container.ListItemPosition(2).FileNameAndPath') + parent_item = Item().fromurl(parent_info) + win = xbmcgui.Window(10025) 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: + # from core.support import dbg;dbg() + 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: - logger.debug('viewmode changed: ' + currentModeName + '-' + str(currentMode) + ' - content: ' + content) + # logger.debug('viewmode changed: ' + currentModeName + '-' + str(currentMode) + ' - content: ' + content) config.set_setting('view_mode_%s' % content, currentModeName + ', ' + str(currentMode)) dialog_notification(config.get_localized_string(70153), config.get_localized_string(70187) % (content, currentModeName), @@ -413,17 +418,24 @@ 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() + item = Item() + if not parent_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 '' @@ -444,21 +456,26 @@ def getCurrentView(item=None, parent_item=None): or (item.channel in ['videolibrary'] and parent_item.action in ['list_tvshows']): return 'tvshow', 'tvshows' - elif parent_item.action in ['get_seasons']: - return 'season', 'tvshows' - elif parent_item.action in ['episodios', 'get_episodes'] or item.contentType == 'episode': return 'episode', 'tvshows' - elif parent_item.action in ['getmainlist', '']: + elif parent_item.action in ['get_seasons']: + logger.debug('CONTENTTYPE:',item.contentType) + return 'season', 'tvshows' + + elif parent_item.action in ['getmainlist', '', 'getchanneltypes']: return 'home', addons elif parent_item.action in ['filterchannels']: return 'channels', addons - else: + elif item.action: return 'menu', addons + else: + return None, None + + def set_view_mode(item, parent_item): def reset_view_mode(): diff --git a/specials/videolibrary.py b/specials/videolibrary.py index fcf2a3fb..75332b9d 100644 --- a/specials/videolibrary.py +++ b/specials/videolibrary.py @@ -96,6 +96,7 @@ def get_results(nfo_path, root, Type, local=False): if filetools.exists(nfo_path): head_nfo, item = videolibrarytools.read_nfo(nfo_path) + item.contentType = Type # If you have not read the .nfo well, we will proceed to the next if not item: @@ -246,7 +247,7 @@ def get_seasons(item): # We create one item for each season for season, title in list(dict_temp.items()): new_item = item.clone(action="get_episodes", title=title, contentSeason=season, - filtrar_season=True, channel='videolibrary') + filtrar_season=True, channel='videolibrary', contentType='season') #Contextual menu: Mark the season as viewed or not visto = item_nfo.library_playcounts.get("season %s" % season, 0) @@ -313,6 +314,7 @@ def get_episodes(item): epi.contentTitle = "%sx%s" % (epi.contentSeason, str(epi.contentEpisodeNumber).zfill(2)) epi.title = "%sx%s - %s" % (epi.contentSeason, str(epi.contentEpisodeNumber).zfill(2), title_episodie) + epi.contentType = 'episode' if item_nfo.library_filter_show: epi.library_filter_show = item_nfo.library_filter_show