Skip to content

Commit

Permalink
Add new item_filter query parameter to override "Hide videos from lis…
Browse files Browse the repository at this point in the history
…tings" setting anxdpanic#896

- Comma seperated string of item types to be filtered out of listing
- "?item_filter=shorts" will remove shorts from listing
- "?item_filter=shorts,live" will remove shorts and live streams from listing
- "?item_filter" will show all item types
- Allowable item types:
  - shorts
  - upcoming
  - upcoming_live
  - live
  - premieres
  - completed
  - vod
  • Loading branch information
MoojMidge committed Sep 14, 2024
1 parent 3efb7e9 commit 3da06e1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class AbstractContext(object):
}
_LIST_PARAMS = {
'channel_ids',
'item_filter',
'playlist_ids',
}
_STRING_PARAMS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -412,8 +412,13 @@ def stream_select(self, value=None):
'vod': True,
}

def item_filter(self, update=None):
types = dict.fromkeys(self.get_string_list(SETTINGS.HIDE_VIDEOS), False)
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 update:
if 'live_folder' in update:
Expand Down
8 changes: 6 additions & 2 deletions resources/lib/youtube_plugin/youtube/helper/v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,13 @@ def response_to_items(provider,
context.log_debug('v3 response discarded: |%s|' % kind)
return []

params = context.get_params()

if kind_type in _KNOWN_RESPONSE_KINDS:
item_filter = context.get_settings().item_filter(item_filter)
item_filter = context.get_settings().item_filter(
update=item_filter,
override=params.get('item_filter'),
)
result = _process_list_response(
provider, context, json_data, item_filter
)
Expand All @@ -477,7 +482,6 @@ def response_to_items(provider,
We implemented our own calculation for the token into the YouTube client
This should work for up to ~2000 entries.
"""
params = context.get_params()
current_page = params.get('page')
next_page = current_page + 1 if current_page else 2
new_params = dict(params, page=next_page)
Expand Down

0 comments on commit 3da06e1

Please sign in to comment.