mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-08 21:39:32 +00:00
handle none page size subscriptions
This commit is contained in:
@@ -21,10 +21,14 @@ class AppConfigSubSerializer(
|
|||||||
):
|
):
|
||||||
"""serialize app config subscriptions"""
|
"""serialize app config subscriptions"""
|
||||||
|
|
||||||
channel_size = serializers.IntegerField(required=False)
|
channel_size = serializers.IntegerField(required=False, allow_null=True)
|
||||||
live_channel_size = serializers.IntegerField(required=False)
|
live_channel_size = serializers.IntegerField(
|
||||||
shorts_channel_size = serializers.IntegerField(required=False)
|
required=False, allow_null=True
|
||||||
playlist_size = serializers.IntegerField(required=False)
|
)
|
||||||
|
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)
|
auto_start = serializers.BooleanField(required=False)
|
||||||
extract_flat = serializers.BooleanField(required=False)
|
extract_flat = serializers.BooleanField(required=False)
|
||||||
|
|
||||||
|
|||||||
@@ -84,7 +84,9 @@ class VideoQueryBuilder:
|
|||||||
limit: bool,
|
limit: bool,
|
||||||
) -> tuple[VideoTypeEnum, int | None]:
|
) -> tuple[VideoTypeEnum, int | None]:
|
||||||
"""Generic query for video page scraping."""
|
"""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)
|
return (video_type, None)
|
||||||
|
|
||||||
if (
|
if (
|
||||||
@@ -94,8 +96,8 @@ class VideoQueryBuilder:
|
|||||||
overwrite = self.channel_overwrites[overwrite_key]
|
overwrite = self.channel_overwrites[overwrite_key]
|
||||||
return (video_type, overwrite)
|
return (video_type, overwrite)
|
||||||
|
|
||||||
if overwrite := self.config["subscriptions"].get(config_key):
|
if app_config_size:
|
||||||
return (video_type, overwrite)
|
return (video_type, app_config_size)
|
||||||
|
|
||||||
return (video_type, 0)
|
return (video_type, 0)
|
||||||
|
|
||||||
|
|||||||
@@ -34,28 +34,7 @@ class ChannelSubscription:
|
|||||||
if not all_channels:
|
if not all_channels:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
all_channel_urls: list[ParsedURLType] = []
|
all_channel_urls = self._process_channel_urls(all_channels)
|
||||||
|
|
||||||
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],
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
if self.task:
|
if self.task:
|
||||||
self.task.send_progress([f"Scanning {len(all_channels)} channels"])
|
self.task.send_progress([f"Scanning {len(all_channels)} channels"])
|
||||||
@@ -70,6 +49,34 @@ class ChannelSubscription:
|
|||||||
|
|
||||||
return added
|
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:
|
class PlaylistSubscription:
|
||||||
"""scan subscribed playlists for videos to add to pending"""
|
"""scan subscribed playlists for videos to add to pending"""
|
||||||
|
|||||||
@@ -96,9 +96,9 @@ const SettingsApplication = () => {
|
|||||||
const { data: cookieStateResponseData } = cookieStateResponse ?? {};
|
const { data: cookieStateResponseData } = cookieStateResponse ?? {};
|
||||||
|
|
||||||
// Subscriptions
|
// Subscriptions
|
||||||
setVideoPageSize(appSettingsConfigData?.subscriptions.channel_size || null);
|
setVideoPageSize(appSettingsConfigData?.subscriptions.channel_size ?? null);
|
||||||
setLivePageSize(appSettingsConfigData?.subscriptions.live_channel_size || null);
|
setLivePageSize(appSettingsConfigData?.subscriptions.live_channel_size ?? null);
|
||||||
setShortPageSize(appSettingsConfigData?.subscriptions.shorts_channel_size || null);
|
setShortPageSize(appSettingsConfigData?.subscriptions.shorts_channel_size ?? null);
|
||||||
setPlaylistPageSize(appSettingsConfigData?.subscriptions.playlist_size || null);
|
setPlaylistPageSize(appSettingsConfigData?.subscriptions.playlist_size || null);
|
||||||
setIsAutostart(appSettingsConfigData?.subscriptions.auto_start || false);
|
setIsAutostart(appSettingsConfigData?.subscriptions.auto_start || false);
|
||||||
setIsExtractFlat(appSettingsConfigData?.subscriptions.extract_flat || false);
|
setIsExtractFlat(appSettingsConfigData?.subscriptions.extract_flat || false);
|
||||||
|
|||||||
Reference in New Issue
Block a user