Skip to content

Commit

Permalink
Move track number getter/setter to BaseItem class
Browse files Browse the repository at this point in the history
- Set for AudioItem
- Allow for future setting on DirectoryItem
  • Loading branch information
MoojMidge committed Dec 7, 2024
1 parent 35ee874 commit c177157
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 8 deletions.
7 changes: 7 additions & 0 deletions resources/lib/youtube_plugin/kodion/items/base_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
7 changes: 0 additions & 7 deletions resources/lib/youtube_plugin/kodion/items/media_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
10 changes: 10 additions & 0 deletions resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down Expand Up @@ -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'
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/youtube_plugin/youtube/helper/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
from ...kodion.items import (
CommandItem,
DirectoryItem,
MediaItem,
NextPageItem,
VideoItem,
menu_items,
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit c177157

Please sign in to comment.