Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new advanced list filter setting
Browse files Browse the repository at this point in the history
- Works in the same manner as the My Subscriptions filter, but for all listings
- Can also be set using the item_filter plugin URI query parameter
MoojMidge committed Nov 27, 2024
1 parent d66744b commit b2021ca
Showing 3 changed files with 32 additions and 14 deletions.
Original file line number Diff line number Diff line change
@@ -30,6 +30,7 @@
ITEMS_PER_PAGE = 'kodion.content.max_per_page' # (int)
HIDE_VIDEOS = 'youtube.view.hide_videos' # (list[str])
SHORTS_DURATION = 'youtube.view.shorts.duration' # (int)
FILTER_LIST = 'youtube.view.filter.list' # (str)

SAFE_SEARCH = 'kodion.safe.search' # (int)
AGE_GATE = 'kodion.age.gate' # (bool)
35 changes: 21 additions & 14 deletions resources/lib/youtube_plugin/kodion/settings/abstract_settings.py
Original file line number Diff line number Diff line change
@@ -573,31 +573,38 @@ def stream_select(self, value=None):
'premieres': True,
'completed': True,
'vod': True,
'custom': None,
}

def item_filter(self, update=None, override=None):
types = dict.fromkeys(
self.get_string_list(SETTINGS.HIDE_VIDEOS)
if override is None else
override,
False
)
types = dict(self._DEFAULT_FILTER, **types)
if override is None:
override = self.get_string_list(SETTINGS.HIDE_VIDEOS)
override = dict.fromkeys(override, False)
override['custom'] = (self.get_string(SETTINGS.FILTER_LIST)
.split(','))
elif isinstance(override, (list, tuple)):
_override = {'custom': []}
for value in override:
if value in self._DEFAULT_FILTER:
_override[value] = False
else:
_override['custom'].append(value)
override = _override
types = dict(self._DEFAULT_FILTER, **override)

if update:
if 'live_folder' in update:
if 'live_folder' in types:
types.update(update)
else:
types.update({
if 'live_folder' not in types:
update.update({
'vod': False,
'upcoming': True,
'upcoming_live': True,
'live': True,
'premieres': True,
'completed': True,
})
types['vod'] = False
else:
types.update(update)
types.update(update)

return types

def shorts_duration(self, value=None):
10 changes: 10 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
@@ -780,6 +780,16 @@
<popup>false</popup>
</control>
</setting>
<setting id="youtube.view.filter.list" type="string" label="587" help="30583">
<level>0</level>
<default/>
<constraints>
<allowempty>true</allowempty>
</constraints>
<control format="string" type="edit">
<heading>587</heading>
</control>
</setting>
<setting id="youtube.view.channel_name.aliases" type="list[string]" label="30807" help="">
<level>0</level>
<default>cast</default>

0 comments on commit b2021ca

Please sign in to comment.