Skip to content

Commit

Permalink
Simplify Tracks.__add__ method, support Chapter(s) & Track objects
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaphoenix committed Feb 29, 2024
1 parent 97efb59 commit be0ed0b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions devine/core/tracks/tracks.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ def __iter__(self) -> Iterator[AnyTrack]:
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(
Expand Down

0 comments on commit be0ed0b

Please sign in to comment.