aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2013-05-09 16:52:54 -0700
committerPhilipp Hagemeister <phihag@phihag.de>2013-05-09 16:52:54 -0700
commitb08980412eb05250100f95bf2c2c8bb764c4b4c5 (patch)
treec6ab492655a41c2d518e86841d6f3f39ce020028
parent532a1e042964e698610908a0c3fde5188dce8f26 (diff)
parent1a2adf3f49c700acc75c6b284927e61881bd7ea6 (diff)
downloadyoutube-dl-b08980412eb05250100f95bf2c2c8bb764c4b4c5.tar.xz
Merge pull request #826 from jakeogh/master
Added --get-id option to print video IDs
-rw-r--r--README.md1
-rw-r--r--youtube_dl/FileDownloader.py3
-rw-r--r--youtube_dl/__init__.py7
3 files changed, 9 insertions, 2 deletions
diff --git a/README.md b/README.md
index c95201c3f..a9eaed192 100644
--- a/README.md
+++ b/README.md
@@ -94,6 +94,7 @@ which means you can modify it, redistribute it or use it however you like.
--skip-download do not download the video
-g, --get-url simulate, quiet but print URL
-e, --get-title simulate, quiet but print title
+ --get-id simulate, quiet but print id
--get-thumbnail simulate, quiet but print thumbnail URL
--get-description simulate, quiet but print video description
--get-filename simulate, quiet but print output filename
diff --git a/youtube_dl/FileDownloader.py b/youtube_dl/FileDownloader.py
index 9b06633cc..eb68d9478 100644
--- a/youtube_dl/FileDownloader.py
+++ b/youtube_dl/FileDownloader.py
@@ -54,6 +54,7 @@ class FileDownloader(object):
quiet: Do not print messages to stdout.
forceurl: Force printing final URL.
forcetitle: Force printing title.
+ forceid: Force printing ID.
forcethumbnail: Force printing thumbnail URL.
forcedescription: Force printing description.
forcefilename: Force printing final filename.
@@ -574,6 +575,8 @@ class FileDownloader(object):
# Forced printings
if self.params.get('forcetitle', False):
compat_print(info_dict['title'])
+ if self.params.get('forceid', False):
+ compat_print(info_dict['id'])
if self.params.get('forceurl', False):
compat_print(info_dict['url'])
if self.params.get('forcethumbnail', False) and 'thumbnail' in info_dict:
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 1fc2fbcb4..80f3b9f33 100644
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -216,6 +216,8 @@ def parseOpts(overrideArguments=None):
action='store_true', dest='geturl', help='simulate, quiet but print URL', default=False)
verbosity.add_option('-e', '--get-title',
action='store_true', dest='gettitle', help='simulate, quiet but print title', default=False)
+ verbosity.add_option('--get-id',
+ action='store_true', dest='getid', help='simulate, quiet but print id', default=False)
verbosity.add_option('--get-thumbnail',
action='store_true', dest='getthumbnail',
help='simulate, quiet but print thumbnail URL', default=False)
@@ -495,15 +497,16 @@ def _real_main(argv=None):
'usenetrc': opts.usenetrc,
'username': opts.username,
'password': opts.password,
- 'quiet': (opts.quiet or opts.geturl or opts.gettitle or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat),
+ 'quiet': (opts.quiet or opts.geturl or opts.gettitle or opts.getid or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat),
'forceurl': opts.geturl,
'forcetitle': opts.gettitle,
+ 'forceid': opts.getid,
'forcethumbnail': opts.getthumbnail,
'forcedescription': opts.getdescription,
'forcefilename': opts.getfilename,
'forceformat': opts.getformat,
'simulate': opts.simulate,
- 'skip_download': (opts.skip_download or opts.simulate or opts.geturl or opts.gettitle or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat),
+ 'skip_download': (opts.skip_download or opts.simulate or opts.geturl or opts.gettitle or opts.getid or opts.getthumbnail or opts.getdescription or opts.getfilename or opts.getformat),
'format': opts.format,
'format_limit': opts.format_limit,
'listformats': opts.listformats,