aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-12-23 10:23:13 +0100
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-12-23 10:23:13 +0100
commitb3d9ef88ec55335db93601f4b2ec9ad30eca93ec (patch)
treea938d7c7521788ca22d8c65d51200d0c43299c61 /youtube_dl
parent8958b6916cdf8b30b347972b452136cb9fdab679 (diff)
downloadyoutube-dl-b3d9ef88ec55335db93601f4b2ec9ad30eca93ec.tar.xz
YoutubeDL: only set the ‘formats’ field of the info_dict if it was already set before
It caused a circular reference error, when trying to dump it to json (for example with the test video for myvideo.de or any other video without formats)
Diffstat (limited to 'youtube_dl')
-rw-r--r--youtube_dl/YoutubeDL.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py
index 04771c637..adeef23af 100644
--- a/youtube_dl/YoutubeDL.py
+++ b/youtube_dl/YoutubeDL.py
@@ -688,7 +688,12 @@ class YoutubeDL(object):
ext_ord)
formats = sorted(formats, key=_free_formats_key)
- info_dict['formats'] = formats
+ if formats[0] is not info_dict:
+ # only set the 'formats' fields if the original info_dict list them
+ # otherwise we end up with a circular reference, the first (and unique)
+ # element in the 'formats' field in info_dict is info_dict itself,
+ # wich can't be exported to json
+ info_dict['formats'] = formats
if self.params.get('listformats', None):
self.list_formats(info_dict)
return