Compare commits

..
3 Commits
Author SHA1 Message Date
Andy 1bd63ddc91 feat(titles): Better detection of DV across all codecs in Episode and Movie classes dvhe.05.06 was not being detected correctly. 2025-08-05 18:33:51 +00:00
Andy 4dff597af2 feat(dl): Fix track selection to support combining -V, -A, -S flags
Previously, using multiple track selection flags like `-S -A` would not work
as expected. The flags were treated as mutually exclusive, resulting in only
one type of track being downloaded.

This change refactors the track selection logic to properly handle combinations:

- Multiple "only" flags now work together (e.g., `-S -A` downloads both)
- Exclusion flags (`--no-*`) continue to work and override selections
- Default behavior (no flags) remains unchanged

Fixes #10
2025-08-05 15:48:17 +00:00
Andy 8dbdde697d feat(hybrid): Enhance extraction and conversion processes with dymanic spinning bars to follow the rest of the codebase. 2025-08-05 14:57:51 +00:00
4 changed files with 131 additions and 119 deletions
+15 -13
View File
@@ -783,23 +783,26 @@ class dl:
sys.exit(1) sys.exit(1)
if video_only or audio_only or subs_only or chapters_only or no_subs or no_audio or no_chapters: if video_only or audio_only or subs_only or chapters_only or no_subs or no_audio or no_chapters:
# Determine which track types to keep based on the flags keep_videos = False
keep_audio = False
keep_subtitles = False
keep_chapters = False
if video_only or audio_only or subs_only or chapters_only:
if video_only:
keep_videos = True
if audio_only:
keep_audio = True
if subs_only:
keep_subtitles = True
if chapters_only:
keep_chapters = True
else:
keep_videos = True keep_videos = True
keep_audio = True keep_audio = True
keep_subtitles = True keep_subtitles = True
keep_chapters = True keep_chapters = True
# Handle exclusive flags (only keep one type)
if video_only:
keep_audio = keep_subtitles = keep_chapters = False
elif audio_only:
keep_videos = keep_subtitles = keep_chapters = False
elif subs_only:
keep_videos = keep_audio = keep_chapters = False
elif chapters_only:
keep_videos = keep_audio = keep_subtitles = False
# Handle exclusion flags (remove specific types)
if no_subs: if no_subs:
keep_subtitles = False keep_subtitles = False
if no_audio: if no_audio:
@@ -807,7 +810,6 @@ class dl:
if no_chapters: if no_chapters:
keep_chapters = False keep_chapters = False
# Build the kept_tracks list without duplicates
kept_tracks = [] kept_tracks = []
if keep_videos: if keep_videos:
kept_tracks.extend(title.tracks.videos) kept_tracks.extend(title.tracks.videos)
+3 -2
View File
@@ -170,8 +170,9 @@ class Episode(Title):
frame_rate = float(primary_video_track.frame_rate) frame_rate = float(primary_video_track.frame_rate)
if hdr_format: if hdr_format:
if (primary_video_track.hdr_format or "").startswith("Dolby Vision"): if (primary_video_track.hdr_format or "").startswith("Dolby Vision"):
if (primary_video_track.hdr_format_commercial) != "Dolby Vision": name += " DV"
name += f" DV {DYNAMIC_RANGE_MAP.get(hdr_format)} " if DYNAMIC_RANGE_MAP.get(hdr_format) and DYNAMIC_RANGE_MAP.get(hdr_format) != "DV":
name += " HDR"
else: else:
name += f" {DYNAMIC_RANGE_MAP.get(hdr_format)} " name += f" {DYNAMIC_RANGE_MAP.get(hdr_format)} "
elif trc and "HLG" in trc: elif trc and "HLG" in trc:
+3 -2
View File
@@ -121,8 +121,9 @@ class Movie(Title):
frame_rate = float(primary_video_track.frame_rate) frame_rate = float(primary_video_track.frame_rate)
if hdr_format: if hdr_format:
if (primary_video_track.hdr_format or "").startswith("Dolby Vision"): if (primary_video_track.hdr_format or "").startswith("Dolby Vision"):
if (primary_video_track.hdr_format_commercial) != "Dolby Vision": name += " DV"
name += f" DV {DYNAMIC_RANGE_MAP.get(hdr_format)} " if DYNAMIC_RANGE_MAP.get(hdr_format) and DYNAMIC_RANGE_MAP.get(hdr_format) != "DV":
name += " HDR"
else: else:
name += f" {DYNAMIC_RANGE_MAP.get(hdr_format)} " name += f" {DYNAMIC_RANGE_MAP.get(hdr_format)} "
elif trc and "HLG" in trc: elif trc and "HLG" in trc:
+19 -11
View File
@@ -126,8 +126,7 @@ class Hybrid:
def extract_stream(self, save_path, type_): def extract_stream(self, save_path, type_):
output = Path(config.directories.temp / f"{type_}.hevc") output = Path(config.directories.temp / f"{type_}.hevc")
self.log.info(f"+ Extracting {type_} stream") with console.status(f"Extracting {type_} stream...", spinner="dots"):
returncode = self.ffmpeg_simple(save_path, output) returncode = self.ffmpeg_simple(save_path, output)
if returncode: if returncode:
@@ -135,14 +134,17 @@ class Hybrid:
self.log.error(f"x Failed extracting {type_} stream") self.log.error(f"x Failed extracting {type_} stream")
sys.exit(1) sys.exit(1)
self.log.info(f"Extracted {type_} stream")
def extract_rpu(self, video, untouched=False): def extract_rpu(self, video, untouched=False):
if os.path.isfile(config.directories.temp / "RPU.bin") or os.path.isfile( if os.path.isfile(config.directories.temp / "RPU.bin") or os.path.isfile(
config.directories.temp / "RPU_UNT.bin" config.directories.temp / "RPU_UNT.bin"
): ):
return return
self.log.info(f"+ Extracting{' untouched ' if untouched else ' '}RPU from Dolby Vision stream") with console.status(
f"Extracting{' untouched ' if untouched else ' '}RPU from Dolby Vision stream...", spinner="dots"
):
extraction_args = [str(DoviTool)] extraction_args = [str(DoviTool)]
if not untouched: if not untouched:
extraction_args += ["-m", "3"] extraction_args += ["-m", "3"]
@@ -168,6 +170,8 @@ class Hybrid:
else: else:
raise ValueError(f"Failed extracting{' untouched ' if untouched else ' '}RPU from Dolby Vision stream") raise ValueError(f"Failed extracting{' untouched ' if untouched else ' '}RPU from Dolby Vision stream")
self.log.info(f"Extracted{' untouched ' if untouched else ' '}RPU from Dolby Vision stream")
def level_6(self): def level_6(self):
"""Edit RPU Level 6 values""" """Edit RPU Level 6 values"""
with open(config.directories.temp / "L6.json", "w+") as level6_file: with open(config.directories.temp / "L6.json", "w+") as level6_file:
@@ -185,7 +189,7 @@ class Hybrid:
json.dump(level6, level6_file, indent=3) json.dump(level6, level6_file, indent=3)
if not os.path.isfile(config.directories.temp / "RPU_L6.bin"): if not os.path.isfile(config.directories.temp / "RPU_L6.bin"):
self.log.info("+ Editing RPU Level 6 values") with console.status("Editing RPU Level 6 values...", spinner="dots"):
level6 = subprocess.run( level6 = subprocess.run(
[ [
str(DoviTool), str(DoviTool),
@@ -205,6 +209,8 @@ class Hybrid:
Path.unlink(config.directories.temp / "RPU_L6.bin") Path.unlink(config.directories.temp / "RPU_L6.bin")
raise ValueError("Failed editing RPU Level 6 values") raise ValueError("Failed editing RPU Level 6 values")
self.log.info("Edited RPU Level 6 values")
# Update rpu_file to use the edited version # Update rpu_file to use the edited version
self.rpu_file = "RPU_L6.bin" self.rpu_file = "RPU_L6.bin"
@@ -212,8 +218,7 @@ class Hybrid:
if os.path.isfile(config.directories.temp / self.hevc_file): if os.path.isfile(config.directories.temp / self.hevc_file):
return return
self.log.info(f"+ Injecting Dolby Vision metadata into {self.hdr_type} stream") with console.status(f"Injecting Dolby Vision metadata into {self.hdr_type} stream...", spinner="dots"):
inject_cmd = [ inject_cmd = [
str(DoviTool), str(DoviTool),
"inject-rpu", "inject-rpu",
@@ -241,6 +246,8 @@ class Hybrid:
Path.unlink(config.directories.temp / self.hevc_file) Path.unlink(config.directories.temp / self.hevc_file)
raise ValueError("Failed injecting Dolby Vision metadata into HDR10 stream") raise ValueError("Failed injecting Dolby Vision metadata into HDR10 stream")
self.log.info(f"Injected Dolby Vision metadata into {self.hdr_type} stream")
def extract_hdr10plus(self, _video): def extract_hdr10plus(self, _video):
"""Extract HDR10+ metadata from the video stream""" """Extract HDR10+ metadata from the video stream"""
if os.path.isfile(config.directories.temp / self.hdr10plus_file): if os.path.isfile(config.directories.temp / self.hdr10plus_file):
@@ -249,8 +256,7 @@ class Hybrid:
if not HDR10PlusTool: if not HDR10PlusTool:
raise ValueError("HDR10Plus_tool not found. Please install it to use HDR10+ to DV conversion.") raise ValueError("HDR10Plus_tool not found. Please install it to use HDR10+ to DV conversion.")
self.log.info("+ Extracting HDR10+ metadata") with console.status("Extracting HDR10+ metadata...", spinner="dots"):
# HDR10Plus_tool needs raw HEVC stream # HDR10Plus_tool needs raw HEVC stream
extraction = subprocess.run( extraction = subprocess.run(
[ [
@@ -271,13 +277,14 @@ class Hybrid:
if os.path.getsize(config.directories.temp / self.hdr10plus_file) == 0: if os.path.getsize(config.directories.temp / self.hdr10plus_file) == 0:
raise ValueError("No HDR10+ metadata found in the stream") raise ValueError("No HDR10+ metadata found in the stream")
self.log.info("Extracted HDR10+ metadata")
def convert_hdr10plus_to_dv(self): def convert_hdr10plus_to_dv(self):
"""Convert HDR10+ metadata to Dolby Vision RPU""" """Convert HDR10+ metadata to Dolby Vision RPU"""
if os.path.isfile(config.directories.temp / "RPU.bin"): if os.path.isfile(config.directories.temp / "RPU.bin"):
return return
self.log.info("+ Converting HDR10+ metadata to Dolby Vision") with console.status("Converting HDR10+ metadata to Dolby Vision...", spinner="dots"):
# First create the extra metadata JSON for dovi_tool # First create the extra metadata JSON for dovi_tool
extra_metadata = { extra_metadata = {
"cm_version": "V29", "cm_version": "V29",
@@ -312,6 +319,7 @@ class Hybrid:
if conversion.returncode: if conversion.returncode:
raise ValueError("Failed converting HDR10+ to Dolby Vision") raise ValueError("Failed converting HDR10+ to Dolby Vision")
self.log.info("Converted HDR10+ metadata to Dolby Vision")
self.log.info("✓ HDR10+ successfully converted to Dolby Vision Profile 8") self.log.info("✓ HDR10+ successfully converted to Dolby Vision Profile 8")
# Clean up temporary files # Clean up temporary files