diff --git a/app/library/DownloadQueue.py b/app/library/DownloadQueue.py index efafa73f..274a247e 100644 --- a/app/library/DownloadQueue.py +++ b/app/library/DownloadQueue.py @@ -33,6 +33,7 @@ from .Utils import ( extract_info, extract_ytdlp_logs, load_cookies, + merge_dict, str_to_dt, ytdlp_reject, ) @@ -358,10 +359,15 @@ class DownloadQueue(metaclass=Singleton): if "thumbnail" not in etr and "youtube:" in entry.get("extractor", ""): extras["thumbnail"] = f"https://img.youtube.com/vi/{etr['id']}/maxresdefault.jpg" - return await self.add( - item=item.new_with(url=etr.get("url") or etr.get("webpage_url"), extras=extras), - already=already, - ) + newItem = item.new_with(url=etr.get("url") or etr.get("webpage_url"), extras=extras) + + if "formats" in etr and isinstance(etr["formats"], list) and len(etr["formats"]) > 0: + LOG.warning(f"Unexpected formats entries in --flat-playlist for {item_name}, treating as video.") + return await self._add_video( + entry=merge_dict(merge_dict({"_type": "video"}, etr), entry), item=newItem, logs=[] + ) + + return await self.add(item=newItem, already=already) finally: self.processors.release() diff --git a/app/library/Utils.py b/app/library/Utils.py index 1c34e34a..3781878e 100644 --- a/app/library/Utils.py +++ b/app/library/Utils.py @@ -373,7 +373,7 @@ def merge_dict( source: dict, destination: dict, max_depth: int = 50, max_list_size: int = 10000, _depth: int = 0, _seen: set = None ) -> dict: """ - Merge data from source into destination safely with protection against DoS attacks. + Merge data from source into destination. Args: source (dict): Source data