Merge branch 'master' into use-other-downloaders

Conflicts:
	youtube_dl/YoutubeDL.py
This commit is contained in:
Rogério Brito 2013-10-23 05:38:19 -02:00
commit f642efff00
5 changed files with 41 additions and 37 deletions

View File

@ -216,10 +216,10 @@ class YoutubeDL(object):
If stderr is a tty file the 'WARNING:' will be colored If stderr is a tty file the 'WARNING:' will be colored
''' '''
if sys.stderr.isatty() and os.name != 'nt': if sys.stderr.isatty() and os.name != 'nt':
_msg_header=u'\033[0;33mWARNING:\033[0m' _msg_header = u'\033[0;33mWARNING:\033[0m'
else: else:
_msg_header=u'WARNING:' _msg_header = u'WARNING:'
warning_message=u'%s %s' % (_msg_header,message) warning_message = u'%s %s' % (_msg_header, message)
self.to_stderr(warning_message) self.to_stderr(warning_message)
def report_error(self, message, tb=None): def report_error(self, message, tb=None):
@ -275,13 +275,15 @@ class YoutubeDL(object):
if template_dict['playlist_index'] is not None: if template_dict['playlist_index'] is not None:
template_dict['playlist_index'] = u'%05d' % template_dict['playlist_index'] template_dict['playlist_index'] = u'%05d' % template_dict['playlist_index']
sanitize = lambda k,v: sanitize_filename( sanitize = lambda k, v: sanitize_filename(
u'NA' if v is None else compat_str(v), u'NA' if v is None else compat_str(v),
restricted=self.params.get('restrictfilenames'), restricted=self.params.get('restrictfilenames'),
is_id=(k==u'id')) is_id=(k == u'id'))
template_dict = dict((k, sanitize(k, v)) for k,v in template_dict.items()) template_dict = dict((k, sanitize(k, v))
for k, v in template_dict.items())
filename = self.params['outtmpl'] % template_dict tmpl = os.path.expanduser(self.params['outtmpl'])
filename = tmpl % template_dict
return filename return filename
except KeyError as err: except KeyError as err:
self.report_error(u'Erroneous output template') self.report_error(u'Erroneous output template')
@ -406,8 +408,8 @@ class YoutubeDL(object):
self.to_screen(u"[%s] playlist '%s': Collected %d video ids (downloading %d of them)" % self.to_screen(u"[%s] playlist '%s': Collected %d video ids (downloading %d of them)" %
(ie_result['extractor'], playlist, n_all_entries, n_entries)) (ie_result['extractor'], playlist, n_all_entries, n_entries))
for i,entry in enumerate(entries,1): for i, entry in enumerate(entries, 1):
self.to_screen(u'[download] Downloading video #%s of %s' %(i, n_entries)) self.to_screen(u'[download] Downloading video #%s of %s' % (i, n_entries))
extra = { extra = {
'playlist': playlist, 'playlist': playlist,
'playlist_index': i + playliststart, 'playlist_index': i + playliststart,
@ -446,7 +448,7 @@ class YoutubeDL(object):
filter_f = lambda f: f['ext'] == format_spec filter_f = lambda f: f['ext'] == format_spec
else: else:
filter_f = lambda f: f['format_id'] == format_spec filter_f = lambda f: f['format_id'] == format_spec
matches = list(filter(filter_f ,available_formats)) matches = list(filter(filter_f, available_formats))
if matches: if matches:
return matches[-1] return matches[-1]
return None return None
@ -480,7 +482,7 @@ class YoutubeDL(object):
format['format'] = u'{id} - {res}{note}'.format( format['format'] = u'{id} - {res}{note}'.format(
id=format['format_id'], id=format['format_id'],
res=self.format_resolution(format), res=self.format_resolution(format),
note = u' ({})'.format(format['format_note']) if format.get('format_note') is not None else '', note=u' ({})'.format(format['format_note']) if format.get('format_note') is not None else '',
) )
if self.params.get('listformats', None): if self.params.get('listformats', None):
@ -642,7 +644,7 @@ class YoutubeDL(object):
infofn = filename + u'.info.json' infofn = filename + u'.info.json'
self.report_writeinfojson(infofn) self.report_writeinfojson(infofn)
try: try:
json_info_dict = dict((k, v) for k,v in info_dict.items() if not k in ['urlhandle']) json_info_dict = dict((k, v) for k, v in info_dict.items() if not k in ['urlhandle'])
write_json_file(json_info_dict, encodeFilename(infofn)) write_json_file(json_info_dict, encodeFilename(infofn))
except (OSError, IOError): except (OSError, IOError):
self.report_error(u'Cannot write metadata to JSON file ' + infofn) self.report_error(u'Cannot write metadata to JSON file ' + infofn)
@ -712,7 +714,7 @@ class YoutubeDL(object):
keep_video = None keep_video = None
for pp in self._pps: for pp in self._pps:
try: try:
keep_video_wish,new_info = pp.run(info) keep_video_wish, new_info = pp.run(info)
if keep_video_wish is not None: if keep_video_wish is not None:
if keep_video_wish: if keep_video_wish:
keep_video = keep_video_wish keep_video = keep_video_wish

View File

@ -220,7 +220,7 @@ class ArteTVCreativeIE(ArteTVPlus7IE):
u'url': u'http://creative.arte.tv/de/magazin/agentur-amateur-corporate-design', u'url': u'http://creative.arte.tv/de/magazin/agentur-amateur-corporate-design',
u'file': u'050489-002.mp4', u'file': u'050489-002.mp4',
u'info_dict': { u'info_dict': {
u'title': u'Agentur Amateur #2 - Corporate Design', u'title': u'Agentur Amateur / Agence Amateur #2 : Corporate Design',
}, },
} }

View File

@ -90,8 +90,8 @@ class NHLVideocenterIE(NHLBaseInfoExtractor):
r'{statusIndex:0,index:0,.*?id:(.*?),'], r'{statusIndex:0,index:0,.*?id:(.*?),'],
webpage, u'category id') webpage, u'category id')
playlist_title = self._html_search_regex( playlist_title = self._html_search_regex(
r'\?catid=%s">(.*?)</a>' % cat_id, r'tab0"[^>]*?>(.*?)</td>',
webpage, u'playlist title', flags=re.DOTALL) webpage, u'playlist title', flags=re.DOTALL).lower().capitalize()
data = compat_urllib_parse.urlencode({ data = compat_urllib_parse.urlencode({
'cid': cat_id, 'cid': cat_id,

View File

@ -236,11 +236,13 @@ class YoutubeIE(YoutubeBaseInfoExtractor, SubtitlesInfoExtractor):
'136': 'mp4', '136': 'mp4',
'137': 'mp4', '137': 'mp4',
'138': 'mp4', '138': 'mp4',
'139': 'mp4',
'140': 'mp4',
'141': 'mp4',
'160': 'mp4', '160': 'mp4',
# Dash mp4 audio
'139': 'm4a',
'140': 'm4a',
'141': 'm4a',
# Dash webm # Dash webm
'171': 'webm', '171': 'webm',
'172': 'webm', '172': 'webm',

View File

@ -1,2 +1,2 @@
__version__ = '2013.10.18.2' __version__ = '2013.10.23'