# Path: fuocore/qqmusic/models.py
# class QQArtistModel(ArtistModel, QQBaseModel):
#     @classmethod
#     def get(cls, identifier):
#         data_artist = cls._api.artist_detail(identifier)
#         artist = _deserialize(data_artist, QQArtistSchema)
#         artist.cover = cls._api.get_cover(artist.mid, 1)
#         return artist
# 
# class QQSongModel(SongModel, QQBaseModel):
# 
#     @classmethod
#     def get(cls, identifier):
#         data = cls._api.get_song_detail(identifier)
#         song = _deserialize(data, QQSongDetailSchema)
#         return song
# 
#     @property
#     def url(self):
#         if self._url is not None:
#             return self._url
#         url = self._api.get_song_url(self.mid)
#         if url is not None:
#             self._url = url
#         else:
#             self._url = ''
#         return self._url
# 
#     @url.setter
#     def url(self, url):
#         self._url = url
# 
# class QQAlbumModel(AlbumModel, QQBaseModel):
#     @classmethod
#     def get(cls, identifier):
#         data_album = cls._api.album_detail(identifier)
#         album = _deserialize(data_album, QQAlbumSchema)
#         album.cover = cls._api.get_cover(album.mid, 2)
#         return album


from marshmallow import Schema, fields, post_load
from .models import (
    QQArtistModel,
    QQSongModel,
    QQAlbumModel,
)  # noqa
    """歌手详情 Schema、歌曲歌手简要信息 Schema"""

    identifier = fields.Int(load_from='singer_id', required=True)
    mid = fields.Str(load_from='singer_mid', required=True)
    name = fields.Str(load_from='singer_name', required=True)

    desc = fields.Str(load_from='SingerDesc')
    songs = fields.List(fields.Nested(_ArtistSongSchema), load_from='list')

    @post_load
    def create_model(self, data):
        if data['songs']:
            data['songs'] = [song['value'] for song in data['songs']]
        return QQArtistModel(**data)


class QQAlbumSchema(Schema):
    identifier = fields.Int(load_from='id', required=True)
    mid = fields.Str(load_from='mid', required=True)
    name = fields.Str(required=True)
    desc = fields.Str(required=True)

    artist_id = fields.Int(load_from='singerid', required=True)
    artist_name = fields.Str(load_from='singername', required=True)

    # 有的专辑歌曲列表为 null，比如：fuo://qqmusic/albums/8623
    songs = fields.List(fields.Nested(QQSongSchema), load_from='list', allow_none=True)

    @post_load
    def create_model(self, data):

# Path: fuocore/qqmusic/models.py
# class QQArtistModel(ArtistModel, QQBaseModel):
#     @classmethod
#     def get(cls, identifier):
#         data_artist = cls._api.artist_detail(identifier)
#         artist = _deserialize(data_artist, QQArtistSchema)
#         artist.cover = cls._api.get_cover(artist.mid, 1)
#         return artist
# 
# class QQSongModel(SongModel, QQBaseModel):
# 
#     @classmethod
#     def get(cls, identifier):
#         data = cls._api.get_song_detail(identifier)
#         song = _deserialize(data, QQSongDetailSchema)
#         return song
# 
#     @property
#     def url(self):
#         if self._url is not None:
#             return self._url
#         url = self._api.get_song_url(self.mid)
#         if url is not None:
#             self._url = url
#         else:
#             self._url = ''
#         return self._url
# 
#     @url.setter
#     def url(self, url):
#         self._url = url
# 
# class QQAlbumModel(AlbumModel, QQBaseModel):
#     @classmethod
#     def get(cls, identifier):
#         data_album = cls._api.album_detail(identifier)
#         album = _deserialize(data_album, QQAlbumSchema)
#         album.cover = cls._api.get_cover(album.mid, 2)
#         return album


# Path: fuocore/qqmusic/schemas.py
from marshmallow import Schema, fields, post_load
from .models import (
    QQArtistModel,
    QQSongModel,
    QQAlbumModel,
)  # noqa

    """歌手详情 Schema、歌曲歌手简要信息 Schema"""

    identifier = fields.Int(load_from='singer_id', required=True)
    mid = fields.Str(load_from='singer_mid', required=True)
    name = fields.Str(load_from='singer_name', required=True)

    desc = fields.Str(load_from='SingerDesc')
    songs = fields.List(fields.Nested(_ArtistSongSchema), load_from='list')

    @post_load
    def create_model(self, data):
        if data['songs']:
            data['songs'] = [song['value'] for song in data['songs']]
        return QQArtistModel(**data)


class QQAlbumSchema(Schema):
    identifier = fields.Int(load_from='id', required=True)
    mid = fields.Str(load_from='mid', required=True)
    name = fields.Str(required=True)
    desc = fields.Str(required=True)

    artist_id = fields.Int(load_from='singerid', required=True)
    artist_name = fields.Str(load_from='singername', required=True)

    # 有的专辑歌曲列表为 null，比如：fuo://qqmusic/albums/8623
    songs = fields.List(fields.Nested(QQSongSchema), load_from='list', allow_none=True)

    @post_load
    def create_model(self, data):

        artist = QQArtistModel(identifier=data['artist_id'],