mirror of
https://github.com/l1ving/youtube-dl
synced 2024-11-22 06:49:31 +08:00
Add a resolution field and improve general --list-formats output
This commit is contained in:
parent
dabc127362
commit
f49d89ee04
@ -1007,13 +1007,15 @@ class YoutubeDL(object):
|
|||||||
def format_resolution(format, default='unknown'):
|
def format_resolution(format, default='unknown'):
|
||||||
if format.get('vcodec') == 'none':
|
if format.get('vcodec') == 'none':
|
||||||
return 'audio only'
|
return 'audio only'
|
||||||
if format.get('_resolution') is not None:
|
if format.get('resolution') is not None:
|
||||||
return format['_resolution']
|
return format['resolution']
|
||||||
if format.get('height') is not None:
|
if format.get('height') is not None:
|
||||||
if format.get('width') is not None:
|
if format.get('width') is not None:
|
||||||
res = u'%sx%s' % (format['width'], format['height'])
|
res = u'%sx%s' % (format['width'], format['height'])
|
||||||
else:
|
else:
|
||||||
res = u'%sp' % format['height']
|
res = u'%sp' % format['height']
|
||||||
|
elif format.get('width') is not None:
|
||||||
|
res = u'?x%d' % format['width']
|
||||||
else:
|
else:
|
||||||
res = default
|
res = default
|
||||||
return res
|
return res
|
||||||
@ -1025,11 +1027,11 @@ class YoutubeDL(object):
|
|||||||
res += fdict['format_note'] + u' '
|
res += fdict['format_note'] + u' '
|
||||||
if (fdict.get('vcodec') is not None and
|
if (fdict.get('vcodec') is not None and
|
||||||
fdict.get('vcodec') != 'none'):
|
fdict.get('vcodec') != 'none'):
|
||||||
res += u'%-5s' % fdict['vcodec']
|
res += u'%-5s@' % fdict['vcodec']
|
||||||
elif fdict.get('vbr') is not None:
|
elif fdict.get('vbr') is not None and fdict.get('abr') is not None:
|
||||||
res += u'video'
|
res += u'video@'
|
||||||
if fdict.get('vbr') is not None:
|
if fdict.get('vbr') is not None:
|
||||||
res += u'@%4dk' % fdict['vbr']
|
res += u'%4dk' % fdict['vbr']
|
||||||
if fdict.get('acodec') is not None:
|
if fdict.get('acodec') is not None:
|
||||||
if res:
|
if res:
|
||||||
res += u', '
|
res += u', '
|
||||||
@ -1064,7 +1066,7 @@ class YoutubeDL(object):
|
|||||||
|
|
||||||
header_line = line({
|
header_line = line({
|
||||||
'format_id': u'format code', 'ext': u'extension',
|
'format_id': u'format code', 'ext': u'extension',
|
||||||
'_resolution': u'resolution', 'format_note': u'note'}, idlen=idlen)
|
'resolution': u'resolution', 'format_note': u'note'}, idlen=idlen)
|
||||||
self.to_screen(u'[info] Available formats for %s:\n%s\n%s' %
|
self.to_screen(u'[info] Available formats for %s:\n%s\n%s' %
|
||||||
(info_dict['id'], header_line, u"\n".join(formats_s)))
|
(info_dict['id'], header_line, u"\n".join(formats_s)))
|
||||||
|
|
||||||
|
@ -37,10 +37,12 @@ class InfoExtractor(object):
|
|||||||
id: Video identifier.
|
id: Video identifier.
|
||||||
title: Video title, unescaped.
|
title: Video title, unescaped.
|
||||||
|
|
||||||
Additionally, it must contain either a formats entry or url and ext:
|
Additionally, it must contain either a formats entry or a url one:
|
||||||
|
|
||||||
formats: A list of dictionaries for each format available, it must
|
formats: A list of dictionaries for each format available, ordered
|
||||||
be ordered from worst to best quality. Potential fields:
|
from worst to best quality.
|
||||||
|
|
||||||
|
Potential fields:
|
||||||
* url Mandatory. The URL of the video file
|
* url Mandatory. The URL of the video file
|
||||||
* ext Will be calculated from url if missing
|
* ext Will be calculated from url if missing
|
||||||
* format A human-readable description of the format
|
* format A human-readable description of the format
|
||||||
@ -53,12 +55,17 @@ class InfoExtractor(object):
|
|||||||
("3D" or "DASH video")
|
("3D" or "DASH video")
|
||||||
* width Width of the video, if known
|
* width Width of the video, if known
|
||||||
* height Height of the video, if known
|
* height Height of the video, if known
|
||||||
|
* resolution Textual description of width and height
|
||||||
* abr Average audio bitrate in KBit/s
|
* abr Average audio bitrate in KBit/s
|
||||||
* acodec Name of the audio codec in use
|
* acodec Name of the audio codec in use
|
||||||
* vbr Average video bitrate in KBit/s
|
* vbr Average video bitrate in KBit/s
|
||||||
* vcodec Name of the video codec in use
|
* vcodec Name of the video codec in use
|
||||||
* filesize The number of bytes, if known in advance
|
* filesize The number of bytes, if known in advance
|
||||||
* player_url SWF Player URL (used for rtmpdump).
|
* player_url SWF Player URL (used for rtmpdump).
|
||||||
|
* preference Order number of this format. If this field is
|
||||||
|
present, the formats get sorted by this field.
|
||||||
|
-1 for default (order by other properties),
|
||||||
|
-2 or smaller for less than default.
|
||||||
url: Final video URL.
|
url: Final video URL.
|
||||||
ext: Video filename extension.
|
ext: Video filename extension.
|
||||||
format: The video format, defaults to ext (used for --get-format)
|
format: The video format, defaults to ext (used for --get-format)
|
||||||
|
Loading…
Reference in New Issue
Block a user