diff options
Diffstat (limited to 'youtube_dlc/YoutubeDL.py')
-rw-r--r-- | youtube_dlc/YoutubeDL.py | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/youtube_dlc/YoutubeDL.py b/youtube_dlc/YoutubeDL.py index 41386a778..bf57d4765 100644 --- a/youtube_dlc/YoutubeDL.py +++ b/youtube_dlc/YoutubeDL.py @@ -202,6 +202,8 @@ class YoutubeDL(object): logtostderr: Log messages to stderr instead of stdout. writedescription: Write the video description to a .description file writeinfojson: Write the video description to a .info.json file + writecomments: Extract video comments. This will not be written to disk + unless writeinfojson is also given writeannotations: Write the video annotations to a .annotations.xml file writethumbnail: Write the thumbnail image to a file write_all_thumbnails: Write all thumbnail formats to files @@ -930,9 +932,7 @@ class YoutubeDL(object): self.to_screen("[%s] %s: has already been recorded in archive" % ( ie_key, temp_id)) break - return self.__extract_info(url, ie, download, extra_info, process, info_dict) - else: self.report_error('no suitable InfoExtractor for URL %s' % url) @@ -1101,6 +1101,21 @@ class YoutubeDL(object): playlist = ie_result.get('title') or ie_result.get('id') self.to_screen('[download] Downloading playlist: %s' % playlist) + if self.params.get('writeinfojson', False): + infofn = replace_extension( + self.prepare_filepath(self.prepare_filename(ie_result), 'infojson'), + 'info.json', ie_result.get('ext')) + if self.params.get('overwrites', True) and os.path.exists(encodeFilename(infofn)): + self.to_screen('[info] Playlist description metadata is already present') + else: + self.to_screen('[info] Writing description playlist metadata as JSON to: ' + infofn) + playlist_info = dict(ie_result) + playlist_info.pop('entries') + try: + write_json_file(self.filter_requested_info(playlist_info), infofn) + except (OSError, IOError): + self.report_error('Cannot write playlist description metadata to JSON file ' + infofn) + playlist_results = [] playliststart = self.params.get('playliststart', 1) - 1 @@ -2105,6 +2120,7 @@ class YoutubeDL(object): except (OSError, IOError): self.report_error('Cannot write metadata to JSON file ' + infofn) return + info_dict['__infojson_filepath'] = infofn thumbdir = os.path.dirname(self.prepare_filepath(filename, 'thumbnail')) for thumbfn in self._write_thumbnails(info_dict, temp_filename): |