-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_api.dart
More file actions
72 lines (56 loc) · 2.4 KB
/
base_api.dart
File metadata and controls
72 lines (56 loc) · 2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import 'package:dart_music_api/music_api.dart';
import 'package:dart_music_api/src/models/play_list_detail.dart';
import 'package:dart_music_api/src/response_pack.dart';
import 'package:dart_music_api/src/models/artist_detail.dart';
import 'package:dio/dio.dart';
// TODO 增添异常处理
class CombinedSearchResult {
final ResultCursor<String, ListResponsePack<Song>> songs;
final ResultCursor<String, ListResponsePack<PlayList>> playlists;
final ResultCursor<String, ListResponsePack<Artist>> artists;
final ResultCursor<String, ListResponsePack<Album>> albums;
CombinedSearchResult({
required this.songs,
required this.playlists,
required this.artists,
required this.albums,
});
}
abstract class MusicApi {
MusicApi();
void configureDio(void Function(Dio dio) configure);
/// 执行初始化操作
/// 网易云: 在这里执行匿名登录操作
Future<void> init() async {
// do nothing default
}
// search
/// 搜索单曲
/// Notes: 网易云的单曲搜索 api 可能不包含歌手头像
ResultCursor<String, ListResponsePack<Song>> searchSongs(String str);
ResultCursor<String, ListResponsePack<PlayList>> searchPlayLists(String str);
ResultCursor<String, ListResponsePack<Artist>> searchArtistes(String str);
ResultCursor<String, ListResponsePack<Album>> searchAlbums(String str);
CombinedSearchResult combineSearch(String str);
// song
Future<ResponsePack<SongDetail>> songDetails(String id);
Future<ListResponsePack<SongDetail>> songsDetails(List<String> ids);
Future<ResponsePack<SongUri>> songUri(String id, {BigInt? bitRate});
/// 获取歌曲播放地址
String simpleSongUrl(String id);
Future<ResponsePack<SongLyrics>> songLyrics(String id);
// TODO 实现这个 https://binaryify.github.io/NeteaseCloudMusicApi/#/?id=获取音乐-url
// album
Future<ResponsePack<AlbumDetail>> albumDetails(String id);
// play list
/// 获取歌单详情
Future<ResponsePack<PlayListDetail>> playListDetails(String id);
/// 获取歌单音乐
ResultCursor<PlayListDetail, ListResponsePack<Song>> playListSongs(
PlayListDetail playListDetail,
);
// artist
// TODO 增加获取歌手描述 https://binaryify.github.io/NeteaseCloudMusicApi/#/?id=%e8%8e%b7%e5%8f%96%e6%ad%8c%e6%89%8b%e6%8f%8f%e8%bf%b0
Future<ResponsePack<ArtistDetail>> artistDetails(String id);
ResultCursor<String, ListResponsePack<Song>> artistSongs(String id);
}