Skip to content

Commit

Permalink
Add context-menu item for opening inputstream-adaptive settings if hl…
Browse files Browse the repository at this point in the history
…s is enabled.
  • Loading branch information
Alexander Bonelis committed Aug 27, 2023
1 parent e96cc28 commit 2682025
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/resources/lib/listitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ def __init__(
if addContextMenuItems:
self.addPredefinedContextMenuItems()

def _addInputstreamadaptivesettingsContextMenuItem(
self, menu_items: List[Tuple[str, str]]
) -> None:
label = "InputStream Adaptive settings"
url = self.plugin.routing.build_url("inputstream_adaptive_settings", self.getProperty("id"))
menu_items.append((label, f"Container.Update({url})"))

def _addWatchlistContextMenuItem(self, menu_items: List[Tuple[str, str]]) -> None:
is_subscribed = self.getProperty("is_subscribed")
if is_subscribed == "":
Expand Down Expand Up @@ -115,7 +122,19 @@ def _addSeparatorContextMenuItem(self, menu_items: List[Tuple[str, str]]) -> Non
menu_items.append(("─" * 21, ""))

def addPredefinedContextMenuItems(self, items: Optional[List[str]] = None) -> None:
items = items or ["watched", "watchlist", "bookmarks", "comments", "similar", "separator"]
items = items or (
[
"watched",
"watchlist",
"bookmarks",
"comments",
"similar",
"inputstreamadaptivesettings",
"separator",
]
if self.plugin.is_hls_enabled
else ["watched", "watchlist", "bookmarks", "comments", "similar", "separator"]
)
menu_items: List[str] = []
for item in items:
getattr(self, f"_add{item.capitalize()}ContextMenuItem")(menu_items)
Expand Down
5 changes: 5 additions & 0 deletions src/resources/lib/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,11 @@ def profile() -> None:
dialog.ok(localize(32038), message)


@plugin.routing.route("/inputstream_adaptive_settings/<item_id>")
def inputstream_adaptive_settings(item_id: str) -> None:
xbmcaddon.Addon("inputstream.adaptive").openSettings()


@plugin.routing.route("/comments/<item_id>")
def comments(item_id: str) -> None:
response = plugin.client("items/comments").get(data={"id": item_id})
Expand Down

0 comments on commit 2682025

Please sign in to comment.