mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 20:29:36 +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":
|
||||
|
||||
Reference in New Issue
Block a user