diff --git a/docs/dev/service-architecture.md b/docs/dev/service-architecture.md index fd056771..b9e27932 100644 --- a/docs/dev/service-architecture.md +++ b/docs/dev/service-architecture.md @@ -488,10 +488,23 @@ for track in tracks.videos + tracks.audio: track.drm_preference = "playready" ``` -Without the hook, the download of a FairPlay-only track stops with -`None of the key systems are supported`, and no challenge goes to the licence server. A licence -server that does not issue the content key refuses the challenge, and can flag the device. Test the route with a licence-only run -(`--cdm-only --skip-dl`) before a service relies on it. +Without the hook, no challenge goes to the licence server for a FairPlay-only track, and `dl` leaves +such a track out of the selection: + +- After the selection and the deferred DRM load, `dl` checks each selected video and audio track that has + no DRM object. An HLS track costs one request for its media playlist. A DASH track is FairPlay-only when + its `ContentProtection` elements name only DRM systems that unshackle cannot license and its init segment + has no Widevine or PlayReady `pssh`. +- `dl` removes each FairPlay-only track and selects again, so the run takes the next best track that + licenses. It logs one line for each title: `Left out 2 FairPlay-only tracks: EXAMPLE has no FairPlay bridge hook`. +- When a quality, range or codec flag matches only FairPlay-only tracks, the second selection skips the + title with its usual reason, and `--best-available` takes its usual fallback. When each selected video + or each selected audio track is FairPlay-only, `dl` skips the title. +- `--list` shows every track and checks none. An import is not checked, because its export holds the + content keys. + +A licence server that does not issue the content key refuses the challenge, and can flag the device. Test +the route with a licence-only run (`--cdm-only --skip-dl`) before a service relies on it. ### Decrypting a cbcs file yourself diff --git a/docs/guide/drm-and-cdm.md b/docs/guide/drm-and-cdm.md index aaee2dad..01cd4e38 100644 --- a/docs/guide/drm-and-cdm.md +++ b/docs/guide/drm-and-cdm.md @@ -82,8 +82,11 @@ appropriate one for each track. For a FairPlay-only track it can send a PlayReady or Widevine challenge for the KIDs of the init segments to the licence server of the platform, which works only when that server issues the same content key to PlayReady or Widevine. - Only a service that defines this route does it. For another service, the download of a FairPlay-only - track stops with `None of the key systems are supported`. + Only a service that defines this route does it. For another service, unshackle leaves the FairPlay-only + tracks out of the selection and takes the next best track that licenses, with one line: + `Left out 1 FairPlay-only track: EXAMPLE has no FairPlay bridge hook`. When only FairPlay-only tracks + match your quality or range options, unshackle skips the title, unless you use `--best-available`. + `--list` still shows every track. When each `EXT-X-KEY` of an fMP4 playlist is sample encryption for a DRM system that unshackle cannot license, such as FairPlay, unshackle reads the key ID from diff --git a/tests/commands/test_fairplay_selection_gate.py b/tests/commands/test_fairplay_selection_gate.py new file mode 100644 index 00000000..23098a77 --- /dev/null +++ b/tests/commands/test_fairplay_selection_gate.py @@ -0,0 +1,297 @@ +"""A service without ``get_fairplay_bridge_license`` leaves FairPlay-only tracks out of the selection.""" + +from __future__ import annotations + +import logging +from types import SimpleNamespace +from typing import Any + +import pytest +from lxml import etree +from pywidevine.pssh import PSSH + +from tests.core.test_hls_service_drm_keys import KID, SKD_KEY, WIDEVINE_KEY, playlist +from tests.lang_selection import test_kind_only_selection as harness +from unshackle.core.drm import Widevine, discovery +from unshackle.core.title_source import KeyArrival +from unshackle.core.titles import Episode +from unshackle.core.tracks import Audio, Tracks, Video +from unshackle.core.tracks.track import Track + +FAIRPLAY_CP = '' +PLAYREADY_CP = '' +WIDEVINE_CP = '' +MP4_CP = '' +PLAYREADY_KEY = ( + '#EXT-X-KEY:METHOD=SAMPLE-AES-CTR,URI="data:text/plain;charset=UTF-16;base64,AAAA",' + 'KEYFORMAT="com.microsoft.playready",KEYFORMATVERSIONS="1"' +) +BASE = "https://cdn.example.test/" +PLAYLISTS = { + f"{BASE}2160.m3u8": playlist(SKD_KEY), + f"{BASE}1080.m3u8": playlist(PLAYREADY_KEY), + f"{BASE}a-fp.m3u8": playlist(SKD_KEY), + f"{BASE}hdr.m3u8": playlist(PLAYREADY_KEY), + f"{BASE}dv.m3u8": playlist(SKD_KEY), +} + + +class Playlists: + """A session that serves the media playlists and notes each URL it gets.""" + + def __init__(self) -> None: + self.urls: list[str] = [] + + def get(self, url: str, **_: Any) -> SimpleNamespace: + self.urls.append(url) + return SimpleNamespace(text=PLAYLISTS[url], ok=True) + + +def dash_data(*protections: str) -> dict: + adaptation_set = etree.fromstring(f"{''.join(protections)}") + return {"dash": {"adaptation_set": adaptation_set, "representation": adaptation_set.find("Representation")}} + + +def video( + id_: str, + height: int, + descriptor: Track.Descriptor, + data: dict | None = None, + range_: Video.Range = Video.Range.SDR, +) -> Video: + return Video( + id_=id_, + url=f"{BASE}{id_}.m3u8", + language="en", + codec=Video.Codec.HEVC, + range_=range_, + width=height * 16 // 9, + height=height, + bitrate=height * 10_000, + descriptor=descriptor, + data=data, + ) + + +class Example(harness.FakeService): + """EXAMPLE: a FairPlay-only 2160p video and audio beside a 1080p video with a PlayReady tag; no bridge hook.""" + + def __init__(self, dash: bool = False) -> None: + super().__init__({1: {}}) + self.session = Playlists() + self.dash = dash + self.drm_on_2160: list | None = None + + def get_tracks(self, title: Episode) -> Tracks: + tracks = super().get_tracks(title) + if self.dash: + tracks.videos = [ + video("2160", 2160, Track.Descriptor.DASH, dash_data(MP4_CP, FAIRPLAY_CP)), + video("1080", 1080, Track.Descriptor.DASH, dash_data(MP4_CP, PLAYREADY_CP)), + ] + else: + tracks.videos = [video("2160", 2160, Track.Descriptor.HLS), video("1080", 1080, Track.Descriptor.HLS)] + tracks.audio.insert( + 0, + Audio( + id_="a-fp", + url=f"{BASE}a-fp.m3u8", + language="en", + codec=Audio.Codec.AAC, + bitrate=256_000, + descriptor=Track.Descriptor.HLS, + ), + ) + tracks.videos[0].drm = self.drm_on_2160 + return tracks + + def __getattr__(self, name: str) -> Any: + if name == "get_fairplay_bridge_license": + raise AttributeError(name) + return super().__getattr__(name) + + +class Bridged(Example): + """EXAMPLE with the hook.""" + + def get_fairplay_bridge_license(self, **_: Any) -> bytes: + return b"" + + +def run(monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, service: Example, **flags: Any) -> Any: + return harness.run(monkeypatch, caplog, {1: {}}, service=service, log_level=logging.INFO, **flags) + + +def test_without_the_hook_the_next_best_tracks_that_license_are_kept( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + service = Example() + + ids = run(monkeypatch, caplog, service) + + assert ids["video"] == ["1080"] + assert ids["audio"] == ["a"] + assert caplog.text.count("Left out 2 FairPlay-only tracks: FAKE has no FairPlay bridge hook") == 1 + assert sorted(service.session.urls) == [f"{BASE}1080.m3u8", f"{BASE}2160.m3u8", f"{BASE}a-fp.m3u8"] + + +def test_with_the_hook_the_fairplay_only_tracks_compete_and_nothing_is_probed( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + service = Bridged() + + ids = run(monkeypatch, caplog, service) + + assert ids["video"] == ["2160"] + assert ids["audio"] == ["a-fp"] + assert "FairPlay-only" not in caplog.text + assert service.session.urls == [] + + +def test_a_quality_with_only_fairplay_only_tracks_skips_with_the_existing_reason( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + assert run(monkeypatch, caplog, Example(), quality=[2160]) == 1 + assert "Left out 2 FairPlay-only tracks" in caplog.text + assert "Show S01E01: There's no 2160p Video Track..." in caplog.text + + +def test_best_available_falls_back_to_the_track_that_licenses( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + ids = run(monkeypatch, caplog, Example(), quality=[2160], best_available=True) + + assert ids["video"] == ["1080"] + + +@pytest.mark.parametrize(("service", "expected"), [(Example, "1080"), (Bridged, "2160")], ids=["no-hook", "hook"]) +def test_a_dash_adaptation_set_with_only_a_fairplay_content_protection( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture, service: type[Example], expected: str +) -> None: + source = service(dash=True) + + ids = run(monkeypatch, caplog, source) + + assert ids["video"] == [expected] + assert source.session.urls == [] + + +def test_a_track_with_a_drm_object_costs_no_request( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + service = Example() + service.drm_on_2160 = [Widevine(PSSH.new(key_ids=[KID], system_id=PSSH.SystemId.Widevine))] + + ids = run(monkeypatch, caplog, service) + + assert ids["video"] == ["2160"] + assert f"{BASE}2160.m3u8" not in service.session.urls + + +def test_list_probes_nothing_and_lists_every_track( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + service = Example() + + ids = run(monkeypatch, caplog, service, list_=True) + + assert ids["video"] == ["2160", "1080"] + assert service.session.urls == [] + + +@pytest.mark.parametrize( + ("protections", "expected"), + [ + pytest.param((MP4_CP, FAIRPLAY_CP), True, id="fairplay"), + pytest.param((FAIRPLAY_CP, WIDEVINE_CP), False, id="fairplay-and-widevine-without-pssh"), + pytest.param((MP4_CP,), False, id="no-key-system"), + pytest.param((), False, id="clear"), + ], +) +def test_dash_fairplay_only_reads_the_key_systems_of_the_content_protection( + protections: tuple[str, ...], expected: bool +) -> None: + assert discovery.fairplay_only(video("v", 1080, Track.Descriptor.DASH, dash_data(*protections))) is expected + + +@pytest.mark.parametrize( + ("text", "expected"), + [(playlist(SKD_KEY), True), (playlist(SKD_KEY, WIDEVINE_KEY), False), (playlist(), False)], + ids=["fairplay", "fairplay-and-widevine", "clear"], +) +def test_hls_fairplay_only_reads_the_media_playlist(text: str, expected: bool) -> None: + session = SimpleNamespace(get=lambda url, **_: SimpleNamespace(text=text, ok=True)) + + assert discovery.fairplay_only(video("v", 1080, Track.Descriptor.HLS), session) is expected + + +class FairPlayAudio(Example): + """EXAMPLE whose only audio track is FairPlay-only.""" + + def get_tracks(self, title: Episode) -> Tracks: + tracks = super().get_tracks(title) + tracks.audio = [audio for audio in tracks.audio if audio.id == "a-fp"] + return tracks + + +def test_a_kind_whose_selected_tracks_are_all_fairplay_only_skips_the_title( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + assert run(monkeypatch, caplog, FairPlayAudio()) == 1 + assert "Show S01E01: Each selected audio track is FairPlay-only: FAKE has no FairPlay bridge hook" in caplog.text + + +class Imported(Example): + """An import: the export holds the content keys of each track, FairPlay-only ones too.""" + + @property + def key_arrival(self) -> KeyArrival: + return KeyArrival.EXPORT + + +def test_an_import_keeps_the_fairplay_only_tracks_and_probes_nothing( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + service = Imported() + + ids = run(monkeypatch, caplog, service) + + assert ids["video"] == ["2160"] + assert service.session.urls == [] + + +class Hybrid(Example): + """EXAMPLE with a 2160p HDR10 video that licenses and, unless ``dv`` is off, a FairPlay-only 2160p DV video.""" + + def __init__(self, dv: bool = True) -> None: + super().__init__() + self.dv = dv + + def get_tracks(self, title: Episode) -> Tracks: + tracks = super().get_tracks(title) + tracks.videos = [video("hdr", 2160, Track.Descriptor.HLS, range_=Video.Range.HDR10)] + if self.dv: + tracks.videos.append(video("dv", 2160, Track.Descriptor.HLS, range_=Video.Range.DV)) + self.videos = tracks.videos + return tracks + + +def test_a_hybrid_that_loses_its_dolby_vision_track_flags_the_base_as_if_it_had_none( + monkeypatch: pytest.MonkeyPatch, caplog: pytest.LogCaptureFixture +) -> None: + harness.stub_hybrid(monkeypatch) + flags = {"range_": [Video.Range.HYBRID, Video.Range.HDR10], "best_available": True} + results = [] + for service in (Hybrid(), Hybrid(dv=False)): + ids = run(monkeypatch, caplog, service, **flags) + hdr = service.videos[0] + results.append((ids["video"], hdr.hybrid_ingredient, hdr.hybrid_base_only, hdr.native_hybrid)) + + assert results[0] == results[1] + assert results[0][0] == ["hdr"] + + +def test_a_widevine_pssh_in_the_dash_init_segment_makes_the_track_licensable(monkeypatch: pytest.MonkeyPatch) -> None: + monkeypatch.setattr(discovery, "drm_from_init_segment", lambda track, session=None: ["widevine"]) + + assert not discovery.fairplay_only(video("v", 1080, Track.Descriptor.DASH, dash_data(MP4_CP, FAIRPLAY_CP))) diff --git a/tests/lang_selection/test_kind_only_selection.py b/tests/lang_selection/test_kind_only_selection.py index 161fc38e..4b5058a8 100644 --- a/tests/lang_selection/test_kind_only_selection.py +++ b/tests/lang_selection/test_kind_only_selection.py @@ -101,6 +101,7 @@ def run( service: FakeService | None = None, to_end: bool = False, download: Any = None, + log_level: int = logging.WARNING, **flags: Any, ) -> Any: """Return the Selected ids, the exit code, or None for a run that completes; to_end runs past selection. @@ -126,7 +127,7 @@ def run( kwargs[name] = None if param.default is inspect.Parameter.empty else param.default kwargs.update(quality=[], vcodec=[], acodec=[], range_=[], wanted=[], cdm_only=None, downloads=1) kwargs.update(flags) - caplog.set_level(logging.WARNING, logger="test_kind_only") + caplog.set_level(log_level, logger="test_kind_only") service = service or FakeService(episodes) try: cmd.result(service, **kwargs) diff --git a/unshackle/commands/dl.py b/unshackle/commands/dl.py index 671c762a..d63db48e 100644 --- a/unshackle/commands/dl.py +++ b/unshackle/commands/dl.py @@ -61,6 +61,7 @@ from unshackle.core.drm import ( MonaLisa, verify, ) +from unshackle.core.drm.discovery import fairplay_only from unshackle.core.drm.key_resolution import ContentKeyResolver from unshackle.core.drm.verify import has_encrypted_sample_entry from unshackle.core.events import events @@ -88,7 +89,7 @@ from unshackle.core.titles import Movie, Movies, Series, Song, Title_T from unshackle.core.titles.episode import Episode from unshackle.core.tracks import Audio, Subtitle, Tracks, Video from unshackle.core.tracks.attachment import Attachment -from unshackle.core.tracks.selection import Skip, TrackSelection, generated_dv_ranges +from unshackle.core.tracks.selection import Kept, Skip, TrackSelection, generated_dv_ranges from unshackle.core.tracks.subtitle_convert import PYCAPTION_WRITERS, SUBSTATION, build_ass_style from unshackle.core.tracks.track import Track, assert_fragments_decrypted, fix_data_reference_indexes from unshackle.core.utilities import ( @@ -2189,7 +2190,7 @@ class dl: elif proxy_download: console.log(f"Using a separate proxy for downloads: {mask_proxy(proxy_download)}") - outcome = selection.select(title, service.NO_SUBTITLES) + outcome = self.select_licensable(selection, title, service) if isinstance(outcome, Skip): skip_title(title, outcome.reason, outcome.kind_only) continue @@ -2243,11 +2244,6 @@ class dl: list(title.tracks), tracks_progress_callables, progress_sink ) - drm_pending = [track for track in title.tracks if getattr(track, "needs_drm_loading", False)] - if drm_pending: - with ThreadPoolExecutor(min(16, len(drm_pending))) as drm_pool: - list(drm_pool.map(lambda track: track.load_drm_if_needed(service), drm_pending)) - download_table = Table.grid() download_table.add_row(selected_tracks) @@ -2776,6 +2772,47 @@ class dl: console.print(Padding(f"Processed all titles in [progress.elapsed]{dl_time}", (0, 5, 1, 5))) return self.outcome() + def select_licensable(self, selection: TrackSelection, title: Title_T, service: TitleSource) -> Kept | Skip: + """Select the tracks of ``title`` and load their deferred DRM. + + Without a FairPlay bridge hook, a selected video or audio track with no DRM that is FairPlay-only leaves the + candidates and the selection runs again; each pass removes a track, so the loop ends. An import has the keys + of such a track in its export. A kind that loses each of its tracks skips the title. + """ + gate = service.fairplay_bridge() is None and service.key_arrival is not KeyArrival.EXPORT + + def prepare(track: AnyTrack) -> bool: + track.load_drm_if_needed(service) + return ( + gate and isinstance(track, (Video, Audio)) and not track.drm and fairplay_only(track, service.session) + ) + + candidates = Tracks(title.tracks) + probed: dict[str, bool] = {} + while True: + outcome = selection.select(title, service.NO_SUBTITLES) + if isinstance(outcome, Skip): + break + if pending := [track for track in title.tracks if track.id not in probed]: + with ThreadPoolExecutor(min(16, len(pending))) as pool: + probed.update(zip((track.id for track in pending), pool.map(prepare, pending), strict=True)) + if not any(probed[track.id] for track in title.tracks): + break + title.tracks = Tracks(candidates) + title.tracks.videos = [video for video in title.tracks.videos if not probed.get(video.id)] + title.tracks.audio = [audio for audio in title.tracks.audio if not probed.get(audio.id)] + if left_out := [track for track in candidates if probed.get(track.id)]: + count = len(left_out) + self.log.info( + f"Left out {count} FairPlay-only track{'s' * (count != 1)}: {self.service} has no FairPlay bridge hook" + ) + if isinstance(outcome, Skip): + return outcome + for kind, track_type, tracks in (("video", Video, title.tracks.videos), ("audio", Audio, title.tracks.audio)): + if not tracks and any(isinstance(track, track_type) for track in left_out): + return Skip(f"Each selected {kind} track is FairPlay-only: {self.service} has no FairPlay bridge hook") + return outcome + def write_sample(self, source: Path, title: Title_T, media_info: MediaInfo) -> None: """Cut a 60 second sample from a finished file into a ``Sample`` folder next to it. diff --git a/unshackle/core/drm/discovery.py b/unshackle/core/drm/discovery.py index 9506a266..7f7f2bc4 100644 --- a/unshackle/core/drm/discovery.py +++ b/unshackle/core/drm/discovery.py @@ -5,11 +5,15 @@ from __future__ import annotations import logging from typing import Any +import m3u8 + from unshackle.core.drm import WHOLE_FILE_DRM from unshackle.core.drm.playready import PlayReady from unshackle.core.drm.widevine import Widevine -from unshackle.core.manifests import DASH, ISM +from unshackle.core.manifests import DASH, HLS, ISM +from unshackle.core.session import utf8_text from unshackle.core.tracks import Track +from unshackle.core.utils import run_proxy log = logging.getLogger(__name__) @@ -87,6 +91,31 @@ def drm_from_init_segment(track: Any, session: Any = None, init_data: bytes | No return drms +def fairplay_only(track: Any, session: Any = None) -> bool: + """Whether a track with no DRM object is encrypted only for DRM systems that unshackle cannot license. + + DASH reads its ContentProtection and then its init segment, HLS its media playlist. A playlist that cannot be + read counts as false, so the download reports it. + """ + dash = track.data.get("dash") or {} + if dash.get("adaptation_set") is not None: + protections = DASH.find_elements("ContentProtection", dash["adaptation_set"], dash.get("representation"), True) + return DASH.only_unsupported_systems(protections) and not drm_from_init_segment(track, session) + if track.descriptor is not Track.Descriptor.HLS: + return False + try: + if track.from_file: + playlist = m3u8.load(str(track.from_file)) + else: + track.ensure_url() + response = (track.session or session or run_proxy.fallback_session()).get(track.url) + playlist = m3u8.loads(utf8_text(response), track.url) + except Exception as e: + log.debug(f"Could not read the playlist of {track.id} for its key tags: {e!r}") + return False + return HLS.only_unsupported_keys(playlist) + + def ensure_track_drm(track: Any, session: Any = None, init_data: bytes | None = None, bridge: bool = False) -> None: """Fill ``track.drm`` from the manifest when the track has none; a failure leaves it empty and never raises. diff --git a/unshackle/core/manifests/dash.py b/unshackle/core/manifests/dash.py index 12e10d51..c43b8b88 100644 --- a/unshackle/core/manifests/dash.py +++ b/unshackle/core/manifests/dash.py @@ -31,7 +31,7 @@ from unshackle.core.config import config from unshackle.core.constants import DOWNLOAD_ALL_DRM, DOWNLOAD_LICENCE_ONLY, AnyTrack from unshackle.core.downloaders.requests import parse_content_range, range_answers, request_range from unshackle.core.drm import DRM_T, ClearKeyCENC, PlayReady, Widevine -from unshackle.core.drm.cenc import COMMON_ID, PLACEHOLDER_KIDS, common_pssh_kids +from unshackle.core.drm.cenc import COMMON_ID, PLACEHOLDER_KIDS, PLAYREADY_ID, common_pssh_kids from unshackle.core.drm.segment_decrypt import SEGMENT_DRM_T, SegmentDecrypter, can_use from unshackle.core.drm.verify import walk from unshackle.core.manifests.segment_pipeline import ( @@ -53,6 +53,8 @@ from unshackle.core.utils.redact import safe_display_url from unshackle.core.utils.webvtt import shift_webvtt, webvtt_block_offsets from unshackle.core.utils.xml import load_xml +PLAYREADY_URNS = (f"urn:uuid:{PLAYREADY_ID}", "urn:microsoft:playready") +LICENSABLE_URNS = {WidevineCdm.urn, *PLAYREADY_URNS, ClearKeyCENC.urn, f"urn:uuid:{COMMON_ID}"} DOLBY_CHANNEL_SCHEMES = ( "tag:dolby.com,2014:dash:audio_channel_configuration:2011", "urn:dolby:dash:audio_channel_configuration:2011", @@ -1557,7 +1559,7 @@ class DASH: drm.append(Widevine(pssh=pssh, kid=kid)) - elif urn in ("urn:uuid:9a04f079-9840-4286-ab92-e65be0885f95", "urn:microsoft:playready"): + elif urn in PLAYREADY_URNS: pr_pssh_b64 = ( protection.findtext("pssh") or protection.findtext("{urn:mpeg:cenc:2013}pssh") @@ -1588,6 +1590,16 @@ class DASH: return drm + @staticmethod + def only_unsupported_systems(protections: list[Element]) -> bool: + """Whether `protections` name a DRM system, and none that unshackle can license. + + A PSSH in the init segment can still give a Widevine or PlayReady DRM. + """ + systems = {(p.get("schemeIdUri") or "").lower() for p in protections} + systems = {urn for urn in systems if urn.startswith("urn:uuid:") or urn in LICENSABLE_URNS} + return bool(systems) and not systems & LICENSABLE_URNS + @staticmethod def default_kid(protection: Element) -> UUID | None: """The default_KID of a ContentProtection, given as a UUID or base64, or None when it has none or it is no KID.""" diff --git a/unshackle/core/tracks/selection.py b/unshackle/core/tracks/selection.py index 721a9452..f94d77ab 100644 --- a/unshackle/core/tracks/selection.py +++ b/unshackle/core/tracks/selection.py @@ -118,6 +118,7 @@ class TrackSelection: subtitles_unsupported is the service's NO_SUBTITLES read after get_tracks, which can set it. The required-language gate runs first, on the tracks before any filter, so a miss there is never kind-only. + It clears the hybrid flags of the videos first, so a second select of the same tracks starts afresh. """ v_lang, a_lang, s_lang, range_ = self.v_lang, self.a_lang, self.s_lang, self.range_ vbitrate_min, vbitrate_max, abitrate_min, abitrate_max = ( @@ -164,6 +165,9 @@ class TrackSelection: if self.no_attachments: console.log("Skipped attachments as --no-attachments was used...") + for video in title.tracks.videos: + video.hybrid_ingredient = video.hybrid_base_only = video.native_hybrid = False + missing_required: list[str] = [] for kind, required, available in ( (