correct playlist positioning
This commit is contained in:
parent
78f0cdd953
commit
03c5822c4c
1 changed files with 22 additions and 24 deletions
46
mcg.py
46
mcg.py
|
@ -298,19 +298,14 @@ class MCGClient(MCGBase, mpd.MPDClient):
|
||||||
album = self._albums[hash]
|
album = self._albums[hash]
|
||||||
|
|
||||||
# Position
|
# Position
|
||||||
if track.get_track() is not None:
|
pos = 0
|
||||||
pos = track.get_track() -1
|
if 'pos' in song:
|
||||||
else:
|
pos = int(song['pos'])
|
||||||
for album in self._playlist:
|
for palbum in self._playlist:
|
||||||
pos = -1
|
if palbum == album and len(palbum.get_tracks()) >= pos:
|
||||||
for ptrack in album.get_tracks():
|
album = palbum
|
||||||
pos = pos + 1
|
break
|
||||||
if ptrack == track:
|
pos = pos - len(palbum.get_tracks())
|
||||||
break
|
|
||||||
if pos < len(album.get_tracks())-1:
|
|
||||||
break
|
|
||||||
if pos is None:
|
|
||||||
pos = 0
|
|
||||||
|
|
||||||
self._state = state
|
self._state = state
|
||||||
self._callback(MCGClient.SIGNAL_STATUS, state, album, pos, time, volume, error)
|
self._callback(MCGClient.SIGNAL_STATUS, state, album, pos, time, volume, error)
|
||||||
|
@ -484,6 +479,10 @@ class MCGAlbum:
|
||||||
self._set_hash()
|
self._set_hash()
|
||||||
|
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
return self._hash == other.get_hash()
|
||||||
|
|
||||||
|
|
||||||
def get_artists(self):
|
def get_artists(self):
|
||||||
return self._artists
|
return self._artists
|
||||||
|
|
||||||
|
@ -507,17 +506,16 @@ class MCGAlbum:
|
||||||
|
|
||||||
|
|
||||||
def add_track(self, track):
|
def add_track(self, track):
|
||||||
if track not in self._tracks:
|
self._tracks.append(track)
|
||||||
self._tracks.append(track)
|
self._length = self._length + track.get_length()
|
||||||
self._length = self._length + track.get_length()
|
for artist in track.get_artists():
|
||||||
for artist in track.get_artists():
|
if artist not in self._artists:
|
||||||
if artist not in self._artists:
|
self._artists.append(artist)
|
||||||
self._artists.append(artist)
|
if track.get_date() is not None and track.get_date() not in self._dates:
|
||||||
if track.get_date() is not None and track.get_date() not in self._dates:
|
self._dates.append(track.get_date())
|
||||||
self._dates.append(track.get_date())
|
path = os.path.dirname(track.get_file())
|
||||||
path = os.path.dirname(track.get_file())
|
if path not in self._pathes:
|
||||||
if path not in self._pathes:
|
self._pathes.append(path)
|
||||||
self._pathes.append(path)
|
|
||||||
|
|
||||||
|
|
||||||
def get_tracks(self):
|
def get_tracks(self):
|
||||||
|
|
Loading…
Reference in a new issue