handle none page size subscriptions
This commit is contained in:
parent
e6260f6919
commit
f8a66ce7f0
|
|
@ -21,10 +21,14 @@ class AppConfigSubSerializer(
|
|||
):
|
||||
"""serialize app config subscriptions"""
|
||||
|
||||
channel_size = serializers.IntegerField(required=False)
|
||||
live_channel_size = serializers.IntegerField(required=False)
|
||||
shorts_channel_size = serializers.IntegerField(required=False)
|
||||
playlist_size = serializers.IntegerField(required=False)
|
||||
channel_size = serializers.IntegerField(required=False, allow_null=True)
|
||||
live_channel_size = serializers.IntegerField(
|
||||
required=False, allow_null=True
|
||||
)
|
||||
shorts_channel_size = serializers.IntegerField(
|
||||
required=False, allow_null=True
|
||||
)
|
||||
playlist_size = serializers.IntegerField(required=False, allow_null=True)
|
||||
auto_start = serializers.BooleanField(required=False)
|
||||
extract_flat = serializers.BooleanField(required=False)
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,9 @@ class VideoQueryBuilder:
|
|||
limit: bool,
|
||||
) -> tuple[VideoTypeEnum, int | None]:
|
||||
"""Generic query for video page scraping."""
|
||||
if not limit:
|
||||
app_config_size = self.config["subscriptions"].get(config_key)
|
||||
if not limit or app_config_size is None:
|
||||
# treat None as unlimited
|
||||
return (video_type, None)
|
||||
|
||||
if (
|
||||
|
|
@ -94,8 +96,8 @@ class VideoQueryBuilder:
|
|||
overwrite = self.channel_overwrites[overwrite_key]
|
||||
return (video_type, overwrite)
|
||||
|
||||
if overwrite := self.config["subscriptions"].get(config_key):
|
||||
return (video_type, overwrite)
|
||||
if app_config_size:
|
||||
return (video_type, app_config_size)
|
||||
|
||||
return (video_type, 0)
|
||||
|
||||
|
|
|
|||
|
|
@ -34,28 +34,7 @@ class ChannelSubscription:
|
|||
if not all_channels:
|
||||
return 0
|
||||
|
||||
all_channel_urls: list[ParsedURLType] = []
|
||||
|
||||
for channel in all_channels:
|
||||
channel_tabs = channel["channel_tabs"]
|
||||
if not channel_tabs:
|
||||
continue
|
||||
|
||||
enum = [getattr(VideoTypeEnum, i.upper()) for i in channel_tabs]
|
||||
queries = VideoQueryBuilder(
|
||||
config=self.config,
|
||||
channel_overwrites=channel.get("channel_overwrites", {}),
|
||||
).build_queries(video_type=enum)
|
||||
|
||||
for query in queries:
|
||||
all_channel_urls.append(
|
||||
ParsedURLType(
|
||||
type="channel",
|
||||
url=channel["channel_id"],
|
||||
vid_type=query[0],
|
||||
limit=query[1],
|
||||
)
|
||||
)
|
||||
all_channel_urls = self._process_channel_urls(all_channels)
|
||||
|
||||
if self.task:
|
||||
self.task.send_progress([f"Scanning {len(all_channels)} channels"])
|
||||
|
|
@ -70,6 +49,34 @@ class ChannelSubscription:
|
|||
|
||||
return added
|
||||
|
||||
def _process_channel_urls(self, all_channels: list[dict]):
|
||||
"""process channels, build queries"""
|
||||
|
||||
all_channel_urls: list[ParsedURLType] = []
|
||||
|
||||
for channel in all_channels:
|
||||
channel_tabs = channel["channel_tabs"]
|
||||
if not channel_tabs:
|
||||
continue
|
||||
|
||||
enums = [getattr(VideoTypeEnum, i.upper()) for i in channel_tabs]
|
||||
queries = VideoQueryBuilder(
|
||||
config=self.config,
|
||||
channel_overwrites=channel.get("channel_overwrites", {}),
|
||||
).build_queries(video_type=enums)
|
||||
|
||||
for query in queries:
|
||||
all_channel_urls.append(
|
||||
ParsedURLType(
|
||||
type="channel",
|
||||
url=channel["channel_id"],
|
||||
vid_type=query[0],
|
||||
limit=query[1],
|
||||
)
|
||||
)
|
||||
|
||||
return all_channel_urls
|
||||
|
||||
|
||||
class PlaylistSubscription:
|
||||
"""scan subscribed playlists for videos to add to pending"""
|
||||
|
|
|
|||
|
|
@ -96,9 +96,9 @@ const SettingsApplication = () => {
|
|||
const { data: cookieStateResponseData } = cookieStateResponse ?? {};
|
||||
|
||||
// Subscriptions
|
||||
setVideoPageSize(appSettingsConfigData?.subscriptions.channel_size || null);
|
||||
setLivePageSize(appSettingsConfigData?.subscriptions.live_channel_size || null);
|
||||
setShortPageSize(appSettingsConfigData?.subscriptions.shorts_channel_size || null);
|
||||
setVideoPageSize(appSettingsConfigData?.subscriptions.channel_size ?? null);
|
||||
setLivePageSize(appSettingsConfigData?.subscriptions.live_channel_size ?? null);
|
||||
setShortPageSize(appSettingsConfigData?.subscriptions.shorts_channel_size ?? null);
|
||||
setPlaylistPageSize(appSettingsConfigData?.subscriptions.playlist_size || null);
|
||||
setIsAutostart(appSettingsConfigData?.subscriptions.auto_start || false);
|
||||
setIsExtractFlat(appSettingsConfigData?.subscriptions.extract_flat || false);
|
||||
|
|
|
|||
Loading…
Reference in New Issue