rssVideos: Handle corrupt metadata better

This commit is contained in:
Geoffrey Frogeye 2024-10-01 14:35:40 +02:00
parent dee90d9a96
commit 6618fbee9d
Signed by: geoffrey
GPG key ID: C72403E7F82E6AD8

View file

@ -1,6 +1,6 @@
#!/usr/bin/env nix-shell #!/usr/bin/env nix-shell
#! nix-shell -i python3 #! 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 # 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]: def ytdl_infos(self) -> typing.Optional[dict]:
try: try:
return self.metafile_read("ytdl") return self.metafile_read("ytdl")
# If the metafile doesn't exist or is corrupted
except (FileNotFoundError, TypeError, AttributeError, EOFError): 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() infos = self._ytdl_infos()
self.metafile_write("ytdl", infos) self.metafile_write("ytdl", infos)
return infos return infos