Added --skip-empty-annotations to be used with write annotations. Will not save annotation if none exist in video
This commit is contained in:
parent
e1a0628797
commit
992c3b862a
@ -1,3 +1,4 @@
|
|||||||
|
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# coding: utf-8
|
# coding: utf-8
|
||||||
|
|
||||||
@ -314,6 +315,7 @@ class YoutubeDL(object):
|
|||||||
The following options are used by the Youtube extractor:
|
The following options are used by the Youtube extractor:
|
||||||
youtube_include_dash_manifest: If True (default), DASH manifests and related
|
youtube_include_dash_manifest: If True (default), DASH manifests and related
|
||||||
data will be downloaded and processed by extractor.
|
data will be downloaded and processed by extractor.
|
||||||
|
|
||||||
You can reduce network I/O by disabling it if you don't
|
You can reduce network I/O by disabling it if you don't
|
||||||
care about DASH.
|
care about DASH.
|
||||||
"""
|
"""
|
||||||
@ -1777,6 +1779,8 @@ class YoutubeDL(object):
|
|||||||
annofn = replace_extension(filename, 'annotations.xml', info_dict.get('ext'))
|
annofn = replace_extension(filename, 'annotations.xml', info_dict.get('ext'))
|
||||||
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(annofn)):
|
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(annofn)):
|
||||||
self.to_screen('[info] Video annotations are already present')
|
self.to_screen('[info] Video annotations are already present')
|
||||||
|
elif not '<annotation id=' in info_dict['annotations'] and self.params.get('writefullannotations', False):
|
||||||
|
self.to_screen('[info] Annotation file is empty. Skipping')
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
self.to_screen('[info] Writing video annotations to: ' + annofn)
|
self.to_screen('[info] Writing video annotations to: ' + annofn)
|
||||||
|
@ -365,6 +365,7 @@ def _real_main(argv=None):
|
|||||||
'nopart': opts.nopart,
|
'nopart': opts.nopart,
|
||||||
'updatetime': opts.updatetime,
|
'updatetime': opts.updatetime,
|
||||||
'writedescription': opts.writedescription,
|
'writedescription': opts.writedescription,
|
||||||
|
'writefullannotations': opts.writefullannotations,
|
||||||
'writeannotations': opts.writeannotations,
|
'writeannotations': opts.writeannotations,
|
||||||
'writeinfojson': opts.writeinfojson,
|
'writeinfojson': opts.writeinfojson,
|
||||||
'writethumbnail': opts.writethumbnail,
|
'writethumbnail': opts.writethumbnail,
|
||||||
|
@ -741,6 +741,10 @@ def parseOpts(overrideArguments=None):
|
|||||||
'--write-info-json',
|
'--write-info-json',
|
||||||
action='store_true', dest='writeinfojson', default=False,
|
action='store_true', dest='writeinfojson', default=False,
|
||||||
help='Write video metadata to a .info.json file')
|
help='Write video metadata to a .info.json file')
|
||||||
|
filesystem.add_option(
|
||||||
|
'--skip-empty-annotations',
|
||||||
|
action='store_true', dest='writefullannotations', default=False,
|
||||||
|
help='Used with --write-annotations. Will not save annotation file if there are no annotations')
|
||||||
filesystem.add_option(
|
filesystem.add_option(
|
||||||
'--write-annotations',
|
'--write-annotations',
|
||||||
action='store_true', dest='writeannotations', default=False,
|
action='store_true', dest='writeannotations', default=False,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user