diff --git a/resources/lib/youtube_plugin/kodion/items/base_item.py b/resources/lib/youtube_plugin/kodion/items/base_item.py index 5f7649990..4ebf50069 100644 --- a/resources/lib/youtube_plugin/kodion/items/base_item.py +++ b/resources/lib/youtube_plugin/kodion/items/base_item.py @@ -54,6 +54,7 @@ def __init__(self, name, uri, image=None, fanart=None): self._dateadded = None self._short_details = None self._production_code = None + self._track_number = None self._cast = None self._artists = None @@ -339,6 +340,12 @@ def set_production_code(self, value): def get_production_code(self): return self._production_code + def set_track_number(self, track_number): + self._track_number = int(track_number) + + def get_track_number(self): + return self._track_number + class _Encoder(json.JSONEncoder): def encode(self, obj, nested=False): diff --git a/resources/lib/youtube_plugin/kodion/items/media_item.py b/resources/lib/youtube_plugin/kodion/items/media_item.py index 0a8554d85..902a2f27e 100644 --- a/resources/lib/youtube_plugin/kodion/items/media_item.py +++ b/resources/lib/youtube_plugin/kodion/items/media_item.py @@ -54,7 +54,6 @@ def __init__(self, self._plot = plot self._rating = None self._title = self.get_name() - self._track_number = None self._headers = None self._license_key = None @@ -213,12 +212,6 @@ def set_title(self, title): def get_title(self): return self._title - def set_track_number(self, track_number): - self._track_number = int(track_number) - - def get_track_number(self): - return self._track_number - def set_headers(self, value): self._headers = value diff --git a/resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py b/resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py index ea6375273..b7f5ea5a8 100644 --- a/resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py +++ b/resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py @@ -126,6 +126,10 @@ def set_info(list_item, item, properties, set_play_count=True, resume=True): if value is not None: info_labels['plot'] = value + value = item.get_track_number() + if value is not None: + info_labels['tracknumber'] = value + elif isinstance(item, ImageItem): info_type = 'picture' @@ -334,6 +338,12 @@ def set_info(list_item, item, properties, set_play_count=True, resume=True): if value is not None: info_tag.setPlot(value) + # tracknumber: int + # eg. 12 + value = item.get_track_number() + if value is not None: + info_tag.setTrackNumber(value) + elif isinstance(item, ImageItem): info_tag = list_item.getPictureInfoTag() info_type = 'picture' diff --git a/resources/lib/youtube_plugin/youtube/helper/v3.py b/resources/lib/youtube_plugin/youtube/helper/v3.py index abbae48e1..f47273f23 100644 --- a/resources/lib/youtube_plugin/youtube/helper/v3.py +++ b/resources/lib/youtube_plugin/youtube/helper/v3.py @@ -29,6 +29,7 @@ from ...kodion.items import ( CommandItem, DirectoryItem, + MediaItem, NextPageItem, VideoItem, menu_items, @@ -300,7 +301,7 @@ def _process_list_response(provider, if '_context_menu' in yt_item: item.add_context_menu(**yt_item['_context_menu']) - if isinstance(item, VideoItem): + if isinstance(item, MediaItem): # Set track number from playlist, or set to current list length to # match "Default" (unsorted) sort order position = snippet.get('position') or len(items)