Add source quality alias

issue #33
This commit is contained in:
Ivan Habunek 2020-09-29 08:26:40 +02:00
parent b982cba566
commit bb16108572
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
4 changed files with 19 additions and 1 deletions

View File

@ -1,6 +1,11 @@
Twitch Downloader change log Twitch Downloader change log
============================ ============================
1.12.0 (TBA)
-------------------
* Added `source` as alias for best available quality (#33)
1.11.0 (2020-09-03) 1.11.0 (2020-09-03)
------------------- -------------------

View File

@ -125,6 +125,12 @@ Specify video quality to download:
twitch-dl download -q 720p 221837124 twitch-dl download -q 720p 221837124
``` ```
Setting quality to `source` will download the best available quality:
```
twitch-dl download -q source 221837124
```
Download a clip by slug or URL: Download a clip by slug or URL:
``` ```

View File

@ -83,6 +83,10 @@ def _parse_playlists(playlists_m3u8):
def _get_playlist_by_name(playlists, quality): def _get_playlist_by_name(playlists, quality):
if quality == "source":
_, _, uri = playlists[0]
return uri
for name, _, uri in playlists: for name, _, uri in playlists:
if name == quality: if name == quality:
return uri return uri
@ -193,6 +197,9 @@ def _get_clip_url(clip, args):
# Quality given as an argument # Quality given as an argument
if args.quality: if args.quality:
if args.quality == "source":
return qualities[0]["sourceURL"]
selected_quality = args.quality.rstrip("p") # allow 720p as well as 720 selected_quality = args.quality.rstrip("p") # allow 720p as well as 720
for q in qualities: for q in qualities:
if q["quality"] == selected_quality: if q["quality"] == selected_quality:

View File

@ -115,7 +115,7 @@ COMMANDS = [
"default": False, "default": False,
}), }),
(["-q", "--quality"], { (["-q", "--quality"], {
"help": "Video quality.", "help": "Video quality, e.g. 720p. Set to 'source' to get best quality.",
"type": str, "type": str,
}), }),
], ],