mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-08 23:04:03 +00:00
add multi select, add redownload
This commit is contained in:
@@ -79,6 +79,7 @@ class AddToDownloadQuerySerializer(serializers.Serializer):
|
||||
|
||||
autostart = serializers.BooleanField(required=False)
|
||||
flat = serializers.BooleanField(required=False)
|
||||
force = serializers.BooleanField(required=False)
|
||||
|
||||
|
||||
class BulkUpdateDowloadQuerySerializer(serializers.Serializer):
|
||||
|
||||
@@ -109,6 +109,7 @@ class PendingList(PendingIndex):
|
||||
task=None,
|
||||
auto_start=False,
|
||||
flat=False,
|
||||
force=False,
|
||||
):
|
||||
super().__init__()
|
||||
self.config = AppConfig().config
|
||||
@@ -116,6 +117,7 @@ class PendingList(PendingIndex):
|
||||
self.task = task
|
||||
self.auto_start = auto_start
|
||||
self.flat = flat
|
||||
self.force = force
|
||||
self.to_skip = False
|
||||
self.missing_videos: list[dict] = []
|
||||
self.added = 0
|
||||
@@ -173,10 +175,16 @@ class PendingList(PendingIndex):
|
||||
PendingInteract(youtube_id=url, status="priority").update_status()
|
||||
return None
|
||||
|
||||
if url in self.missing_videos or url in self.to_skip:
|
||||
if not self.force and (
|
||||
url in self.missing_videos or url in self.to_skip
|
||||
):
|
||||
print(f"{url}: skipped adding already indexed video to download.")
|
||||
return None
|
||||
|
||||
if self.force and url in self.all_ignored or url in self.all_pending:
|
||||
print(f"{url}: skipped adding force video already in queue.")
|
||||
return None
|
||||
|
||||
to_add = self._parse_video(url, vid_type)
|
||||
if to_add:
|
||||
self.missing_videos.append(to_add)
|
||||
|
||||
@@ -118,12 +118,15 @@ class DownloadApiListView(ApiBaseView):
|
||||
|
||||
auto_start = validated_query.get("autostart")
|
||||
flat = validated_query.get("flat", False)
|
||||
print(f"auto_start: {auto_start}, flat: {flat}")
|
||||
force = validated_query.get("force", False)
|
||||
print(f"auto_start: {auto_start}, flat: {flat}, force: {force}")
|
||||
to_add = validated_data["data"]
|
||||
|
||||
pending = [i["youtube_id"] for i in to_add if i["status"] == "pending"]
|
||||
url_str = " ".join(pending)
|
||||
task = extrac_dl.delay(url_str, auto_start=auto_start, flat=flat)
|
||||
task = extrac_dl.delay(
|
||||
url_str, auto_start=auto_start, flat=flat, force=force
|
||||
)
|
||||
|
||||
message = {
|
||||
"message": "add to queue task started",
|
||||
@@ -153,15 +156,12 @@ class DownloadApiListView(ApiBaseView):
|
||||
query_serializer.is_valid(raise_exception=True)
|
||||
validated_query = query_serializer.validated_data
|
||||
status_filter = validated_query.get("filter")
|
||||
channel = validated_query.get("channel")
|
||||
vid_type = validated_query.get("vid_type")
|
||||
error = validated_query.get("error")
|
||||
|
||||
PendingInteract(status=status_filter).update_bulk(
|
||||
channel_id=channel,
|
||||
vid_type=vid_type,
|
||||
new_status=new_status,
|
||||
error=error,
|
||||
channel_id=validated_query.get("channel"),
|
||||
vid_type=validated_query.get("vid_type"),
|
||||
new_status=validated_data["status"],
|
||||
error=validated_query.get("error"),
|
||||
)
|
||||
|
||||
if new_status == "priority":
|
||||
|
||||
@@ -16,7 +16,7 @@ from celery import Task, shared_task
|
||||
from celery.exceptions import Retry
|
||||
from channel.src.index import YoutubeChannel
|
||||
from common.src.ta_redis import RedisArchivist
|
||||
from common.src.urlparser import Parser
|
||||
from common.src.urlparser import ParsedURLType, Parser
|
||||
from download.src.queue import PendingList
|
||||
from download.src.subscriptions import SubscriptionHandler, SubscriptionScanner
|
||||
from download.src.thumbnails import ThumbFilesystem, ThumbValidator
|
||||
@@ -150,8 +150,13 @@ def download_pending(self, auto_only=False):
|
||||
|
||||
@shared_task(name="extract_download", bind=True, base=BaseTask)
|
||||
def extrac_dl(
|
||||
self, youtube_ids, auto_start=False, flat=False, status="pending"
|
||||
):
|
||||
self,
|
||||
youtube_ids: str | list[ParsedURLType],
|
||||
auto_start: bool = False,
|
||||
flat: bool = False,
|
||||
force: bool = False,
|
||||
status: str = "pending",
|
||||
) -> str | None:
|
||||
"""parse list passed and add to pending"""
|
||||
TaskManager().init(self)
|
||||
if isinstance(youtube_ids, str):
|
||||
@@ -160,7 +165,11 @@ def extrac_dl(
|
||||
to_add = youtube_ids
|
||||
|
||||
pending_handler = PendingList(
|
||||
youtube_ids=to_add, task=self, auto_start=auto_start, flat=flat
|
||||
youtube_ids=to_add,
|
||||
task=self,
|
||||
auto_start=auto_start,
|
||||
flat=flat,
|
||||
force=force,
|
||||
)
|
||||
videos_added = pending_handler.parse_url_list(status=status)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user