对外接口¶
这部分文档覆盖了 fuocore 对外提供的所有模块和接口。
-
class
fuocore.models.BaseModel(*args, **kwargs)[源代码]¶ Base model for music resource.
参数: identifier – model object identifier, unique in each provider
变量: - allow_get – meta var, whether model has a valid get method
- allow_list – meta var, whether model has a valid list method
-
class
fuocore.models.SongModel(*args, **kwargs)[源代码]¶ Song Model
参数: - title (str) – song title
- url (str) – song url (http url or local filepath)
- duration (float) – song duration
- album (AlbumModel) – album which song belong to
- artists (list) – song artists
ArtistModel - lyric (LyricModel) – song lyric
-
class
fuocore.models.LyricModel(*args, **kwargs)[源代码]¶ Lyric Model
参数: - song (SongModel) – song which lyric belongs to
- content (str) – lyric content
- trans_content (str) – translated lyric content
-
class
fuocore.models.AlbumModel(*args, **kwargs)[源代码]¶ Album Model
参数: - name (str) – album name
- cover (str) – album cover image url
- songs (list) – album songs
- artists (list) – album artists
- desc (str) – album description
-
class
fuocore.models.ArtistModel(*args, **kwargs)[源代码]¶ Artist Model
参数: - name (str) – artist name
- cover (str) – artist cover image url
- songs (list) – artist songs
- desc (str) – artist description
-
class
fuocore.models.PlaylistModel(*args, **kwargs)[源代码]¶ Playlist Model
参数: - name – playlist name
- cover – playlist cover image url
- desc – playlist description
- songs – playlist songs
-
class
fuocore.models.UserModel(*args, **kwargs)[源代码]¶ User Model
参数: - name – user name
- playlists – playlists created by user
- fav_playlists – playlists collected by user
- fav_songs – songs collected by user
- fav_albums – albums collected by user
- fav_artists – artists collected by user
-
class
fuocore.models.SearchModel(*args, **kwargs)[源代码]¶ Search Model
参数: - q – search query string
- songs – songs in search result
TODO: support album and artist
-
class
fuocore.provider.AbstractProvider[源代码]¶ abstract music resource provider
-
Song¶
-
Artist¶
-
Album¶
-
Playlist¶
-
Lyric¶
-
User¶
-
identifier¶ provider identify
-
name¶ provider name
-
-
class
fuocore.player.PlaybackMode[源代码]¶ Playlist playback mode.
-
one_loop= 0¶ One Loop
-
sequential= 1¶ Sequential
-
loop= 2¶ Loop
-
random= 3¶ Random
-
-
class
fuocore.player.Playlist(songs=None, playback_mode=<PlaybackMode.loop: 2>)[源代码]¶ player playlist provide a list of song model to play
NOTE - Design: Why we use song model instead of url? Theoretically, using song model may increase the coupling. However, simple url do not obtain enough metadata.
-
playback_mode_changed= None¶ playback mode changed signal
-
song_changed= None¶ current song changed signal
-
remove(song)[源代码]¶ Remove song from playlist. O(n)
If song is current song, remove the song and play next. Otherwise, just remove it.
-
current_song¶ current playing song, return None if there is no current song
-
next_song¶ next song for player, calculated based on playback_mode
-
previous_song¶ previous song for player to play
NOTE: not the last played song
-
-
class
fuocore.live_lyric.LiveLyric[源代码]¶ live lyric
LiveLyric listens to song changed signal and position changed signal and emit sentence changed signal. It also has a
current_sentenceproperty.Usage:
live_lyric = LiveLyric() player.song_changed.connect(live_lyric.on_song_changed) player.position_change.connect(live_lyric.on_position_changed)
-
current_sentence¶ get current lyric sentence
-