Skip to content

Commit

Permalink
Fix incorrect date sorting after a3af85f
Browse files Browse the repository at this point in the history
- Sorting was messed up due to sorting based on localised date format
- No default sorting for non-live listings, will use order from API
- TODO: Ensure correct order is kept when using cache
  • Loading branch information
MoojMidge committed Dec 15, 2023
1 parent 5c27828 commit e9ed03f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions resources/lib/youtube_plugin/kodion/items/base_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def set_date(self, year, month, day, hour=0, minute=0, second=0):
def set_date_from_datetime(self, date_time):
self._date = date_time

def get_date(self, as_text=True, short=False):
def get_date(self, as_text=False, short=False):
if not self._date:
return ''
if short:
Expand All @@ -131,7 +131,7 @@ def set_dateadded(self, year, month, day, hour=0, minute=0, second=0):
def set_dateadded_from_datetime(self, date_time):
self._dateadded = date_time

def get_dateadded(self, as_text=True):
def get_dateadded(self, as_text=False):
if not self._dateadded:
return ''
if as_text:
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/youtube_plugin/kodion/ui/xbmc/info_labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def create_from_item(base_item):
info_labels = {}

# 'date' = '1982-03-09' (string)
_process_datetime_value(info_labels, 'date', base_item.get_date(as_text=False))
_process_datetime_value(info_labels, 'date', base_item.get_date())

# 'count' = 12 (integer)
# Can be used to store an id for later, or for sorting purposes
Expand Down Expand Up @@ -138,7 +138,7 @@ def create_from_item(base_item):
_process_list_value(info_labels, 'artist', base_item.get_artist())

# 'dateadded' = '2014-08-11 13:08:56' (string) will be taken from 'dateadded'
_process_datetime_value(info_labels, 'dateadded', base_item.get_dateadded(as_text=False))
_process_datetime_value(info_labels, 'dateadded', base_item.get_dateadded())

# TODO: starting with Helix this could be seconds
# 'duration' = '3:18' (string)
Expand Down
3 changes: 1 addition & 2 deletions resources/lib/youtube_plugin/youtube/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -493,8 +493,7 @@ def _on_channel(self, context, re_match):
if not v3.handle_error(context, json_data):
return False

result.extend(
v3.response_to_items(self, context, json_data, sort=lambda x: x.get_date()))
result.extend(v3.response_to_items(self, context, json_data))

return result

Expand Down

0 comments on commit e9ed03f

Please sign in to comment.