mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-04 19:19:26 +00:00
add to each item to pending queue in loop
This commit is contained in:
@@ -118,8 +118,9 @@ class PendingList(PendingIndex):
|
|||||||
self.flat = flat
|
self.flat = flat
|
||||||
self.to_skip = False
|
self.to_skip = False
|
||||||
self.missing_videos: list[dict] = []
|
self.missing_videos: list[dict] = []
|
||||||
|
self.added = 0
|
||||||
|
|
||||||
def parse_url_list(self):
|
def parse_url_list(self, status="pending") -> int:
|
||||||
"""extract youtube ids from list"""
|
"""extract youtube ids from list"""
|
||||||
self.get_download()
|
self.get_download()
|
||||||
self.get_indexed()
|
self.get_indexed()
|
||||||
@@ -128,17 +129,24 @@ class PendingList(PendingIndex):
|
|||||||
for idx, entry in enumerate(self.youtube_ids, start=1):
|
for idx, entry in enumerate(self.youtube_ids, start=1):
|
||||||
if self.task:
|
if self.task:
|
||||||
self.task.send_progress(
|
self.task.send_progress(
|
||||||
message_lines=[f"Extracting items {idx}/{total}"],
|
message_lines=[f"Extracting URL {idx}/{total}"],
|
||||||
progress=(idx + 1) / total,
|
progress=idx / total,
|
||||||
)
|
)
|
||||||
|
|
||||||
self._process_entry(entry, idx, total)
|
self._process_entry(entry, idx, total)
|
||||||
|
|
||||||
|
if self.missing_videos:
|
||||||
|
self.added += self.add_to_pending(status)
|
||||||
|
self.missing_videos = []
|
||||||
|
|
||||||
if self.task and self.task.is_stopped():
|
if self.task and self.task.is_stopped():
|
||||||
break
|
break
|
||||||
|
|
||||||
rand_sleep(self.config)
|
rand_sleep(self.config)
|
||||||
|
|
||||||
def _process_entry(self, entry: dict, idx: int, total: int):
|
return self.added
|
||||||
|
|
||||||
|
def _process_entry(self, entry: ParsedURLType, idx: int, total: int):
|
||||||
"""process single entry from url list"""
|
"""process single entry from url list"""
|
||||||
if entry["type"] == "video":
|
if entry["type"] == "video":
|
||||||
to_add = self._add_video(entry["url"], entry["vid_type"])
|
to_add = self._add_video(entry["url"], entry["vid_type"])
|
||||||
@@ -373,7 +381,7 @@ class PendingList(PendingIndex):
|
|||||||
def __extract_vid_type(self, video_data) -> str:
|
def __extract_vid_type(self, video_data) -> str:
|
||||||
"""build vid type"""
|
"""build vid type"""
|
||||||
if "vid_type" in video_data:
|
if "vid_type" in video_data:
|
||||||
return video_data["vid_type"]
|
return str(video_data["vid_type"])
|
||||||
|
|
||||||
if video_data.get("live_status") == "was_live":
|
if video_data.get("live_status") == "was_live":
|
||||||
return VideoTypeEnum.STREAMS.value
|
return VideoTypeEnum.STREAMS.value
|
||||||
@@ -445,7 +453,7 @@ class PendingList(PendingIndex):
|
|||||||
|
|
||||||
self.task.send_progress(
|
self.task.send_progress(
|
||||||
message_lines=lines,
|
message_lines=lines,
|
||||||
progress=(idx + 1) / total,
|
progress=idx / total,
|
||||||
)
|
)
|
||||||
|
|
||||||
def _notify_empty(self):
|
def _notify_empty(self):
|
||||||
|
|||||||
@@ -60,8 +60,7 @@ class ChannelSubscription:
|
|||||||
auto_start=self.config["subscriptions"].get("auto_start", False),
|
auto_start=self.config["subscriptions"].get("auto_start", False),
|
||||||
flat=self.config["subscriptions"].get("extract_flat", False),
|
flat=self.config["subscriptions"].get("extract_flat", False),
|
||||||
)
|
)
|
||||||
pending_handler.parse_url_list()
|
added = pending_handler.parse_url_list()
|
||||||
added = pending_handler.add_to_pending()
|
|
||||||
|
|
||||||
return added
|
return added
|
||||||
|
|
||||||
@@ -99,8 +98,7 @@ class PlaylistSubscription:
|
|||||||
auto_start=self.config["subscriptions"].get("auto_start", False),
|
auto_start=self.config["subscriptions"].get("auto_start", False),
|
||||||
flat=self.config["subscriptions"].get("extract_flat", False),
|
flat=self.config["subscriptions"].get("extract_flat", False),
|
||||||
)
|
)
|
||||||
pending_handler.parse_url_list()
|
added = pending_handler.parse_url_list()
|
||||||
added = pending_handler.add_to_pending()
|
|
||||||
|
|
||||||
return added
|
return added
|
||||||
|
|
||||||
|
|||||||
@@ -360,9 +360,7 @@ class DownloadPostProcess(DownloaderBase):
|
|||||||
|
|
||||||
print("add deleted to ignore list")
|
print("add deleted to ignore list")
|
||||||
vids = [{"type": "video", "url": i["youtube_id"]} for i in to_delete]
|
vids = [{"type": "video", "url": i["youtube_id"]} for i in to_delete]
|
||||||
pending = PendingList(youtube_ids=vids)
|
PendingList(youtube_ids=vids).parse_url_list(status="ignore")
|
||||||
pending.parse_url_list()
|
|
||||||
_ = pending.add_to_pending(status="ignore")
|
|
||||||
|
|
||||||
def refresh_playlist(self) -> None:
|
def refresh_playlist(self) -> None:
|
||||||
"""match videos with playlists"""
|
"""match videos with playlists"""
|
||||||
|
|||||||
@@ -162,8 +162,7 @@ def extrac_dl(
|
|||||||
pending_handler = PendingList(
|
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
|
||||||
)
|
)
|
||||||
pending_handler.parse_url_list()
|
videos_added = pending_handler.parse_url_list(status=status)
|
||||||
videos_added = pending_handler.add_to_pending(status=status)
|
|
||||||
|
|
||||||
if auto_start:
|
if auto_start:
|
||||||
download_pending.delay(auto_only=True)
|
download_pending.delay(auto_only=True)
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ class VideoTypeEnum(enum.Enum):
|
|||||||
SHORTS = "shorts"
|
SHORTS = "shorts"
|
||||||
UNKNOWN = "unknown"
|
UNKNOWN = "unknown"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.value
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def values(cls) -> list[str]:
|
def values(cls) -> list[str]:
|
||||||
"""value list"""
|
"""value list"""
|
||||||
|
|||||||
Reference in New Issue
Block a user