Add settings for filtering out shorts in subscriptions and channels

This commit is contained in:
Astound 2024-01-22 05:55:59 +08:00
parent 2140f48919
commit ca4a735692
Signed by: kaiser
GPG Key ID: 97504AF0027B1A56
3 changed files with 21 additions and 3 deletions

View File

@ -298,6 +298,18 @@ Archive: https://archive.ph/OZQbN''',
'comment': '', 'comment': '',
}), }),
('include_shorts_in_subscriptions', {
'type': bool,
'default': 0,
'comment': '',
}),
('include_shorts_in_channel', {
'type': bool,
'default': 1,
'comment': '',
}),
('gather_googlevideo_domains', { ('gather_googlevideo_domains', {
'type': bool, 'type': bool,
'default': False, 'default': False,

View File

@ -2,6 +2,7 @@ import base64
from youtube import (util, yt_data_extract, local_playlist, subscriptions, from youtube import (util, yt_data_extract, local_playlist, subscriptions,
playlist) playlist)
from youtube import yt_app from youtube import yt_app
import settings
import urllib import urllib
import json import json
@ -382,7 +383,8 @@ def get_channel_page_general_url(base_url, tab, request, channel_id=None):
# sort 2: oldest # sort 2: oldest
# sort 3: newest # sort 3: newest
# sort 4: newest - no shorts (Just a kludge on our end, not internal to yt) # sort 4: newest - no shorts (Just a kludge on our end, not internal to yt)
sort = request.args.get('sort', '3') default_sort = '3' if settings.include_shorts_in_channel else '4'
sort = request.args.get('sort', default_sort)
view = request.args.get('view', '1') view = request.args.get('view', '1')
query = request.args.get('query', '') query = request.args.get('query', '')
ctoken = request.args.get('ctoken', '') ctoken = request.args.get('ctoken', '')

View File

@ -464,8 +464,12 @@ def _get_atoma_feed(channel_id):
def _get_channel_videos_first_page(channel_id, channel_status_name): def _get_channel_videos_first_page(channel_id, channel_status_name):
try: try:
# First try the playlist method # First try the playlist method
pl_json = playlist.get_videos('UU' + channel_id[2:], 1, pl_json = playlist.get_videos(
include_shorts=False, report_text=None) 'UU' + channel_id[2:],
1,
include_shorts=settings.include_shorts_in_subscriptions,
report_text=None
)
pl_info = yt_data_extract.extract_playlist_info(pl_json) pl_info = yt_data_extract.extract_playlist_info(pl_json)
if pl_info.get('items'): if pl_info.get('items'):
pl_info['items'] = pl_info['items'][0:30] pl_info['items'] = pl_info['items'][0:30]