|
@@ -4,7 +4,7 @@ import re
|
|
|
|
|
|
import mutagen
|
|
import mutagen
|
|
|
|
|
|
-import symuid.tag_interface
|
|
|
|
|
|
+from symuid import _tag_interface
|
|
|
|
|
|
|
|
|
|
def _timestamp_to_utc_dt(ts_sec):
|
|
def _timestamp_to_utc_dt(ts_sec):
|
|
@@ -46,15 +46,18 @@ class Track:
|
|
PATH_DEFAULT_IGNORE_REGEX = r'\.(itdb|itc2|itl|jpg|midi?|plist|xml|zip)$'
|
|
PATH_DEFAULT_IGNORE_REGEX = r'\.(itdb|itc2|itl|jpg|midi?|plist|xml|zip)$'
|
|
|
|
|
|
def __init__(self, path):
|
|
def __init__(self, path):
|
|
- mutagen_file = mutagen.File(path)
|
|
|
|
|
|
+ self._iface = self._select_tag_interface(path)
|
|
|
|
+
|
|
|
|
+ @staticmethod
|
|
|
|
+ def _select_tag_interface(track_path) -> _tag_interface.TagInterface:
|
|
|
|
+ mutagen_file = mutagen.File(track_path)
|
|
if mutagen_file is None:
|
|
if mutagen_file is None:
|
|
- raise NotImplementedError(path)
|
|
|
|
|
|
+ raise NotImplementedError(track_path)
|
|
if isinstance(mutagen_file.tags, mutagen.id3.ID3):
|
|
if isinstance(mutagen_file.tags, mutagen.id3.ID3):
|
|
- self._iface = symuid.tag_interface.ID3(mutagen_file)
|
|
|
|
- elif isinstance(mutagen_file.tags, mutagen.mp4.MP4Tags):
|
|
|
|
- self._iface = symuid.tag_interface.MP4(mutagen_file)
|
|
|
|
- else:
|
|
|
|
- raise NotImplementedError((path, type(mutagen_file)))
|
|
|
|
|
|
+ return _tag_interface.ID3(mutagen_file)
|
|
|
|
+ if isinstance(mutagen_file.tags, mutagen.mp4.MP4Tags):
|
|
|
|
+ return _tag_interface.MP4(mutagen_file)
|
|
|
|
+ raise NotImplementedError((track_path, type(mutagen_file)))
|
|
|
|
|
|
@property
|
|
@property
|
|
def path(self):
|
|
def path(self):
|