mirror of
https://github.com/l1ving/youtube-dl
synced 2025-02-09 10:42:52 +08:00
Write all video metadata to directory to reduce redundant metadata reading from internet. Greatly speeds up subsequent youtube channel downloading for today's date only.
This commit is contained in:
parent
de0359c0af
commit
e3bcc40bf0
@ -788,9 +788,28 @@ class YoutubeDL(object):
|
|||||||
if not ie.working():
|
if not ie.working():
|
||||||
self.report_warning('The program functionality for this site has been marked as broken, '
|
self.report_warning('The program functionality for this site has been marked as broken, '
|
||||||
'and will probably not work.')
|
'and will probably not work.')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
if str(ie_key) == "Youtube":
|
||||||
|
video_metadata_directory = "/data/video_metadata"
|
||||||
|
# Check if we already have metadata downloaded for this file.
|
||||||
|
metadata_path = os.path.join(video_metadata_directory, str(ie_key) + "." + str(url))
|
||||||
|
if os.path.isfile(metadata_path):
|
||||||
|
with open(metadata_path, 'r') as content_file:
|
||||||
|
try:
|
||||||
|
ie_result = json.loads(content_file.read())
|
||||||
|
except:
|
||||||
ie_result = ie.extract(url)
|
ie_result = ie.extract(url)
|
||||||
|
else:
|
||||||
|
ie_result = ie.extract(url)
|
||||||
|
# Write the result here for future use.
|
||||||
|
with open(metadata_path, 'w') as content_file:
|
||||||
|
try:
|
||||||
|
content_file.write(json.dumps(ie_result,indent=4))
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
|
ie_result = ie.extract(url)
|
||||||
|
|
||||||
if ie_result is None: # Finished already (backwards compatibility; listformats and friends should be moved here)
|
if ie_result is None: # Finished already (backwards compatibility; listformats and friends should be moved here)
|
||||||
break
|
break
|
||||||
if isinstance(ie_result, list):
|
if isinstance(ie_result, list):
|
||||||
|
Loading…
Reference in New Issue
Block a user