From 766b97a00129b73970d998976ee952f913130d68 Mon Sep 17 00:00:00 2001 From: kaliko Date: Wed, 11 Jun 2014 15:45:33 +0200 Subject: [PATCH] Fixed type issue with depth/recursion --- sima/lib/meta.py | 10 ---------- sima/lib/track.py | 8 +++++++- sima/lib/webserv.py | 13 ++++++------- 3 files changed, 13 insertions(+), 18 deletions(-) diff --git a/sima/lib/meta.py b/sima/lib/meta.py index 4e481e6..a3efbf5 100644 --- a/sima/lib/meta.py +++ b/sima/lib/meta.py @@ -22,7 +22,6 @@ Defines some object to handle audio file metadata """ from .simastr import SimaStr -from .track import Track class MetaException(Exception): """Generic Meta Exception""" @@ -109,14 +108,5 @@ class Artist(Meta): else: raise NotSameArtist('different mbids: {0} and {1}'.format(self, other)) - -class TrackMB(Track): - - def __init__(self, **kwargs): - super().__init__(**kwargs) - if hasattr(self, 'musicbrainz_artistid'): - self.artist = Artist(mbid=self.musicbrainz_artistid, - name=self.artist) - # vim: ai ts=4 sw=4 sts=4 expandtab diff --git a/sima/lib/track.py b/sima/lib/track.py index 5a01e17..a938c27 100644 --- a/sima/lib/track.py +++ b/sima/lib/track.py @@ -1,6 +1,6 @@ # -*- 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 # @@ -23,6 +23,7 @@ import time +from .meta import Artist class Track: """ @@ -32,6 +33,7 @@ class Track: def __init__(self, file=None, time=0, pos=-1, **kwargs): self.title = self.artist = self.album = self.albumartist = '' + self.musicbrainz_artistid = None self.pos = int(pos) self._empty = False self._file = file @@ -124,5 +126,9 @@ class Track: fmt = '%M:%S' return time.strftime(fmt, temps) + def get_artist(self): + """Get artist object from track""" + return Artist(name=self.artist, mbid=self.musicbrainz_artistid) + # VIM MODLINE # vim: ai ts=4 sw=4 sts=4 expandtab diff --git a/sima/lib/webserv.py b/sima/lib/webserv.py index 75b0a38..c84c78c 100644 --- a/sima/lib/webserv.py +++ b/sima/lib/webserv.py @@ -208,17 +208,16 @@ class WebService(Plugin): if len(history) == 0: break trk = history.popleft() - if (trk.artist in [trk.artist for trk in extra_arts] - or trk.artist == current.artist): + if (trk.get_artist() in extra_arts + or trk.get_artist() == current.get_artist()): continue - extra_arts.append(trk) + extra_arts.append(trk.get_artist()) depth += 1 self.log.info('EXTRA ARTS: {}'.format( - '/'.join([trk.artist for trk in extra_arts]))) + '/'.join([art.name for art in extra_arts]))) for artist in extra_arts: - self.log.debug( - 'Looking for artist similar to "{0.artist}" as well'.format( - artist)) + self.log.debug('Looking for artist similar ' + 'to "{}" as well'.format(artist)) similar = self.ws_similar_artists(artist=artist) if not similar: return ret_extra -- 2.39.5