projects
/
youtube-dl
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Give preference to format 34 before format 5 in quality list
[youtube-dl]
/
youtube-dl
diff --git
a/youtube-dl
b/youtube-dl
index 47c64658631ca9581ff62f344aca60595c398e49..10dd7c7916c990815c4c388211e1c17d709b1dce 100755
(executable)
--- a/
youtube-dl
+++ b/
youtube-dl
@@
-300,11
+300,15
@@
class FileDownloader(object):
self._pps.append(pp)
pp.set_downloader(self)
self._pps.append(pp)
pp.set_downloader(self)
- def to_stdout(self, message, skip_eol=False):
+ def to_stdout(self, message, skip_eol=False
, ignore_encoding_errors=False
):
"""Print message to stdout if not in quiet mode."""
"""Print message to stdout if not in quiet mode."""
- if not self.params.get('quiet', False):
- print (u'%s%s' % (message, [u'\n', u''][skip_eol])).encode(preferredencoding()),
+ try:
+ if not self.params.get('quiet', False):
+ print (u'%s%s' % (message, [u'\n', u''][skip_eol])).encode(preferredencoding()),
sys.stdout.flush()
sys.stdout.flush()
+ except (UnicodeEncodeError), err:
+ if not ignore_encoding_errors:
+ raise
def to_stderr(self, message):
"""Print message to stderr."""
def to_stderr(self, message):
"""Print message to stderr."""
@@
-342,7
+346,7
@@
class FileDownloader(object):
def report_destination(self, filename):
"""Report destination filename."""
def report_destination(self, filename):
"""Report destination filename."""
- self.to_stdout(u'[download] Destination: %s' % filename)
+ self.to_stdout(u'[download] Destination: %s' % filename
, ignore_encoding_errors=True
)
def report_progress(self, percent_str, data_len_str, speed_str, eta_str):
"""Report download progress."""
def report_progress(self, percent_str, data_len_str, speed_str, eta_str):
"""Report download progress."""
@@
-355,7
+359,10
@@
class FileDownloader(object):
def report_file_already_downloaded(self, file_name):
"""Report file has already been fully downloaded."""
def report_file_already_downloaded(self, file_name):
"""Report file has already been fully downloaded."""
- self.to_stdout(u'[download] %s has already been downloaded' % file_name)
+ try:
+ self.to_stdout(u'[download] %s has already been downloaded' % file_name)
+ except (UnicodeEncodeError), err:
+ self.to_stdout(u'[download] The file has already been downloaded')
def report_unable_to_resume(self):
"""Report it was impossible to resume download."""
def report_unable_to_resume(self):
"""Report it was impossible to resume download."""
@@
-629,7
+636,7
@@
class YoutubeIE(InfoExtractor):
_LOGIN_URL = 'http://www.youtube.com/signup?next=/&gl=US&hl=en'
_AGE_URL = 'http://www.youtube.com/verify_age?next_url=/&gl=US&hl=en'
_NETRC_MACHINE = 'youtube'
_LOGIN_URL = 'http://www.youtube.com/signup?next=/&gl=US&hl=en'
_AGE_URL = 'http://www.youtube.com/verify_age?next_url=/&gl=US&hl=en'
_NETRC_MACHINE = 'youtube'
- _available_formats = ['37', '22', '35', '18', '5', '17', '13', None] # listed in order of priority for -b flag
+ _available_formats = ['37', '22', '35', '18', '
34', '
5', '17', '13', None] # listed in order of priority for -b flag
_video_extensions = {
'13': '3gp',
'17': 'mp4',
_video_extensions = {
'13': '3gp',
'17': 'mp4',
@@
-1034,6
+1041,7
@@
class GoogleIE(InfoExtractor):
return
video_title = mobj.group(1).decode('utf-8')
video_title = sanitize_title(video_title)
return
video_title = mobj.group(1).decode('utf-8')
video_title = sanitize_title(video_title)
+ simple_title = re.sub(ur'(?u)([^%s]+)' % simple_title_chars, ur'_', video_title)
# Google Video doesn't show uploader nicknames?
video_uploader = 'NA'
# Google Video doesn't show uploader nicknames?
video_uploader = 'NA'
@@
-1045,7
+1053,7
@@
class GoogleIE(InfoExtractor):
'url': video_url.decode('utf-8'),
'uploader': video_uploader.decode('utf-8'),
'title': video_title,
'url': video_url.decode('utf-8'),
'uploader': video_uploader.decode('utf-8'),
'title': video_title,
- 'stitle':
video
_title,
+ 'stitle':
simple
_title,
'ext': video_extension.decode('utf-8'),
})
except UnavailableFormatError:
'ext': video_extension.decode('utf-8'),
})
except UnavailableFormatError:
@@
-1111,6
+1119,7
@@
class PhotobucketIE(InfoExtractor):
return
video_title = mobj.group(1).decode('utf-8')
video_title = sanitize_title(video_title)
return
video_title = mobj.group(1).decode('utf-8')
video_title = sanitize_title(video_title)
+ simple_title = re.sub(ur'(?u)([^%s]+)' % simple_title_chars, ur'_', video_title)
video_uploader = mobj.group(2).decode('utf-8')
video_uploader = mobj.group(2).decode('utf-8')
@@
-1121,7
+1130,7
@@
class PhotobucketIE(InfoExtractor):
'url': video_url.decode('utf-8'),
'uploader': video_uploader,
'title': video_title,
'url': video_url.decode('utf-8'),
'uploader': video_uploader,
'title': video_title,
- 'stitle':
video
_title,
+ 'stitle':
simple
_title,
'ext': video_extension.decode('utf-8'),
})
except UnavailableFormatError:
'ext': video_extension.decode('utf-8'),
})
except UnavailableFormatError:
@@
-1199,6
+1208,7
@@
class GenericIE(InfoExtractor):
return
video_title = mobj.group(1).decode('utf-8')
video_title = sanitize_title(video_title)
return
video_title = mobj.group(1).decode('utf-8')
video_title = sanitize_title(video_title)
+ simple_title = re.sub(ur'(?u)([^%s]+)' % simple_title_chars, ur'_', video_title)
# video uploader is domain name
mobj = re.match(r'(?:https?://)?([^/]*)/.*', url)
# video uploader is domain name
mobj = re.match(r'(?:https?://)?([^/]*)/.*', url)
@@
-1214,7
+1224,7
@@
class GenericIE(InfoExtractor):
'url': video_url.decode('utf-8'),
'uploader': video_uploader,
'title': video_title,
'url': video_url.decode('utf-8'),
'uploader': video_uploader,
'title': video_title,
- 'stitle':
video
_title,
+ 'stitle':
simple
_title,
'ext': video_extension.decode('utf-8'),
})
except UnavailableFormatError:
'ext': video_extension.decode('utf-8'),
})
except UnavailableFormatError:
@@
-1578,10
+1588,6
@@
if __name__ == '__main__':
sys.exit(u'ERROR: batch file could not be read')
all_urls = batchurls + args
sys.exit(u'ERROR: batch file could not be read')
all_urls = batchurls + args
- # Make sure all URLs are in our preferred encoding
- for i in range(0, len(all_urls)):
- all_urls[i] = unicode(all_urls[i], preferredencoding())
-
# Conflicting, missing and erroneous options
if opts.usenetrc and (opts.username is not None or opts.password is not None):
parser.error(u'using .netrc conflicts with giving username/password')
# Conflicting, missing and erroneous options
if opts.usenetrc and (opts.username is not None or opts.password is not None):
parser.error(u'using .netrc conflicts with giving username/password')