Fix: some extractors dont support --flat-playlist, so expand support to cover them
This commit is contained in:
parent
2ae5f7e3c8
commit
9ba68dcfaf
1 changed files with 27 additions and 25 deletions
|
|
@ -373,11 +373,12 @@ class DownloadQueue(metaclass=Singleton):
|
||||||
|
|
||||||
newItem: Item = item.new_with(url=etr.get("url") or etr.get("webpage_url"), extras=extras)
|
newItem: Item = 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:
|
if ("video" == etr.get("_type") and etr.get("url")) or (
|
||||||
LOG.warning(f"Unexpected formats entries in --flat-playlist for {item_name}, treating as video.")
|
"formats" in etr and isinstance(etr["formats"], list) and len(etr["formats"]) > 0
|
||||||
return await self._add_video(
|
):
|
||||||
entry=merge_dict(merge_dict({"_type": "video"}, etr), entry), item=newItem, logs=[]
|
dct = merge_dict(merge_dict({"_type": "video"}, etr), entry)
|
||||||
)
|
dct.pop("entries", None)
|
||||||
|
return await self.add(item=newItem, entry=dct, already=already)
|
||||||
|
|
||||||
return await self.add(item=newItem, already=already)
|
return await self.add(item=newItem, already=already)
|
||||||
finally:
|
finally:
|
||||||
|
|
@ -651,13 +652,14 @@ class DownloadQueue(metaclass=Singleton):
|
||||||
|
|
||||||
return {"status": "error", "msg": f'Unsupported event type "{event_type}".'}
|
return {"status": "error", "msg": f'Unsupported event type "{event_type}".'}
|
||||||
|
|
||||||
async def add(self, item: Item, already: set | None = None):
|
async def add(self, item: Item, already: set | None = None, entry: dict | None = None) -> dict[str, str]:
|
||||||
"""
|
"""
|
||||||
Add an item to the download queue.
|
Add an item to the download queue.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
item (Item): The item to be added to the queue.
|
item (Item): The item to be added to the queue.
|
||||||
already (set): Set of already downloaded items.
|
already (set): Set of already downloaded items.
|
||||||
|
entry (dict): The entry associated with the item.
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
dict[str, str]: The status of the download.
|
dict[str, str]: The status of the download.
|
||||||
|
|
@ -683,7 +685,7 @@ class DownloadQueue(metaclass=Singleton):
|
||||||
yt_conf = {}
|
yt_conf = {}
|
||||||
cookie_file: Path = Path(self.config.temp_path) / f"c_{uuid.uuid4().hex}.txt"
|
cookie_file: Path = Path(self.config.temp_path) / f"c_{uuid.uuid4().hex}.txt"
|
||||||
|
|
||||||
LOG.info(f"Adding '{item.__repr__()}'.")
|
LOG.info(f"Adding '{item!r}'.")
|
||||||
|
|
||||||
already = set() if already is None else already
|
already = set() if already is None else already
|
||||||
|
|
||||||
|
|
@ -709,7 +711,7 @@ class DownloadQueue(metaclass=Singleton):
|
||||||
LOG.warning(f"Using external downloader '{yt_conf.get('external_downloader')}' for '{item.url}'.")
|
LOG.warning(f"Using external downloader '{yt_conf.get('external_downloader')}' for '{item.url}'.")
|
||||||
item.extras.update({"external_downloader": True})
|
item.extras.update({"external_downloader": True})
|
||||||
|
|
||||||
archive_id = item.get_archive_id()
|
archive_id: str | None = item.get_archive_id()
|
||||||
|
|
||||||
if item.is_archived():
|
if item.is_archived():
|
||||||
if archive_id:
|
if archive_id:
|
||||||
|
|
@ -744,12 +746,11 @@ class DownloadQueue(metaclass=Singleton):
|
||||||
return {"status": "ok"}
|
return {"status": "ok"}
|
||||||
|
|
||||||
message: str = f"The URL '{item.url}' is already downloaded and recorded in archive."
|
message: str = f"The URL '{item.url}' is already downloaded and recorded in archive."
|
||||||
LOG.error(message)
|
LOG.warning(message)
|
||||||
self._notify.emit(
|
self._notify.emit(
|
||||||
Events.LOG_INFO, data={"preset": item.preset}, title="Already Downloaded", message=message
|
Events.LOG_INFO, data={"preset": item.preset}, title="Already Downloaded", message=message
|
||||||
)
|
)
|
||||||
|
return {"status": "error", "msg": message, "hidden": True}
|
||||||
return {"status": "error", "msg": message}
|
|
||||||
|
|
||||||
started: float = time.perf_counter()
|
started: float = time.perf_counter()
|
||||||
|
|
||||||
|
|
@ -761,22 +762,23 @@ class DownloadQueue(metaclass=Singleton):
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
return {"status": "error", "msg": msg}
|
return {"status": "error", "msg": msg}
|
||||||
|
|
||||||
LOG.info(f"Checking '{item.url}' with {'cookies' if yt_conf.get('cookiefile') else 'no cookies'}.")
|
LOG.info(f"Extracting '{item.url}' with {'cookies' if yt_conf.get('cookiefile') else ''}.")
|
||||||
|
|
||||||
entry: dict | None = await asyncio.wait_for(
|
if not entry:
|
||||||
fut=asyncio.get_running_loop().run_in_executor(
|
entry: dict | None = await asyncio.wait_for(
|
||||||
None,
|
fut=asyncio.get_running_loop().run_in_executor(
|
||||||
functools.partial(
|
None,
|
||||||
extract_info,
|
functools.partial(
|
||||||
config=yt_conf,
|
extract_info,
|
||||||
url=item.url,
|
config=yt_conf,
|
||||||
debug=bool(self.config.ytdlp_debug),
|
url=item.url,
|
||||||
no_archive=False,
|
debug=bool(self.config.ytdlp_debug),
|
||||||
follow_redirect=True,
|
no_archive=False,
|
||||||
|
follow_redirect=True,
|
||||||
|
),
|
||||||
),
|
),
|
||||||
),
|
timeout=self.config.extract_info_timeout,
|
||||||
timeout=self.config.extract_info_timeout,
|
)
|
||||||
)
|
|
||||||
|
|
||||||
if not entry:
|
if not entry:
|
||||||
LOG.error(f"Unable to extract info for '{item.url}'. Logs: {logs}")
|
LOG.error(f"Unable to extract info for '{item.url}'. Logs: {logs}")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue