forked from DRMTalks/devine
Add Bitrate Selection options to dl command CLI
It defaults to highest available. Closes #8.
This commit is contained in:
parent
4bee08c431
commit
84bf9fde92
|
@ -62,6 +62,12 @@ class dl:
|
||||||
@click.option("-a", "--acodec", type=click.Choice(Audio.Codec, case_sensitive=False),
|
@click.option("-a", "--acodec", type=click.Choice(Audio.Codec, case_sensitive=False),
|
||||||
default=None,
|
default=None,
|
||||||
help="Audio Codec to download, defaults to any codec.")
|
help="Audio Codec to download, defaults to any codec.")
|
||||||
|
@click.option("-vb", "--vbitrate", type=int,
|
||||||
|
default=None,
|
||||||
|
help="Video Bitrate to download (in kbps), defaults to highest available.")
|
||||||
|
@click.option("-ab", "--abitrate", type=int,
|
||||||
|
default=None,
|
||||||
|
help="Audio Bitrate to download (in kbps), defaults to highest available.")
|
||||||
@click.option("-r", "--range", "range_", type=click.Choice(Video.Range, case_sensitive=False),
|
@click.option("-r", "--range", "range_", type=click.Choice(Video.Range, case_sensitive=False),
|
||||||
default=Video.Range.SDR,
|
default=Video.Range.SDR,
|
||||||
help="Video Color Range, defaults to SDR.")
|
help="Video Color Range, defaults to SDR.")
|
||||||
|
@ -229,11 +235,31 @@ class dl:
|
||||||
self.cli._result_callback = self.result
|
self.cli._result_callback = self.result
|
||||||
|
|
||||||
def result(
|
def result(
|
||||||
self, service: Service, quality: Optional[int], vcodec: Video.Codec,
|
self,
|
||||||
acodec: Optional[Audio.Codec], range_: Video.Range, wanted: list[str], lang: list[str], v_lang: list[str],
|
service: Service,
|
||||||
s_lang: list[str], audio_only: bool, subs_only: bool, chapters_only: bool, slow: bool, list_: bool,
|
quality: Optional[int],
|
||||||
list_titles: bool, skip_dl: bool, export: Optional[Path], cdm_only: Optional[bool], no_folder: bool,
|
vcodec: Video.Codec,
|
||||||
no_source: bool, workers: int, *_: Any, **__: Any
|
acodec: Optional[Audio.Codec],
|
||||||
|
vbitrate: int,
|
||||||
|
abitrate: int,
|
||||||
|
range_: Video.Range,
|
||||||
|
wanted: list[str],
|
||||||
|
lang: list[str],
|
||||||
|
v_lang: list[str],
|
||||||
|
s_lang: list[str],
|
||||||
|
audio_only: bool,
|
||||||
|
subs_only: bool,
|
||||||
|
chapters_only: bool,
|
||||||
|
slow: bool, list_: bool,
|
||||||
|
list_titles: bool,
|
||||||
|
skip_dl: bool,
|
||||||
|
export: Optional[Path],
|
||||||
|
cdm_only: Optional[bool],
|
||||||
|
no_folder: bool,
|
||||||
|
no_source: bool,
|
||||||
|
workers: int,
|
||||||
|
*_: Any,
|
||||||
|
**__: Any
|
||||||
) -> None:
|
) -> None:
|
||||||
if cdm_only is None:
|
if cdm_only is None:
|
||||||
vaults_only = None
|
vaults_only = None
|
||||||
|
@ -306,6 +332,11 @@ class dl:
|
||||||
# filter video tracks
|
# filter video tracks
|
||||||
title.tracks.select_video(lambda x: x.codec == vcodec)
|
title.tracks.select_video(lambda x: x.codec == vcodec)
|
||||||
title.tracks.select_video(lambda x: x.range == range_)
|
title.tracks.select_video(lambda x: x.range == range_)
|
||||||
|
if vbitrate:
|
||||||
|
title.tracks.select_video(lambda x: x.bitrate and x.bitrate // 1000 == vbitrate)
|
||||||
|
if not title.tracks.videos:
|
||||||
|
self.log.error(f"There's no {vbitrate}kbps Video Track...")
|
||||||
|
sys.exit(1)
|
||||||
if quality:
|
if quality:
|
||||||
title.tracks.with_resolution(quality)
|
title.tracks.with_resolution(quality)
|
||||||
if not title.tracks.videos:
|
if not title.tracks.videos:
|
||||||
|
@ -335,6 +366,10 @@ class dl:
|
||||||
if not title.tracks.audio:
|
if not title.tracks.audio:
|
||||||
self.log.error(f"There's no {acodec.name} Audio Tracks...")
|
self.log.error(f"There's no {acodec.name} Audio Tracks...")
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
if abitrate:
|
||||||
|
title.tracks.select_audio(lambda x: x.bitrate and x.bitrate // 1000 == abitrate)
|
||||||
|
if not title.tracks.audio:
|
||||||
|
self.log.error(f"There's no {abitrate}kbps Audio Track...")
|
||||||
|
|
||||||
if lang and "all" not in lang:
|
if lang and "all" not in lang:
|
||||||
title.tracks.audio = title.tracks.select_per_language(title.tracks.audio, lang)
|
title.tracks.audio = title.tracks.select_per_language(title.tracks.audio, lang)
|
||||||
|
|
Loading…
Reference in New Issue