From bb16108572a5ce15ad6a195dc18b61a5664819d6 Mon Sep 17 00:00:00 2001 From: Ivan Habunek Date: Tue, 29 Sep 2020 08:26:40 +0200 Subject: [PATCH] Add source quality alias issue #33 --- CHANGELOG.md | 5 +++++ README.md | 6 ++++++ twitchdl/commands.py | 7 +++++++ twitchdl/console.py | 2 +- 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44287a7..4218e5d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ Twitch Downloader change log ============================ +1.12.0 (TBA) +------------------- + +* Added `source` as alias for best available quality (#33) + 1.11.0 (2020-09-03) ------------------- diff --git a/README.md b/README.md index 2ab7434..b2e428d 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,12 @@ Specify video quality to download: 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: ``` diff --git a/twitchdl/commands.py b/twitchdl/commands.py index c6bef20..72811d6 100644 --- a/twitchdl/commands.py +++ b/twitchdl/commands.py @@ -83,6 +83,10 @@ def _parse_playlists(playlists_m3u8): def _get_playlist_by_name(playlists, quality): + if quality == "source": + _, _, uri = playlists[0] + return uri + for name, _, uri in playlists: if name == quality: return uri @@ -193,6 +197,9 @@ def _get_clip_url(clip, args): # Quality given as an argument if args.quality: + if args.quality == "source": + return qualities[0]["sourceURL"] + selected_quality = args.quality.rstrip("p") # allow 720p as well as 720 for q in qualities: if q["quality"] == selected_quality: diff --git a/twitchdl/console.py b/twitchdl/console.py index 87efde5..f5764d4 100644 --- a/twitchdl/console.py +++ b/twitchdl/console.py @@ -115,7 +115,7 @@ COMMANDS = [ "default": False, }), (["-q", "--quality"], { - "help": "Video quality.", + "help": "Video quality, e.g. 720p. Set to 'source' to get best quality.", "type": str, }), ],