From 0c20160ddc2542889ec6d18dad99aa69b80fdb4d Mon Sep 17 00:00:00 2001 From: rlaphoenix Date: Tue, 20 Feb 2024 22:06:39 +0000 Subject: [PATCH] Implement `__add__` to Tracks class --- devine/core/tracks/tracks.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/devine/core/tracks/tracks.py b/devine/core/tracks/tracks.py index 108dcf7..1906b00 100644 --- a/devine/core/tracks/tracks.py +++ b/devine/core/tracks/tracks.py @@ -51,6 +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 __repr__(self) -> str: return "{name}({items})".format( name=self.__class__.__name__,