[BUGFIX] Handle case when yt-dlp returns LazyList (#929)

Fixes https://github.com/jmbannon/ytdl-sub/issues/910 , when yt-dlp sometimes returns a non-serializable LazyList
This commit is contained in:
Jesse Bannon 2024-02-17 09:51:21 -08:00 committed by GitHub
parent 248e9a15a6
commit f346b0ef52
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -8,6 +8,7 @@ from typing import Type
from typing import TypeVar
from typing import final
from yt_dlp.utils import LazyList
from yt_dlp.utils import sanitize_filename
from ytdl_sub.entries.script.variable_definitions import VARIABLES
@ -37,6 +38,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:
"""