diff options
author | pukkandan <pukkandan@gmail.com> | 2021-02-28 20:26:08 +0530 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-28 20:26:08 +0530 |
commit | 277d6ff5f2bd4f142429def30d01df264eb7c922 (patch) | |
tree | 1ffa4fe83c33aef1f82e1e339cc59c46139ca0ac /yt_dlp/YoutubeDL.py | |
parent | 1cf376f55a3d9335eb161c07c439ca143d86924e (diff) | |
download | hypervideo-pre-277d6ff5f2bd4f142429def30d01df264eb7c922.tar.lz hypervideo-pre-277d6ff5f2bd4f142429def30d01df264eb7c922.tar.xz hypervideo-pre-277d6ff5f2bd4f142429def30d01df264eb7c922.zip |
Extract comments only when needed #95 (Closes #94)
Diffstat (limited to 'yt_dlp/YoutubeDL.py')
-rw-r--r-- | yt_dlp/YoutubeDL.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index 3c53f4cd8..e9cb7e187 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -2041,6 +2041,7 @@ class YoutubeDL(object): self.to_stdout(formatSeconds(info_dict['duration'])) print_mandatory('format') if self.params.get('forcejson', False): + self.post_extract(info_dict) self.to_stdout(json.dumps(info_dict)) def process_info(self, info_dict): @@ -2064,6 +2065,7 @@ class YoutubeDL(object): if self._match_entry(info_dict, incomplete=False) is not None: return + self.post_extract(info_dict) self._num_downloads += 1 info_dict = self.pre_process(info_dict) @@ -2497,6 +2499,7 @@ class YoutubeDL(object): raise else: if self.params.get('dump_single_json', False): + self.post_extract(res) self.to_stdout(json.dumps(res)) return self._download_retcode @@ -2545,6 +2548,24 @@ class YoutubeDL(object): del files_to_move[old_filename] return files_to_move, infodict + @staticmethod + def post_extract(info_dict): + def actual_post_extract(info_dict): + if info_dict.get('_type') in ('playlist', 'multi_video'): + for video_dict in info_dict.get('entries', {}): + actual_post_extract(video_dict) + return + + if '__post_extractor' not in info_dict: + return + post_extractor = info_dict['__post_extractor'] + if post_extractor: + info_dict.update(post_extractor().items()) + del info_dict['__post_extractor'] + return + + actual_post_extract(info_dict) + def pre_process(self, ie_info): info = dict(ie_info) for pp in self._pps['beforedl']: |