[youtube] Added argument --write-tags, that ads the list of tags to the end of the description file. Implies --write-description.
This commit is contained in:
parent
289bbb350e
commit
a90a1bd798
@ -150,6 +150,7 @@ class YoutubeDL(object):
|
|||||||
logger: Log messages to a logging.Logger instance.
|
logger: Log messages to a logging.Logger instance.
|
||||||
logtostderr: Log messages to stderr instead of stdout.
|
logtostderr: Log messages to stderr instead of stdout.
|
||||||
writedescription: Write the video description to a .description file
|
writedescription: Write the video description to a .description file
|
||||||
|
writetags: Write out the tags of the video to the bottom of the .description file.
|
||||||
writeinfojson: Write the video description to a .info.json file
|
writeinfojson: Write the video description to a .info.json file
|
||||||
writeannotations: Write the video annotations to a .annotations.xml file
|
writeannotations: Write the video annotations to a .annotations.xml file
|
||||||
writethumbnail: Write the thumbnail image to a file
|
writethumbnail: Write the thumbnail image to a file
|
||||||
@ -1291,7 +1292,7 @@ class YoutubeDL(object):
|
|||||||
self.report_error('unable to create directory ' + compat_str(err))
|
self.report_error('unable to create directory ' + compat_str(err))
|
||||||
return
|
return
|
||||||
|
|
||||||
if self.params.get('writedescription', False):
|
if self.params.get('writedescription', False) or (self.params.get('writetags', False) and 'tags' in info_dict):
|
||||||
descfn = replace_extension(filename, 'description', info_dict.get('ext'))
|
descfn = replace_extension(filename, 'description', info_dict.get('ext'))
|
||||||
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(descfn)):
|
if self.params.get('nooverwrites', False) and os.path.exists(encodeFilename(descfn)):
|
||||||
self.to_screen('[info] Video description is already present')
|
self.to_screen('[info] Video description is already present')
|
||||||
@ -1302,6 +1303,8 @@ class YoutubeDL(object):
|
|||||||
self.to_screen('[info] Writing video description to: ' + descfn)
|
self.to_screen('[info] Writing video description to: ' + descfn)
|
||||||
with io.open(encodeFilename(descfn), 'w', encoding='utf-8') as descfile:
|
with io.open(encodeFilename(descfn), 'w', encoding='utf-8') as descfile:
|
||||||
descfile.write(info_dict['description'])
|
descfile.write(info_dict['description'])
|
||||||
|
if self.params.get('writetags', False):
|
||||||
|
descfile.write("\nKeywords: %s\n" % (info_dict['tags'],))
|
||||||
except (OSError, IOError):
|
except (OSError, IOError):
|
||||||
self.report_error('Cannot write description file ' + descfn)
|
self.report_error('Cannot write description file ' + descfn)
|
||||||
return
|
return
|
||||||
|
@ -314,6 +314,7 @@ def _real_main(argv=None):
|
|||||||
'nopart': opts.nopart,
|
'nopart': opts.nopart,
|
||||||
'updatetime': opts.updatetime,
|
'updatetime': opts.updatetime,
|
||||||
'writedescription': opts.writedescription,
|
'writedescription': opts.writedescription,
|
||||||
|
'writetags': opts.writetags,
|
||||||
'writeannotations': opts.writeannotations,
|
'writeannotations': opts.writeannotations,
|
||||||
'writeinfojson': opts.writeinfojson,
|
'writeinfojson': opts.writeinfojson,
|
||||||
'writethumbnail': opts.writethumbnail,
|
'writethumbnail': opts.writethumbnail,
|
||||||
|
@ -1072,6 +1072,9 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
else:
|
else:
|
||||||
video_categories = None
|
video_categories = None
|
||||||
|
|
||||||
|
m = re.findall(r'''<meta(?:\s+[a-zA-Z0-9:._-]+(?:=[a-zA-Z0-9:._-]+|="[^"]+"|='[^']+'))*?\s+property=['"]?og:video:tag['"]?(?:\s+[a-zA-Z0-9:._-]+(?:=[a-zA-Z0-9:._-]+|="[^"]+"|='[^']+'))*?\s+content=['"]?([^>'"]+?)['"]?\s*>'''
|
||||||
|
, video_webpage, re.DOTALL | re.IGNORECASE);
|
||||||
|
video_tags = u", ".join(m)
|
||||||
# description
|
# description
|
||||||
video_description = get_element_by_id("eow-description", video_webpage)
|
video_description = get_element_by_id("eow-description", video_webpage)
|
||||||
if video_description:
|
if video_description:
|
||||||
@ -1259,6 +1262,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
'title': video_title,
|
'title': video_title,
|
||||||
'thumbnail': video_thumbnail,
|
'thumbnail': video_thumbnail,
|
||||||
'description': video_description,
|
'description': video_description,
|
||||||
|
'tags' : video_tags,
|
||||||
'categories': video_categories,
|
'categories': video_categories,
|
||||||
'subtitles': video_subtitles,
|
'subtitles': video_subtitles,
|
||||||
'automatic_captions': automatic_captions,
|
'automatic_captions': automatic_captions,
|
||||||
|
@ -635,6 +635,10 @@ def parseOpts(overrideArguments=None):
|
|||||||
'--write-description',
|
'--write-description',
|
||||||
action='store_true', dest='writedescription', default=False,
|
action='store_true', dest='writedescription', default=False,
|
||||||
help='Write video description to a .description file')
|
help='Write video description to a .description file')
|
||||||
|
filesystem.add_option(
|
||||||
|
'--write-tags',
|
||||||
|
action='store_true', dest='writetags', default=False,
|
||||||
|
help='Write out the tags of the video to the bottom of the .description file. Implies --write-description.')
|
||||||
filesystem.add_option(
|
filesystem.add_option(
|
||||||
'--write-info-json',
|
'--write-info-json',
|
||||||
action='store_true', dest='writeinfojson', default=False,
|
action='store_true', dest='writeinfojson', default=False,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user