0
0
Fork 0
mirror of https://github.com/yt-dlp/yt-dlp.git synced 2024-11-29 03:23:02 +00:00

[YoutubeDL] Do not require default output template to be set

This commit is contained in:
Philipp Hagemeister 2014-04-30 10:02:03 +02:00
parent b30b8698ea
commit acd69589a5
4 changed files with 12 additions and 6 deletions

View file

@ -31,6 +31,7 @@
ContentTooShortError, ContentTooShortError,
date_from_str, date_from_str,
DateRange, DateRange,
DEFAULT_OUTTMPL,
determine_ext, determine_ext,
DownloadError, DownloadError,
encodeFilename, encodeFilename,
@ -440,7 +441,8 @@ def prepare_filename(self, info_dict):
if v is not None) if v is not None)
template_dict = collections.defaultdict(lambda: 'NA', template_dict) template_dict = collections.defaultdict(lambda: 'NA', template_dict)
tmpl = os.path.expanduser(self.params['outtmpl']) outtmpl = self.params.get('outtmpl', DEFAULT_OUTTMPL)
tmpl = os.path.expanduser(outtmpl)
filename = tmpl % template_dict filename = tmpl % template_dict
return filename return filename
except ValueError as err: except ValueError as err:
@ -1025,10 +1027,11 @@ def dl(name, info):
def download(self, url_list): def download(self, url_list):
"""Download a given list of URLs.""" """Download a given list of URLs."""
outtmpl = self.params.get('outtmpl', DEFAULT_OUTTMPL)
if (len(url_list) > 1 and if (len(url_list) > 1 and
'%' not in self.params['outtmpl'] '%' not in outtmpl
and self.params.get('max_downloads') != 1): and self.params.get('max_downloads') != 1):
raise SameFileError(self.params['outtmpl']) raise SameFileError(outtmpl)
for url in url_list: for url in url_list:
try: try:

View file

@ -72,6 +72,7 @@
compat_getpass, compat_getpass,
compat_print, compat_print,
DateRange, DateRange,
DEFAULT_OUTTMPL,
decodeOption, decodeOption,
get_term_width, get_term_width,
DownloadError, DownloadError,
@ -705,7 +706,7 @@ def _real_main(argv=None):
or (opts.usetitle and u'%(title)s-%(id)s.%(ext)s') or (opts.usetitle and u'%(title)s-%(id)s.%(ext)s')
or (opts.useid and u'%(id)s.%(ext)s') or (opts.useid and u'%(id)s.%(ext)s')
or (opts.autonumber and u'%(autonumber)s-%(id)s.%(ext)s') or (opts.autonumber and u'%(autonumber)s-%(id)s.%(ext)s')
or u'%(title)s-%(id)s.%(ext)s') or DEFAULT_OUTTMPL)
if not os.path.splitext(outtmpl)[1] and opts.extractaudio: if not os.path.splitext(outtmpl)[1] and opts.extractaudio:
parser.error(u'Cannot download a video and extract audio into the same' parser.error(u'Cannot download a video and extract audio into the same'
u' file! Use "{0}.%(ext)s" instead of "{0}" as the output' u' file! Use "{0}.%(ext)s" instead of "{0}" as the output'

View file

@ -31,7 +31,7 @@ def _real_extract(self, url):
data = json.loads(self._html_search_regex( data = json.loads(self._html_search_regex(
r'window\.POST_DATA = { %s: ({.+?}) }' % video_id, webpage, 'vine data')) r'window\.POST_DATA = { %s: ({.+?}) }' % video_id, webpage, 'vine data'))
print(json.dumps(data, indent=2))
formats = [ formats = [
{ {
'url': data['videoLowURL'], 'url': data['videoLowURL'],

View file

@ -1423,3 +1423,5 @@ def q(qid):
return -1 return -1
return q return q
DEFAULT_OUTTMPL = '%(title)s-%(id)s.%(ext)s'