From d2d8cddb77d840b09d5ac8739ed8e5b8815288e6 Mon Sep 17 00:00:00 2001 From: gotik Date: Fri, 20 Apr 2012 01:33:29 +0200 Subject: [PATCH] Klasse MCGTrack hinzugef?gt --- mcg.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/mcg.py b/mcg.py index e61be24..7bc03a9 100644 --- a/mcg.py +++ b/mcg.py @@ -125,9 +125,14 @@ class MCGClient: for song in self._client.listallinfo(): try: if song['album'] not in self._albums: - album = MCGAlbum(song['artist'], song['album'], os.path.dirname(song['file'])) + album = MCGAlbum(song['artist'], song['album'], song['date'], os.path.dirname(song['file'])) self._albums[song['album']] = album self._callback(self.SIGNAL_UPDATE, album) + else: + album = self._albums[song['album']] + + track = MCGTrack(song['title'], song['track'], song['time'], song['file']) + album.add_track(track) except KeyError: pass self._start_idle() @@ -173,12 +178,14 @@ class MCGAlbum: _file_exts = ['jpg', 'jpeg', 'png'] - def __init__(self, artist, title, path): + def __init__(self, artist, title, date, path): self._artist = artist if type(self._artist) is list: self._artist = self._artist[0] self._title = title + self._date = date self._path = path + self._tracks = [] self._cover = None self._find_cover() @@ -191,10 +198,23 @@ class MCGAlbum: return self._title + def get_date(self): + return self._date + + def get_path(self): return self._path + def add_track(self, track): + if track not in self._tracks: + self._tracks.append(track) + + + def get_tracks(self): + return self._tracks + + def get_cover(self): return self._cover @@ -214,3 +234,29 @@ class MCGAlbum: if self._cover is not None: break + + + +class MCGTrack: + def __init__(self, title, track, time, file): + self._title = title + self._track = track + self._time = time + self._file = file + + + def get_title(self): + return self._title + + + def get_track(self): + return self._track + + + def get_time(self): + return self._time + + + def get_file(self): + return self._file +