[README.md] Clarify sequence types in output template and document numeric string formatting operations
parent
fafc2bf5a9
commit
050f143c12
138
README.md
138
README.md
|
@ -486,87 +486,89 @@ The `-o` option allows users to indicate a template for the output file names.
|
||||||
|
|
||||||
**tl;dr:** [navigate me to examples](#output-template-examples).
|
**tl;dr:** [navigate me to examples](#output-template-examples).
|
||||||
|
|
||||||
The basic usage is not to set any template arguments when downloading a single file, like in `youtube-dl -o funny_video.flv "http://some/video"`. However, it may contain special sequences that will be replaced when downloading each video. The special sequences have the format `%(NAME)s`. To clarify, that is a percent symbol followed by a name in parentheses, followed by a lowercase S. Allowed names are:
|
The basic usage is not to set any template arguments when downloading a single file, like in `youtube-dl -o funny_video.flv "http://some/video"`. However, it may contain special sequences that will be replaced when downloading each video. The special sequences may be formatted according to [python string formatting operations](https://docs.python.org/2/library/stdtypes.html#string-formatting). For example, `%(NAME)s` or `%(NAME)05d`. To clarify, that is a percent symbol followed by a name in parentheses, followed by a formatting operations. Allowed names along with sequence type are:
|
||||||
|
|
||||||
- `id`: Video identifier
|
- `id` (string): Video identifier
|
||||||
- `title`: Video title
|
- `title` (string): Video title
|
||||||
- `url`: Video URL
|
- `url` (string): Video URL
|
||||||
- `ext`: Video filename extension
|
- `ext` (string): Video filename extension
|
||||||
- `alt_title`: A secondary title of the video
|
- `alt_title` (string): A secondary title of the video
|
||||||
- `display_id`: An alternative identifier for the video
|
- `display_id` (string): An alternative identifier for the video
|
||||||
- `uploader`: Full name of the video uploader
|
- `uploader` (string): Full name of the video uploader
|
||||||
- `license`: License name the video is licensed under
|
- `license` (string): License name the video is licensed under
|
||||||
- `creator`: The creator of the video
|
- `creator` (string): The creator of the video
|
||||||
- `release_date`: The date (YYYYMMDD) when the video was released
|
- `release_date` (string): The date (YYYYMMDD) when the video was released
|
||||||
- `timestamp`: UNIX timestamp of the moment the video became available
|
- `timestamp` (numeric): UNIX timestamp of the moment the video became available
|
||||||
- `upload_date`: Video upload date (YYYYMMDD)
|
- `upload_date` (string): Video upload date (YYYYMMDD)
|
||||||
- `uploader_id`: Nickname or id of the video uploader
|
- `uploader_id` (string): Nickname or id of the video uploader
|
||||||
- `location`: Physical location where the video was filmed
|
- `location` (string): Physical location where the video was filmed
|
||||||
- `duration`: Length of the video in seconds
|
- `duration` (numeric): Length of the video in seconds
|
||||||
- `view_count`: How many users have watched the video on the platform
|
- `view_count` (numeric): How many users have watched the video on the platform
|
||||||
- `like_count`: Number of positive ratings of the video
|
- `like_count` (numeric): Number of positive ratings of the video
|
||||||
- `dislike_count`: Number of negative ratings of the video
|
- `dislike_count` (numeric): Number of negative ratings of the video
|
||||||
- `repost_count`: Number of reposts of the video
|
- `repost_count` (numeric): Number of reposts of the video
|
||||||
- `average_rating`: Average rating give by users, the scale used depends on the webpage
|
- `average_rating` (numeric): Average rating give by users, the scale used depends on the webpage
|
||||||
- `comment_count`: Number of comments on the video
|
- `comment_count` (numeric): Number of comments on the video
|
||||||
- `age_limit`: Age restriction for the video (years)
|
- `age_limit` (numeric): Age restriction for the video (years)
|
||||||
- `format`: A human-readable description of the format
|
- `format` (string): A human-readable description of the format
|
||||||
- `format_id`: Format code specified by `--format`
|
- `format_id` (string): Format code specified by `--format`
|
||||||
- `format_note`: Additional info about the format
|
- `format_note` (string): Additional info about the format
|
||||||
- `width`: Width of the video
|
- `width` (numeric): Width of the video
|
||||||
- `height`: Height of the video
|
- `height` (numeric): Height of the video
|
||||||
- `resolution`: Textual description of width and height
|
- `resolution` (string): Textual description of width and height
|
||||||
- `tbr`: Average bitrate of audio and video in KBit/s
|
- `tbr` (numeric): Average bitrate of audio and video in KBit/s
|
||||||
- `abr`: Average audio bitrate in KBit/s
|
- `abr` (numeric): Average audio bitrate in KBit/s
|
||||||
- `acodec`: Name of the audio codec in use
|
- `acodec` (string): Name of the audio codec in use
|
||||||
- `asr`: Audio sampling rate in Hertz
|
- `asr` (numeric): Audio sampling rate in Hertz
|
||||||
- `vbr`: Average video bitrate in KBit/s
|
- `vbr` (numeric): Average video bitrate in KBit/s
|
||||||
- `fps`: Frame rate
|
- `fps` (numeric): Frame rate
|
||||||
- `vcodec`: Name of the video codec in use
|
- `vcodec` (string): Name of the video codec in use
|
||||||
- `container`: Name of the container format
|
- `container` (string): Name of the container format
|
||||||
- `filesize`: The number of bytes, if known in advance
|
- `filesize` (numeric): The number of bytes, if known in advance
|
||||||
- `filesize_approx`: An estimate for the number of bytes
|
- `filesize_approx` (numeric): An estimate for the number of bytes
|
||||||
- `protocol`: The protocol that will be used for the actual download
|
- `protocol` (string): The protocol that will be used for the actual download
|
||||||
- `extractor`: Name of the extractor
|
- `extractor` (string): Name of the extractor
|
||||||
- `extractor_key`: Key name of the extractor
|
- `extractor_key` (string): Key name of the extractor
|
||||||
- `epoch`: Unix epoch when creating the file
|
- `epoch` (numeric): Unix epoch when creating the file
|
||||||
- `autonumber`: Five-digit number that will be increased with each download, starting at zero
|
- `autonumber` (numeric): Five-digit number that will be increased with each download, starting at zero
|
||||||
- `playlist`: Name or id of the playlist that contains the video
|
- `playlist` (string): Name or id of the playlist that contains the video
|
||||||
- `playlist_index`: Index of the video in the playlist padded with leading zeros according to the total length of the playlist
|
- `playlist_index` (numeric): Index of the video in the playlist padded with leading zeros according to the total length of the playlist
|
||||||
- `playlist_id`: Playlist identifier
|
- `playlist_id` (string): Playlist identifier
|
||||||
- `playlist_title`: Playlist title
|
- `playlist_title` (string): Playlist title
|
||||||
|
|
||||||
|
|
||||||
Available for the video that belongs to some logical chapter or section:
|
Available for the video that belongs to some logical chapter or section:
|
||||||
- `chapter`: Name or title of the chapter the video belongs to
|
- `chapter` (string): Name or title of the chapter the video belongs to
|
||||||
- `chapter_number`: Number of the chapter the video belongs to
|
- `chapter_number` (numeric): Number of the chapter the video belongs to
|
||||||
- `chapter_id`: Id of the chapter the video belongs to
|
- `chapter_id` (string): Id of the chapter the video belongs to
|
||||||
|
|
||||||
Available for the video that is an episode of some series or programme:
|
Available for the video that is an episode of some series or programme:
|
||||||
- `series`: Title of the series or programme the video episode belongs to
|
- `series` (string): Title of the series or programme the video episode belongs to
|
||||||
- `season`: Title of the season the video episode belongs to
|
- `season` (string): Title of the season the video episode belongs to
|
||||||
- `season_number`: Number of the season the video episode belongs to
|
- `season_number` (numeric): Number of the season the video episode belongs to
|
||||||
- `season_id`: Id of the season the video episode belongs to
|
- `season_id` (string): Id of the season the video episode belongs to
|
||||||
- `episode`: Title of the video episode
|
- `episode` (string): Title of the video episode
|
||||||
- `episode_number`: Number of the video episode within a season
|
- `episode_number` (numeric): Number of the video episode within a season
|
||||||
- `episode_id`: Id of the video episode
|
- `episode_id` (string): Id of the video episode
|
||||||
|
|
||||||
Available for the media that is a track or a part of a music album:
|
Available for the media that is a track or a part of a music album:
|
||||||
- `track`: Title of the track
|
- `track` (string): Title of the track
|
||||||
- `track_number`: Number of the track within an album or a disc
|
- `track_number` (numeric): Number of the track within an album or a disc
|
||||||
- `track_id`: Id of the track
|
- `track_id` (string): Id of the track
|
||||||
- `artist`: Artist(s) of the track
|
- `artist` (string): Artist(s) of the track
|
||||||
- `genre`: Genre(s) of the track
|
- `genre` (string): Genre(s) of the track
|
||||||
- `album`: Title of the album the track belongs to
|
- `album` (string): Title of the album the track belongs to
|
||||||
- `album_type`: Type of the album
|
- `album_type` (string): Type of the album
|
||||||
- `album_artist`: List of all artists appeared on the album
|
- `album_artist` (string): List of all artists appeared on the album
|
||||||
- `disc_number`: Number of the disc or other physical medium the track belongs to
|
- `disc_number` (numeric): Number of the disc or other physical medium the track belongs to
|
||||||
- `release_year`: Year (YYYY) when the album was released
|
- `release_year` (numeric): Year (YYYY) when the album was released
|
||||||
|
|
||||||
Each aforementioned sequence when referenced in an output template will be replaced by the actual value corresponding to the sequence name. Note that some of the sequences are not guaranteed to be present since they depend on the metadata obtained by a particular extractor. Such sequences will be replaced with `NA`.
|
Each aforementioned sequence when referenced in an output template will be replaced by the actual value corresponding to the sequence name. Note that some of the sequences are not guaranteed to be present since they depend on the metadata obtained by a particular extractor. Such sequences will be replaced with `NA`.
|
||||||
|
|
||||||
For example for `-o %(title)s-%(id)s.%(ext)s` and an mp4 video with title `youtube-dl test video` and id `BaW_jenozKcj`, this will result in a `youtube-dl test video-BaW_jenozKcj.mp4` file created in the current directory.
|
For example for `-o %(title)s-%(id)s.%(ext)s` and an mp4 video with title `youtube-dl test video` and id `BaW_jenozKcj`, this will result in a `youtube-dl test video-BaW_jenozKcj.mp4` file created in the current directory.
|
||||||
|
|
||||||
|
For numeric sequences you can use numeric related formatting, for example, `%(view_count)05d` will result in a string with view count padded with zeros up to 5 characters, like in `00042`.
|
||||||
|
|
||||||
Output templates can also contain arbitrary hierarchical path, e.g. `-o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'` which will result in downloading each video in a directory corresponding to this path template. Any missing directory will be automatically created for you.
|
Output templates can also contain arbitrary hierarchical path, e.g. `-o '%(playlist)s/%(playlist_index)s - %(title)s.%(ext)s'` which will result in downloading each video in a directory corresponding to this path template. Any missing directory will be automatically created for you.
|
||||||
|
|
||||||
To use percent literals in an output template use `%%`. To output to stdout use `-o -`.
|
To use percent literals in an output template use `%%`. To output to stdout use `-o -`.
|
||||||
|
|
Loading…
Reference in New Issue