XML generation fails if no thumbnail included in video
NePoCz opened this issue · comments
Hi, just started using your tool and seems to work fine for youtube feeds. But then I supplied an RSS feed and the videos download fine, but the xml is not generated. Would it be possible to proceed, even if no thumbnail is included with some videos? I think this should not be a fatal error, or even custom fallback thumbnail path could be selected
I get the following error:
Traceback (most recent call last):
File "/home/xxx/.local/bin/ydl-podcast", line 8, in <module>
sys.exit(main())
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__main__.py", line 61, in main
write_xml(sub)
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__init__.py", line 246, in write_xml
md = metadata_parse(md_file)
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__init__.py", line 47, in metadata_parse
thumb_ext = mdjs["thumbnail"].split(".")[-1]
KeyError: 'thumbnail'
Thanks I will have a look! Do you have an example link I can try with?
Wow, thanks for having a look so quickly! I tried the new version, but still get errors. Tested it a bit and here is what I observed:
(example video link here)
With fresh config/download location, so no "residues" from past runs:
Traceback (most recent call last):
File "/home/xxx/.local/bin/ydl-podcast", line 8, in <module>
sys.exit(main())
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__main__.py", line 61, in main
write_xml(sub)
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__init__.py", line 236, in write_xml
mds = [metadata_parse(md_file) for md_file in glob.glob(os.path.join(sub["output_dir"], "%s/*.info.json" % sub["name"]))]
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__init__.py", line 236, in <listcomp>
mds = [metadata_parse(md_file) for md_file in glob.glob(os.path.join(sub["output_dir"], "%s/*.info.json" % sub["name"]))]
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__init__.py", line 59, in metadata_parse
if f.name.startswith(basename) and ext not in [thumb_ext, "json"]:
UnboundLocalError: local variable 'thumb_ext' referenced before assignment
Editing __init__.py and hard-coding some arbitrary thumb_ext value inside the function got me past this, but only to get the following error:
Traceback (most recent call last):
File "/home/xxx/.local/bin/ydl-podcast", line 8, in <module>
sys.exit(main())
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__main__.py", line 61, in main
write_xml(sub)
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__init__.py", line 236, in write_xml
mds = [metadata_parse(md_file) for md_file in glob.glob(os.path.join(sub["output_dir"], "%s/*.info.json" % sub["name"]))]
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__init__.py", line 236, in <listcomp>
mds = [metadata_parse(md_file) for md_file in glob.glob(os.path.join(sub["output_dir"], "%s/*.info.json" % sub["name"]))]
File "/home/xxx/.local/lib/python3.9/site-packages/ydl_podcast/__init__.py", line 69, in metadata_parse
"description": mdjs["description"],
KeyError: 'description'
And once I hard-coded some value to description as well, I got the same error about duration. Hard-coding duration finally produced a valid XML.
Seems I picked a tricky video 😉 But generally looks like some fall-back values/placeholders are required since many audio/video files will have missing metadata.
Let me know if I can help anyhow.
Thanks a bunch for the feedback!!
I think you should be good to go now :)
Thanks again for the quick update. The description & duration errors seem to be solved, but the thumb_ext UnboundLocalError is still there.