From 6618fbee9d330619a321d135f1846f4c1b643ebe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Tue, 1 Oct 2024 14:35:40 +0200 Subject: [PATCH] rssVideos: Handle corrupt metadata better --- hm/scripts/rssVideos | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hm/scripts/rssVideos b/hm/scripts/rssVideos index 9b1401c..6cbefd3 100755 --- a/hm/scripts/rssVideos +++ b/hm/scripts/rssVideos @@ -1,6 +1,6 @@ #!/usr/bin/env nix-shell #! nix-shell -i python3 -#! nix-shell -p python3 python3Packages.coloredlogs python3Packages.configargparse python3Packages.filelock python3Packages.filelock python3Packages.requests python3Packages.yt-dlp ffmpeg +#! nix-shell -p python3 python3Packages.coloredlogs python3Packages.configargparse python3Packages.filelock python3Packages.requests python3Packages.yt-dlp ffmpeg # Also needs mpv but if I put it there it's not using the configured one @@ -189,7 +189,13 @@ class RVElement: def ytdl_infos(self) -> typing.Optional[dict]: try: return self.metafile_read("ytdl") + # If the metafile doesn't exist or is corrupted except (FileNotFoundError, TypeError, AttributeError, EOFError): + # Delete file otherwise __str__ won't be happy + metafile = self.metafile("ytdl") + if os.path.isfile(metafile): + os.unlink(metafile) + infos = self._ytdl_infos() self.metafile_write("ytdl", infos) return infos