Compare commits

...

3 Commits

Author SHA1 Message Date
Abdulmohsen
b3bec455c5
Merge d3aec35e5b into 52c0ffe40a 2024-11-17 09:50:31 +05:30
ArabCoders
d3aec35e5b implemented requested changes 2024-03-16 22:16:11 +03:00
ArabCoders
395d2793aa Added method to download using already extracted info 2024-03-16 18:36:13 +03:00

View File

@ -3606,13 +3606,10 @@ class YoutubeDL:
return self._download_retcode return self._download_retcode
def download_with_info_file(self, info_filename): def download_with_info(self, *info_list):
with contextlib.closing(fileinput.FileInput( """Download using already extracted info_dicts."""
[info_filename], mode='r', infos = [self.sanitize_info(info, self.params.get('clean_infojson', True))
openhook=fileinput.hook_encoded('utf-8'))) as f: for info in info_list]
# FileInput doesn't have a read method, we can't call json.load
infos = [self.sanitize_info(info, self.params.get('clean_infojson', True))
for info in variadic(json.loads('\n'.join(f)))]
for info in infos: for info in infos:
try: try:
self.__download_wrapper(self.process_ie_result)(info, download=True) self.__download_wrapper(self.process_ie_result)(info, download=True)
@ -3628,6 +3625,15 @@ class YoutubeDL:
self.report_error(e) self.report_error(e)
return self._download_retcode return self._download_retcode
def download_with_info_file(self, info_filename):
"""Download using an info file."""
with contextlib.closing(fileinput.FileInput(
[info_filename], mode='r',
openhook=fileinput.hook_encoded('utf-8'))) as f:
# FileInput doesn't have a read method, we can't call json.load
infos = [info for info in variadic(json.loads('\n'.join(f)))]
return self.download_with_info(infos)
@staticmethod @staticmethod
def sanitize_info(info_dict, remove_private_keys=False): def sanitize_info(info_dict, remove_private_keys=False):
""" Sanitize the infodict for converting to json """ """ Sanitize the infodict for converting to json """