From 8011b980a29bcfb1d78131ff96c773996bb414ab Mon Sep 17 00:00:00 2001 From: Jesse Bannon Date: Sat, 17 Feb 2024 09:25:50 -0800 Subject: [PATCH] [BUGFIX] Handle case when yt-dlp returns LazyList --- src/ytdl_sub/entries/base_entry.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ytdl_sub/entries/base_entry.py b/src/ytdl_sub/entries/base_entry.py index 1d8acd3e..f6a774a5 100644 --- a/src/ytdl_sub/entries/base_entry.py +++ b/src/ytdl_sub/entries/base_entry.py @@ -8,7 +8,7 @@ from typing import Type from typing import TypeVar from typing import final -from yt_dlp.utils import sanitize_filename +from yt_dlp.utils import sanitize_filename, LazyList from ytdl_sub.entries.script.variable_definitions import VARIABLES from ytdl_sub.entries.script.variable_definitions import VariableDefinitions @@ -37,6 +37,12 @@ class BaseEntry(ABC): self._working_directory = working_directory self._kwargs = entry_dict + # Sometimes yt-dlp can return a LazyList which is not JSON serializable. + # Cast it to a native list here. (https://github.com/jmbannon/ytdl-sub/issues/910) + for key in self._kwargs.keys(): + if isinstance(self._kwargs[key], LazyList): + self._kwargs[key] = list(self._kwargs[key]) + @property def uid(self) -> str: """