Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX #75] Fix successive track removal #76

Open
wants to merge 1 commit into
base: release/1.0.9
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 11 additions & 10 deletions pymkv/MKVFile.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

import bitmath

from pymkv.MKVTrack import MKVTrack
from pymkv.MKVTrack import MKVTrack, MKVTrackIdNotFound
from pymkv.MKVAttachment import MKVAttachment
from pymkv.Timestamp import Timestamp
from pymkv.ISO639_2 import is_ISO639_2
Expand Down Expand Up @@ -478,23 +478,24 @@ def replace_track(self, track_num, track):
else:
raise IndexError('track index out of range')

def remove_track(self, track_num):
def remove_track(self, track_id):
"""Remove a track from the :class:`~pymkv.MKVFile` object.

Parameters
----------
track_num : int
The track number of the track to remove.
track_id: int
The track id of the track to remove.

Raises
------
IndexError
Raised if `track_num` is is out of range of the track list.
MKVTrackIdNotFound
Raised if `track_id` is not found in the track list.
"""
if 0 <= track_num < len(self.tracks):
del self.tracks[track_num]
else:
raise IndexError('track index out of range')
for track in self.tracks:
if (track.track_id == track_id):
self.tracks.remove(track)
return
raise MKVTrackIdNotFound('Track id not found in the track list')

def split_none(self):
"""Remove all splitting options."""
Expand Down
3 changes: 3 additions & 0 deletions pymkv/MKVTrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,3 +258,6 @@ def track_codec(self):
def track_type(self):
"""str: The type of track such as video or audio."""
return self._track_type

class MKVTrackIdNotFound(Exception):
pass