diff --git a/resources/lib/item_functions.py b/resources/lib/item_functions.py index da3ec4b..db84a0c 100644 --- a/resources/lib/item_functions.py +++ b/resources/lib/item_functions.py @@ -596,18 +596,24 @@ def add_gui_item(url, item_details, display_options, folder=True, default_sort=F list_item.setProperties(item_properties) # Add context menu for playable video items - if not folder and is_video and item_details.item_type.lower() in ['movie', 'episode']: - from . import translation - context_menu = [] + if not folder and is_video and item_details.id and item_details.item_type.lower() in ['movie', 'episode']: + try: + from .utils import translate_string + context_menu = [] - # Add "Play with track selection" option - play_with_selection_url = ( - 'RunPlugin(plugin://plugin.video.jellycon/' - '?mode=PLAY&item_id={}&force_track_selection=true)'.format(item_details.id) - ) - context_menu.append((translation.translate_string(30701), play_with_selection_url)) + # Add "Play with track selection" option + play_with_selection_url = ( + 'RunPlugin(plugin://plugin.video.jellycon/' + '?mode=PLAY&item_id={}&force_track_selection=true)'.format(item_details.id) + ) + context_menu.append((translate_string(30701), play_with_selection_url)) - list_item.addContextMenuItems(context_menu) + list_item.addContextMenuItems(context_menu) + except Exception as e: + # Don't break playback if context menu fails + import logging + log = logging.getLogger(__name__) + log.debug("Failed to add context menu: {0}".format(e)) return u, list_item, folder