youtube-dl icon indicating copy to clipboard operation
youtube-dl copied to clipboard

--get-info-json: TypeError: Object of type function is not JSON serializable

Open Slider-Whistle opened this issue 3 years ago • 0 comments

Checklist

  • [ ] I'm reporting a broken site support issue
  • [x] I've verified that I'm running youtube-dl version 2020.12.14
  • [x] I've checked that all provided URLs are alive and playable in a browser
  • [x] I've checked that all URLs and arguments with special characters are properly quoted or escaped
  • [x] I've searched the bugtracker for similar bug reports including closed ones
  • [x] I've read bugs section in FAQ

Verbose log

python3.8 /home/houston/animelover1984-youtube-dl/youtube_dl/__main__.py -v --ignore-config -o "$HOME/Youtube Archives/%(uploader)s/%(upload_date)s %(title)s.%(ext)s" --netrc --write-thumbnail --write-annotations --write-sub --all-subs --write-info-json --get-comments --split-tracks https://www.youtube.com/watch?v=21iM7dSB6JU
[debug] System config: []
[debug] User config: []
[debug] Custom config: []
[debug] Command-line args: ['-v', '--ignore-config', '-o', '/home/houston/Youtube Archives/%(uploader)s/%(upload_date)s %(title)s.%(ext)s', '--netrc', '--write-thumbnail', '--write-annotations', '--write-sub', '--all-subs', '--write-info-json', '--get-comments', '--split-tracks', 'https://www.youtube.com/watch?v=21iM7dSB6JU']
[debug] Encodings: locale UTF-8, fs utf-8, out utf-8, pref UTF-8
[debug] youtube-dl version 2020.12.14
[debug] Git HEAD: 458e7fd52
[debug] Python version 3.8.10 (CPython) - Linux-5.12.0-gentoo-x86_64-x86_64-AMD_Ryzen_5_1600_Six-Core_Processor-with-glibc2.2.5
[debug] exe versions: ffmpeg 4.4, ffprobe 4.4
[debug] Proxy map: {}
[youtube] Downloading login page
[youtube] Looking up account info
WARNING: Unable to look up account info: HTTP Error 400: Bad Request
[youtube] 21iM7dSB6JU: Downloading webpage
[debug] Default format spec: bestvideo+bestaudio/best
WARNING: There are no annotations to write.
[info] Writing video description metadata as JSON to: /home/houston/Youtube Archives/garrrzzz/20140216 DDS - Megami Tensei - Piano arrangement medley.info.json
Traceback (most recent call last):
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/__main__.py", line 19, in <module>
    youtube_dl.main()
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/__init__.py", line 482, in main
    _real_main(argv)
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/__init__.py", line 472, in _real_main
    retcode = ydl.download(all_urls)
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/YoutubeDL.py", line 2054, in download
    res = self.extract_info(
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/YoutubeDL.py", line 797, in extract_info
    return self.__extract_info(url, ie, download, extra_info, process)
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/YoutubeDL.py", line 804, in wrapper
    return func(self, *args, **kwargs)
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/YoutubeDL.py", line 836, in __extract_info
    return self.process_ie_result(ie_result, download, extra_info)
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/YoutubeDL.py", line 870, in process_ie_result
    return self.process_video_result(ie_result, download=download)
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/YoutubeDL.py", line 1680, in process_video_result
    self.process_info(new_info)
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/YoutubeDL.py", line 1886, in process_info
    write_json_file(self.filter_requested_info(info_dict), infofn)
  File "/home/houston/animelover1984-youtube-dl/youtube_dl/utils.py", line 1832, in write_json_file
    json.dump(obj, tf)
  File "/usr/lib/python3.8/json/__init__.py", line 179, in dump
    for chunk in iterable:
  File "/usr/lib/python3.8/json/encoder.py", line 431, in _iterencode
    yield from _iterencode_dict(o, _current_indent_level)
  File "/usr/lib/python3.8/json/encoder.py", line 405, in _iterencode_dict
    yield from chunks
  File "/usr/lib/python3.8/json/encoder.py", line 438, in _iterencode
    o = _default(o)
  File "/usr/lib/python3.8/json/encoder.py", line 179, in default
    raise TypeError(f'Object of type {o.__class__.__name__} '
TypeError: Object of type function is not JSON serializable

Description

This fork of youtube-dl appears to crash whenever I give it either the arguments --write-description, or --write-info-json, which appears to imply write-description all the same. Since write-info-json appears to be necessary for writing comments, this is a somewhat serious issue, at least if it's reproducible. Have tested using python 3.7 as well, output is similar to above. If there's a workaround that involves passing the write-info-json argument in a way that doesn't put the description inside the json, that would also be appreciated. Don't get this bug in normal youtube-dl. I was wondering whether there may be some kind of upstream fix that's failed to get applied, but couldn't find anything searching their issues/PR's.

Thanks for your time.

Slider-Whistle avatar May 30 '21 07:05 Slider-Whistle