From be0ed0b0fbea611c0f9c7314efb007206a1394cd Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Thu, 29 Feb 2024 23:19:05 +0000 Subject: [PATCH] Simplify `Tracks.__add__` method, support Chapter(s) & Track objects --- devine/core/tracks/tracks.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/devine/core/tracks/tracks.py b/devine/core/tracks/tracks.py index 1906b00..6a487af 100644 --- a/devine/core/tracks/tracks.py +++ b/devine/core/tracks/tracks.py @@ -51,11 +51,12 @@ class Tracks: def __len__(self) -> int: return len(self.videos) + len(self.audio) + len(self.subtitles) - def __add__(self, other: Tracks) -> Tracks: - if not isinstance(other, Tracks): - raise TypeError(f"Cannot only add {Tracks} objects with one another, not {type(other)}") - - return Tracks(list(self) + list(other)) + def __add__( + self, + other: Union[Tracks, Sequence[Union[AnyTrack, Chapter, Chapters]], Track, Chapter, Chapters] + ) -> Tracks: + self.add(other) + return self def __repr__(self) -> str: return "{name}({items})".format(