Fix context menu import causing movies not to load
Some checks failed
Build JellyCon / build (py2) (push) Has been cancelled
Build JellyCon / build (py3) (push) Has been cancelled
CodeQL Analysis / analyze (python, 3.9) (push) Has been cancelled
Release Drafter / Update release draft (push) Has been cancelled
Test JellyCon / test (3.9) (push) Has been cancelled

- Fix incorrect import: change 'from . import translation' to
  'from .utils import translate_string'
- Add try/except block to prevent context menu errors from breaking playback
- Add defensive check for item_details.id existence
- Add error logging for debugging context menu issues

This fixes the critical bug where the movie menu would not load
due to the incorrect translation import.
This commit is contained in:
mani
2026-01-06 00:46:21 +01:00
parent 3184fa6f89
commit ebd59760ae

View File

@@ -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