mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-23 11:31:29 +01:00
Add forceurl and forcetitle downloader options
This commit is contained in:
parent
7414bdf11d
commit
05a84b35cc
14
youtube-dl
14
youtube-dl
|
@ -55,6 +55,8 @@ class FileDownloader(object):
|
||||||
password: Password for authentication purposes.
|
password: Password for authentication purposes.
|
||||||
usenetrc: Use netrc for authentication instead.
|
usenetrc: Use netrc for authentication instead.
|
||||||
quiet: Do not print messages to stdout.
|
quiet: Do not print messages to stdout.
|
||||||
|
forceurl: Force printing final URL.
|
||||||
|
forcetitle: Force printing title.
|
||||||
simulate: Do not download the video files.
|
simulate: Do not download the video files.
|
||||||
format: Video format code.
|
format: Video format code.
|
||||||
outtmpl: Template for output names.
|
outtmpl: Template for output names.
|
||||||
|
@ -174,10 +176,18 @@ class FileDownloader(object):
|
||||||
if len(results) > 1 and self.fixed_template():
|
if len(results) > 1 and self.fixed_template():
|
||||||
sys.exit('ERROR: fixed output name but more than one file to download')
|
sys.exit('ERROR: fixed output name but more than one file to download')
|
||||||
|
|
||||||
|
for result in results:
|
||||||
|
|
||||||
|
# Forced printings
|
||||||
|
if self._params.get('forcetitle', False):
|
||||||
|
print result['title']
|
||||||
|
if self._params.get('forceurl', False):
|
||||||
|
print result['url']
|
||||||
|
|
||||||
|
# Do nothing else if in simulate mode
|
||||||
if self._params.get('simulate', False):
|
if self._params.get('simulate', False):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for result in results:
|
|
||||||
try:
|
try:
|
||||||
filename = self._params['outtmpl'] % result
|
filename = self._params['outtmpl'] % result
|
||||||
except (ValueError, KeyError), err:
|
except (ValueError, KeyError), err:
|
||||||
|
@ -450,6 +460,8 @@ if __name__ == '__main__':
|
||||||
'username': None,
|
'username': None,
|
||||||
'password': None,
|
'password': None,
|
||||||
'quiet': False,
|
'quiet': False,
|
||||||
|
'forceurl': False,
|
||||||
|
'forcetitle': False,
|
||||||
'simulate': False,
|
'simulate': False,
|
||||||
'format': None,
|
'format': None,
|
||||||
'outtmpl': '%(ext)s/%(ext)s/%(id)s.%(ext)s'
|
'outtmpl': '%(ext)s/%(ext)s/%(id)s.%(ext)s'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user