mirror of
https://github.com/ihabunek/twitch-dl
synced 2024-08-30 18:32:25 +00:00
Download init segments
These seem to occur in hd quality playlists like 1440p.
This commit is contained in:
parent
2feef136ca
commit
ac7cdba28e
@ -19,6 +19,7 @@ from twitchdl.naming import clip_filename, video_filename
|
|||||||
from twitchdl.output import blue, bold, green, print_log, yellow
|
from twitchdl.output import blue, bold, green, print_log, yellow
|
||||||
from twitchdl.playlists import (
|
from twitchdl.playlists import (
|
||||||
enumerate_vods,
|
enumerate_vods,
|
||||||
|
get_init_sections,
|
||||||
load_m3u8,
|
load_m3u8,
|
||||||
make_join_playlist,
|
make_join_playlist,
|
||||||
parse_playlists,
|
parse_playlists,
|
||||||
@ -231,6 +232,11 @@ def _download_video(video_id: str, args: DownloadOptions) -> None:
|
|||||||
|
|
||||||
click.echo(f"\nDownloading {len(vods)} VODs using {args.max_workers} workers to {target_dir}")
|
click.echo(f"\nDownloading {len(vods)} VODs using {args.max_workers} workers to {target_dir}")
|
||||||
|
|
||||||
|
init_sections = get_init_sections(vods_m3u8)
|
||||||
|
for uri in init_sections:
|
||||||
|
print_log(f"Downloading init section {uri}...")
|
||||||
|
download_file(f"{base_uri}{uri}", target_dir / uri)
|
||||||
|
|
||||||
sources = [base_uri + vod.path for vod in vods]
|
sources = [base_uri + vod.path for vod in vods]
|
||||||
targets = [target_dir / f"{vod.index:05d}.ts" for vod in vods]
|
targets = [target_dir / f"{vod.index:05d}.ts" for vod in vods]
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ Parse and manipulate m3u8 playlists.
|
|||||||
|
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from typing import Generator, List, Optional, OrderedDict
|
from typing import Generator, List, Optional, OrderedDict, Set
|
||||||
|
|
||||||
import click
|
import click
|
||||||
import m3u8
|
import m3u8
|
||||||
@ -169,3 +169,12 @@ def _playlist_key(playlist: Playlist) -> int:
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
return MAX
|
return MAX
|
||||||
|
|
||||||
|
|
||||||
|
def get_init_sections(playlist: m3u8.M3U8) -> Set[str]:
|
||||||
|
# TODO: we're ignoring initi_section.base_uri and bytes
|
||||||
|
return set(
|
||||||
|
segment.init_section.uri
|
||||||
|
for segment in playlist.segments
|
||||||
|
if segment.init_section is not None
|
||||||
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user