Enable downloading multiple videos successively

This commit is contained in:
Ivan Habunek
2022-08-18 09:09:20 +02:00
parent c8d38b5512
commit c4f4935b96
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 and from threads to `asyncio` for concurrency. This enables easier
implementation of new features, but has no breaking changes for the CLI. 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. 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 * Improved progress meter, updates on each chunk downloaded, instead of each VOD
downloaded. downloaded.
* Improved speed estimate, displays recent speed instead of average speed since * 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 easier implementation of new features, but has no breaking changes for the
CLI. CLI.
changes: 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 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." - "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) ### [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 This release switches from using `requests` to `httpx` for making http requests,
requests, and from threads to `asyncio` for concurrency. This enables and from threads to `asyncio` for concurrency. This enables easier
easier implementation of new features, but has no breaking changes for the implementation of new features, but has no breaking changes for the CLI.
CLI.
* Add `--rate-limit` option to `download` for limiting maximum bandwidth when
* Add `--rate-limit` option to `download` for limiting maximum bandwith when
downloading. 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 * Improved progress meter, updates on each chunk downloaded, instead of each VOD
downloaded. downloaded.
* Improved speed estimate, displays recent speed instead of average speed since * Improved speed estimate, displays recent speed instead of average speed since

View File

@ -1,12 +1,12 @@
<!-- ------------------- generated docs start ------------------- --> <!-- ------------------- generated docs start ------------------- -->
# twitch-dl download # twitch-dl download
Download a video or clip. Download videos or clips.
### USAGE ### USAGE
``` ```
twitch-dl download <video> [FLAGS] [OPTIONS] twitch-dl download <videos> [FLAGS] [OPTIONS]
``` ```
### ARGUMENTS ### ARGUMENTS
@ -14,8 +14,8 @@ twitch-dl download <video> [FLAGS] [OPTIONS]
<table> <table>
<tbody> <tbody>
<tr> <tr>
<td class="code">&lt;video&gt;</td> <td class="code">&lt;videos&gt;</td>
<td>Video ID, clip slug, or URL</td> <td>One or more video ID, clip slug or twitch URL to download.</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>
@ -116,6 +116,12 @@ Setting quality to `audio_only` will download only audio:
twitch-dl download -q audio_only 221837124 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 ### Overriding the target file name
The target filename can be defined by passing the `--output` option followed by 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): 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: if video_id:
return _download_video(video_id, args) return _download_video(video_id, args)
clip_slug = utils.parse_clip_identifier(args.video) clip_slug = utils.parse_clip_identifier(video)
if clip_slug: if clip_slug:
return _download_clip(clip_slug, args) 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): def _get_clip_url(clip, quality):

View File

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