diff --git a/backend/download/src/queue.py b/backend/download/src/queue.py index eae697d5..08be6906 100644 --- a/backend/download/src/queue.py +++ b/backend/download/src/queue.py @@ -167,14 +167,14 @@ class PendingList(PendingIndex): self.to_skip = False self.missing_videos = False - def parse_url_list(self): + def parse_url_list(self, auto_start=False): """extract youtube ids from list""" self.missing_videos = [] self.get_download() self.get_indexed() total = len(self.youtube_ids) for idx, entry in enumerate(self.youtube_ids): - self._process_entry(entry) + self._process_entry(entry, auto_start=auto_start) if not self.task: continue @@ -183,11 +183,11 @@ class PendingList(PendingIndex): progress=(idx + 1) / total, ) - def _process_entry(self, entry): + def _process_entry(self, entry, auto_start=False): """process single entry from url list""" vid_type = self._get_vid_type(entry) if entry["type"] == "video": - self._add_video(entry["url"], vid_type) + self._add_video(entry["url"], vid_type, auto_start=auto_start) elif entry["type"] == "channel": self._parse_channel(entry["url"], vid_type) elif entry["type"] == "playlist": @@ -204,8 +204,14 @@ class PendingList(PendingIndex): return VideoTypeEnum(vid_type_str) - def _add_video(self, url, vid_type): + def _add_video(self, url, vid_type, auto_start=False): """add video to list""" + if auto_start and url in set( + i["youtube_id"] for i in self.all_pending + ): + PendingInteract(youtube_id=url, status="priority").update_status() + return + if url not in self.missing_videos and url not in self.to_skip: self.missing_videos.append((url, vid_type)) else: diff --git a/backend/task/tasks.py b/backend/task/tasks.py index 31d7eb83..525938b4 100644 --- a/backend/task/tasks.py +++ b/backend/task/tasks.py @@ -156,7 +156,7 @@ def extrac_dl(self, youtube_ids, auto_start=False, status="pending"): to_add = youtube_ids pending_handler = PendingList(youtube_ids=to_add, task=self) - pending_handler.parse_url_list() + pending_handler.parse_url_list(auto_start=auto_start) videos_added = pending_handler.add_to_pending( status=status, auto_start=auto_start )