diff --git a/wobuzz/__init__.py b/wobuzz/__init__.py new file mode 100644 index 0000000..a93a4bf --- /dev/null +++ b/wobuzz/__init__.py @@ -0,0 +1 @@ +#!/usr/bin/python3 diff --git a/wobuzz/player/playlist.py b/wobuzz/player/playlist.py index a93909f..2c1a9d2 100644 --- a/wobuzz/player/playlist.py +++ b/wobuzz/player/playlist.py @@ -33,8 +33,8 @@ class Playlist: m3u = file.read() file.close() - lines = m3u.split("\n") # m3u entries - lines = lines[:-1] + lines = m3u.split("\n") # m3u entries are separated by newlines + lines = lines[:-1] # remove last entry because it is just an empty string i = 0 num_lines = len(lines) diff --git a/wobuzz/player/track.py b/wobuzz/player/track.py index a6fd9e2..04ee851 100644 --- a/wobuzz/player/track.py +++ b/wobuzz/player/track.py @@ -6,6 +6,13 @@ from pygame.mixer import Sound from tinytag import TinyTag +SUPPORTED_FORMATS = [ + "mp3", + "wav", + "ogg" +] + + class Track: """ Class containing data for a track like file path, raw data... @@ -27,7 +34,7 @@ class Track: self.cache() def cache(self): - self.audio = AudioSegment.from_mp3(self.path) + self.load_audio() # audio = normalize(audio) wav = self.audio.export(format="wav") @@ -38,6 +45,12 @@ class Track: self.cached = True + def load_audio(self): + type = self.path.split(".")[-1] + + if type in SUPPORTED_FORMATS: + self.audio = AudioSegment.from_file(self.path) + def remaining(self, position: int): remaining_audio = self.audio[position:]