X-Git-Url: https://git.kaliko.me/?a=blobdiff_plain;f=sima%2Flib%2Ftrack.py;h=55fb3675403d81507b12fd1b87419e46c1e51a4c;hb=a6a2ea116e050cd0f1c3f81a392878bcd22a5960;hp=93aa350bbc4d24d612e2232e8c7a8d1de19d0a90;hpb=1cc879f39941fc302f9a841a532c9f749797cca4;p=mpd-sima.git diff --git a/sima/lib/track.py b/sima/lib/track.py index 93aa350..55fb367 100644 --- a/sima/lib/track.py +++ b/sima/lib/track.py @@ -1,46 +1,48 @@ # -*- coding: utf-8 -*- -# Copyright (c) 2009, 2010, 2011, 2013 Jack Kaliko +# Copyright (c) 2009, 2010, 2011, 2013, 2014 Jack Kaliko # Copyright (c) 2009 J. Alexander Treuman (Tag collapse method) # Copyright (c) 2008 Rick van Hattem # -# This file is part of MPD_sima +# This file is part of sima # -# MPD_sima is free software: you can redistribute it and/or modify +# sima is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # -# MPD_sima is distributed in the hope that it will be useful, +# sima is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with MPD_sima. If not, see . +# along with sima. If not, see . # # import time +from .meta import Artist -class Track(object): +class Track: """ Track object. - Instanciate with mpd replies. + Instanciate with Player replies. """ - def __init__(self, file=None, time=0, pos=0, **kwargs): + def __init__(self, file=None, time=0, pos=-1, **kwargs): self.title = self.artist = self.album = self.albumartist = '' - self._pos = pos - self.empty = False + self.musicbrainz_artistid = None + self.pos = int(pos) + self._empty = False self._file = file if not kwargs: - self.empty = True - self.time = time + self._empty = True + self._time = time self.__dict__.update(**kwargs) - self.tags_to_collapse = list(['artist', 'album', 'title', 'date', - 'genre', 'albumartist']) + self.tags_to_collapse = ['artist', 'album', 'title', 'date', + 'genre', 'albumartist'] # have tags been collapsed? self.collapse_tags_bool = False self.collapsed_tags = list() @@ -60,12 +62,6 @@ class Track(object): self.collapsed_tags.append(tag) self.__dict__.update({tag: ', '.join(set(value))}) - def get_filename(self): - """return filename""" - if not self.file: - return None - return self.file - def __repr__(self): return '%s(artist="%s", album="%s", title="%s", filename="%s")' % ( self.__class__.__name__, @@ -103,12 +99,7 @@ class Track(object): return hash(self) != hash(other) def __bool__(self): - return not self.empty - - @property - def pos(self): - """return position of track in the playlist""" - return int(self._pos) + return not self._empty @property def file(self): @@ -135,13 +126,10 @@ class Track(object): fmt = '%M:%S' return time.strftime(fmt, temps) - -def main(): - pass - -# Script starts here -if __name__ == '__main__': - main() + def get_artist(self): + """Get artist object from track""" + return Artist(name=self.albumartist or self.artist, + mbid=self.musicbrainz_artistid) # VIM MODLINE # vim: ai ts=4 sw=4 sts=4 expandtab