minor fixes to how we handle preset cookies
This commit is contained in:
parent
4966461cb4
commit
ce1d4991d7
2 changed files with 9 additions and 9 deletions
|
|
@ -140,11 +140,11 @@ class Download:
|
||||||
try:
|
try:
|
||||||
params = (
|
params = (
|
||||||
YTDLPOpts.get_instance()
|
YTDLPOpts.get_instance()
|
||||||
.preset(self.preset)
|
.preset(self.preset, with_cookies=not self.info.cookies)
|
||||||
.add({"break_on_existing": True})
|
.add({"break_on_existing": True})
|
||||||
.add_cli(self.info.cli, from_user=True)
|
.add_cli(args=self.info.cli, from_user=True)
|
||||||
.add(
|
.add(
|
||||||
{
|
config={
|
||||||
"color": "no_color",
|
"color": "no_color",
|
||||||
"paths": {
|
"paths": {
|
||||||
"home": self.download_dir,
|
"home": self.download_dir,
|
||||||
|
|
@ -218,7 +218,7 @@ class Download:
|
||||||
)
|
)
|
||||||
|
|
||||||
self.logger.info(
|
self.logger.info(
|
||||||
f'Task id="{self.info.id}" PID="{os.getpid()}" title="{self.info.title}" preset="{self.preset}" started.'
|
f'Task id="{self.info.id}" PID="{os.getpid()}" title="{self.info.title}" preset="{self.preset}" cookies="{bool(params.get("cookiefile"))}" started.'
|
||||||
)
|
)
|
||||||
|
|
||||||
self.logger.debug(f"Params before passing to yt-dlp. {params}")
|
self.logger.debug(f"Params before passing to yt-dlp. {params}")
|
||||||
|
|
|
||||||
|
|
@ -368,9 +368,6 @@ class DownloadQueue(metaclass=Singleton):
|
||||||
if _preset.template and not item.template:
|
if _preset.template and not item.template:
|
||||||
item.template = _preset.template
|
item.template = _preset.template
|
||||||
|
|
||||||
if _preset.cookies and not item.cookies:
|
|
||||||
item.cookies = _preset.cookies
|
|
||||||
|
|
||||||
yt_conf = {}
|
yt_conf = {}
|
||||||
cookie_file = os.path.join(self.config.temp_path, f"c_{uuid.uuid4().hex}.txt")
|
cookie_file = os.path.join(self.config.temp_path, f"c_{uuid.uuid4().hex}.txt")
|
||||||
|
|
||||||
|
|
@ -392,7 +389,10 @@ class DownloadQueue(metaclass=Singleton):
|
||||||
"func": lambda _, msg: logs.append(msg),
|
"func": lambda _, msg: logs.append(msg),
|
||||||
"level": logging.WARNING,
|
"level": logging.WARNING,
|
||||||
},
|
},
|
||||||
**YTDLPOpts.get_instance().preset(name=item.preset).add_cli(args=item.cli, from_user=True).get_all(),
|
**YTDLPOpts.get_instance()
|
||||||
|
.preset(name=item.preset, with_cookies=not item.cookies)
|
||||||
|
.add_cli(args=item.cli, from_user=True)
|
||||||
|
.get_all(),
|
||||||
}
|
}
|
||||||
|
|
||||||
downloaded, id_dict = self._is_downloaded(file=yt_conf.get("download_archive", None), url=item.url)
|
downloaded, id_dict = self._is_downloaded(file=yt_conf.get("download_archive", None), url=item.url)
|
||||||
|
|
@ -411,7 +411,7 @@ class DownloadQueue(metaclass=Singleton):
|
||||||
|
|
||||||
load_cookies(cookie_file)
|
load_cookies(cookie_file)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = f"Failed to create cookie file for '{self.info.id}: {self.info.title}'. '{e!s}'."
|
msg = f"Failed to create cookie file for '{item.url}'. '{e!s}'."
|
||||||
LOG.error(msg)
|
LOG.error(msg)
|
||||||
return {"status": "error", "msg": msg}
|
return {"status": "error", "msg": msg}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue