Enable downloading multiple videos successively

This commit is contained in:
Ivan Habunek 2022-08-18 09:09:20 +02:00
parent c8d38b5512
commit c4f4935b96
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
6 changed files with 33 additions and 18 deletions

View File

@ -9,8 +9,10 @@ This release switches from using `requests` to `httpx` for making http requests,
and from threads to `asyncio` for concurrency. This enables easier
implementation of new features, but has no breaking changes for the CLI.
* Add `--rate-limit` option to `download` for limiting maximum bandwith when
* Add `--rate-limit` option to `download` for limiting maximum bandwidth when
downloading.
* Allow passing multiple video ids to `download` to download multiple videos
successively.
* Improved progress meter, updates on each chunk downloaded, instead of each VOD
downloaded.
* Improved speed estimate, displays recent speed instead of average speed since

View File

@ -6,7 +6,8 @@
easier implementation of new features, but has no breaking changes for the
CLI.
changes:
- "Add `--rate-limit` option to `download` for limiting maximum bandwith when downloading."
- "Add `--rate-limit` option to `download` for limiting maximum bandwidth when downloading."
- "Allow passing multiple video ids to `download` to download multiple videos successively."
- "Improved progress meter, updates on each chunk downloaded, instead of each VOD downloaded."
- "Improved speed estimate, displays recent speed instead of average speed since the start of download."

View File

@ -5,14 +5,14 @@ twitch-dl changelog
### [2.0.0 (TBA)](https://github.com/ihabunek/twitch-dl/releases/tag/2.0.0)
This release switches from using `requests` to `httpx` for making http
requests, and from threads to `asyncio` for concurrency. This enables
easier implementation of new features, but has no breaking changes for the
CLI.
This release switches from using `requests` to `httpx` for making http requests,
and from threads to `asyncio` for concurrency. This enables easier
implementation of new features, but has no breaking changes for the CLI.
* Add `--rate-limit` option to `download` for limiting maximum bandwith when
* Add `--rate-limit` option to `download` for limiting maximum bandwidth when
downloading.
* Allow passing multiple video ids to `download` to download multiple videos
successively.
* Improved progress meter, updates on each chunk downloaded, instead of each VOD
downloaded.
* Improved speed estimate, displays recent speed instead of average speed since

View File

@ -1,12 +1,12 @@
<!-- ------------------- generated docs start ------------------- -->
# twitch-dl download
Download a video or clip.
Download videos or clips.
### USAGE
```
twitch-dl download <video> [FLAGS] [OPTIONS]
twitch-dl download <videos> [FLAGS] [OPTIONS]
```
### ARGUMENTS
@ -14,8 +14,8 @@ twitch-dl download <video> [FLAGS] [OPTIONS]
<table>
<tbody>
<tr>
<td class="code">&lt;video&gt;</td>
<td>Video ID, clip slug, or URL</td>
<td class="code">&lt;videos&gt;</td>
<td>One or more video ID, clip slug or twitch URL to download.</td>
</tr>
</tbody>
</table>
@ -116,6 +116,12 @@ Setting quality to `audio_only` will download only audio:
twitch-dl download -q audio_only 221837124
```
Download multiple videos one after the other:
```
twitch-dl download 1559928295 1557034274 1555157293 -q source
```
### Overriding the target file name
The target filename can be defined by passing the `--output` option followed by

View File

@ -166,15 +166,20 @@ def _crete_temp_dir(base_uri):
def download(args):
video_id = utils.parse_video_identifier(args.video)
for video in args.videos:
download_one(video, args)
def download_one(video, args):
video_id = utils.parse_video_identifier(video)
if video_id:
return _download_video(video_id, args)
clip_slug = utils.parse_clip_identifier(args.video)
clip_slug = utils.parse_clip_identifier(video)
if clip_slug:
return _download_clip(clip_slug, args)
raise ConsoleError("Invalid input: {}".format(args.video))
raise ConsoleError("Invalid input: {}".format(video))
def _get_clip_url(clip, quality):

View File

@ -158,11 +158,12 @@ COMMANDS = [
),
Command(
name="download",
description="Download a video or clip.",
description="Download videos or clips.",
arguments=[
(["video"], {
"help": "Video ID, clip slug, or URL",
(["videos"], {
"help": "One or more video ID, clip slug or twitch URL to download.",
"type": str,
"nargs": "+",
}),
(["-w", "--max-workers"], {
"help": "Maximal number of threads for downloading vods "