diff --git a/resources/lib/youtube_plugin/kodion/items/base_item.py b/resources/lib/youtube_plugin/kodion/items/base_item.py index e417a50a0..32b43952b 100644 --- a/resources/lib/youtube_plugin/kodion/items/base_item.py +++ b/resources/lib/youtube_plugin/kodion/items/base_item.py @@ -14,6 +14,7 @@ from datetime import date, datetime from hashlib import md5 +from .menu_items import separator from ..compatibility import ( datetime_infolabel, parse_qsl, @@ -193,10 +194,16 @@ def get_fanart(self, default=True): 'fanart.jpg', )) - def add_context_menu(self, context_menu, position='end', replace=False): - context_menu = (item for item in context_menu if item) + def add_context_menu(self, + context_menu, + position='end', + replace=False, + end_separator=separator()): + context_menu = [item for item in context_menu if item] + if context_menu and end_separator and context_menu[-1] != end_separator: + context_menu.append(end_separator) if replace or not self._context_menu: - self._context_menu = list(context_menu) + self._context_menu = context_menu elif position == 'end': self._context_menu.extend(context_menu) else: diff --git a/resources/lib/youtube_plugin/kodion/items/command_item.py b/resources/lib/youtube_plugin/kodion/items/command_item.py index c4838c005..501a28f28 100644 --- a/resources/lib/youtube_plugin/kodion/items/command_item.py +++ b/resources/lib/youtube_plugin/kodion/items/command_item.py @@ -37,6 +37,5 @@ def __init__(self, menu_items.refresh(context), menu_items.goto_home(context), menu_items.goto_quick_search(context), - menu_items.separator(), ] self.add_context_menu(context_menu) diff --git a/resources/lib/youtube_plugin/kodion/items/next_page_item.py b/resources/lib/youtube_plugin/kodion/items/next_page_item.py index 32d50c0f5..946820f50 100644 --- a/resources/lib/youtube_plugin/kodion/items/next_page_item.py +++ b/resources/lib/youtube_plugin/kodion/items/next_page_item.py @@ -45,7 +45,6 @@ def __init__(self, context, params, image=None, fanart=None): menu_items.goto_page(context, params) if can_jump else None, menu_items.goto_home(context), menu_items.goto_quick_search(context), - menu_items.separator(), ] self.add_context_menu(context_menu) diff --git a/resources/lib/youtube_plugin/kodion/items/search_history_item.py b/resources/lib/youtube_plugin/kodion/items/search_history_item.py index 0d5785f9e..ba406f877 100644 --- a/resources/lib/youtube_plugin/kodion/items/search_history_item.py +++ b/resources/lib/youtube_plugin/kodion/items/search_history_item.py @@ -46,6 +46,5 @@ def __init__(self, context, query, image=None, fanart=None, location=False): menu_items.search_sort_by(context, params, 'viewCount'), menu_items.search_sort_by(context, params, 'rating'), menu_items.search_sort_by(context, params, 'title'), - menu_items.separator(), ] self.add_context_menu(context_menu) diff --git a/resources/lib/youtube_plugin/youtube/helper/utils.py b/resources/lib/youtube_plugin/youtube/helper/utils.py index a7144c478..bf8351548 100644 --- a/resources/lib/youtube_plugin/youtube/helper/utils.py +++ b/resources/lib/youtube_plugin/youtube/helper/utils.py @@ -301,7 +301,6 @@ def update_channel_infos(provider, context, channel_id_dict, ) if context_menu: - context_menu.append(menu_items.separator()) channel_item.add_context_menu(context_menu) # update channel mapping @@ -342,6 +341,7 @@ def update_playlist_infos(provider, context, playlist_id_dict, video_count_label = localize('stats.videoCount') podcast_label = context.localize('playlist.podcast') untitled = localize('untitled') + separator = menu_items.separator() path = context.get_path() ui = context.get_ui() @@ -448,7 +448,7 @@ def update_playlist_infos(provider, context, playlist_id_dict, menu_items.shuffle_playlist( context, playlist_id ), - menu_items.separator(), + separator, menu_items.bookmark_add( context, playlist_item ) if not in_bookmarks_list and channel_id != 'mine' else None, @@ -499,7 +499,6 @@ def update_playlist_infos(provider, context, playlist_id_dict, ) if context_menu: - context_menu.append(menu_items.separator()) playlist_item.add_context_menu(context_menu) # update channel mapping @@ -993,7 +992,6 @@ def update_video_infos(provider, context, video_id_dict, ) if context_menu: - context_menu.append(menu_items.separator()) media_item.add_context_menu(context_menu) diff --git a/resources/lib/youtube_plugin/youtube/helper/v3.py b/resources/lib/youtube_plugin/youtube/helper/v3.py index fc4dfaee2..b8c9ba892 100644 --- a/resources/lib/youtube_plugin/youtube/helper/v3.py +++ b/resources/lib/youtube_plugin/youtube/helper/v3.py @@ -123,7 +123,6 @@ def _process_list_response(provider, context, json_data, item_filter): menu_items.search_sort_by(context, params, 'viewCount'), menu_items.search_sort_by(context, params, 'rating'), menu_items.search_sort_by(context, params, 'title'), - menu_items.separator() ), 'position': 0, } diff --git a/resources/lib/youtube_plugin/youtube/provider.py b/resources/lib/youtube_plugin/youtube/provider.py index 9c4e1601b..7fe503589 100644 --- a/resources/lib/youtube_plugin/youtube/provider.py +++ b/resources/lib/youtube_plugin/youtube/provider.py @@ -436,29 +436,25 @@ def on_channel_playlists(provider, context, re_match): menu_items.shuffle_playlist( context, playlist_id ), - menu_items.separator(), - menu_items.bookmark_add( - context, uploads - ) if channel_id != 'mine' else None, ] if channel_id != 'mine': - if provider.is_logged_in: + context_menu.extend(( + menu_items.separator(), + menu_items.bookmark_add( + context, uploads + ), # subscribe to the channel via the playlist item - context_menu.append( - menu_items.subscribe_to_channel( - context, channel_id, - ) - ) - context_menu.append( + menu_items.subscribe_to_channel( + context, channel_id, + ) if provider.is_logged_in else None, # bookmark channel of the playlist menu_items.bookmark_add_channel( context, channel_id, ) - ) + )) if context_menu: - context_menu.append(menu_items.separator()) uploads.add_context_menu(context_menu) result = [uploads] @@ -1114,7 +1110,6 @@ def on_playback_history(provider, context, re_match): menu_items.history_clear( context ), - menu_items.separator(), ), 'position': 0, } @@ -1606,7 +1601,6 @@ def _update(new_item): menu_items.bookmarks_clear( context ), - menu_items.separator(), ), 'position': 0, }, @@ -1691,7 +1685,6 @@ def on_watch_later(provider, context, re_match): menu_items.watch_later_local_clear( context ), - menu_items.separator(), ), 'position': 0, }