Skip to content
This repository has been archived by the owner on Jun 30, 2019. It is now read-only.

Commit

Permalink
Fix some bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
cyliuu committed Dec 4, 2018
1 parent ba3e989 commit c5629c6
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
8 changes: 4 additions & 4 deletions fuocore/local/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,27 +38,27 @@ class LSongModel(SongModel, LBaseModel):

@classmethod
def get(cls, identifier):
return cls.meta.provider._identifier_song_map.get(identifier)
return cls.meta.provider.identifier_song_map.get(identifier)

@classmethod
def list(cls, identifier_list):
return map(cls.meta.provider._identifier_song_map.get, identifier_list)
return map(cls.meta.provider.identifier_song_map.get, identifier_list)


class LAlbumModel(AlbumModel, LBaseModel):
_detail_fields = ('songs',)

@classmethod
def get(cls, identifier):
return cls.meta.provider._identifier_album_map.get(identifier)
return cls.meta.provider.identifier_album_map.get(identifier)


class LArtistModel(ArtistModel, LBaseModel):
_detail_fields = ('songs',)

@classmethod
def get(cls, identifier):
return cls.meta.provider._identifier_artist_map.get(identifier)
return cls.meta.provider.identifier_artist_map.get(identifier)


class LSearchModel(SearchModel, LBaseModel):
Expand Down
25 changes: 20 additions & 5 deletions fuocore/local/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,8 @@ def setup_library(self):
else:
self._artists[album_artist.identifier].albums.append(album)
for artist in self._artists.values():
if artist.albums:
artist.albums.sort(key=lambda x: (x.songs[0].date is None, x.songs[0].date), reverse=True)
# if artist.albums:
# artist.albums.sort(key=lambda x: (x.songs[0].date is None, x.songs[0].date), reverse=True)
if artist.songs:
artist.songs.sort(key=lambda x: x.title)

Expand All @@ -182,9 +182,12 @@ class LocalProvider(AbstractProvider):
def __init__(self):
super().__init__()

self._songs = dict()
self._albums = dict()
self._artists = dict()
self._identifier_song_map = dict()
self._identifier_album_map = dict()
self._identifier_artist_map = dict()
self._songs = []
self._albums = []
self._artists = []

def scan(self, paths=None, depth=2):
scanner = Scanner(paths or [], depth=depth)
Expand All @@ -204,6 +207,18 @@ def identifier(self):
def name(self):
return '本地音乐'

@property
def identifier_song_map(self):
return self._identifier_song_map

@property
def identifier_artist_map(self):
return self._identifier_artist_map

@property
def identifier_album_map(self):
return self._identifier_album_map

@property
def songs(self):
return self._songs
Expand Down

0 comments on commit c5629c6

Please sign in to comment.