-
Notifications
You must be signed in to change notification settings - Fork 0
/
MusicNetPlatform.cs
79 lines (67 loc) · 2.77 KB
/
MusicNetPlatform.cs
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
73
74
75
76
77
78
79
using NetMusicLib.Enums;
using NetMusicLib.Models;
using NetMusicLib.MusicProvider;
using NetMusicLib.SearchProvider;
namespace NetMusicLib;
public class MusicNetPlatform
{
private readonly SearchManager _searchManager;
private readonly IEnumerable<IMusicProvider> _musicProviderList;
public MusicNetPlatform(IEnumerable<IMusicProvider> musicProviderList, SearchManager searchManager)
{
_musicProviderList = musicProviderList;
_searchManager = searchManager;
}
private IMusicProvider GetMusicProvider(PlatformEnum platform)
{
return _musicProviderList.First(x => x.Platform == platform);
}
public async Task<List<string>> GetHotWordAsync()
{
return await GetMusicProvider(PlatformEnum.KuWo).GetHotWordAsync();
}
public async Task<List<string>> GetSearchSuggestAsync(string keyword)
{
return await GetMusicProvider(PlatformEnum.NetEase).GetSearchSuggestAsync(keyword);
}
public async Task<List<Music>> SearchAsync(PlatformEnum platform, string keyword)
{
return await _searchManager.DoSearchesAsync(platform, keyword);
}
public async Task<string> GetPlayUrlAsync(PlatformEnum platform, string id, string extendDataJson = "")
{
return await GetMusicProvider(platform).GetPlayUrlAsync(id, extendDataJson);
}
public async Task<string> GetImageUrlAsync(PlatformEnum platform, string id, string extendDataJson = "")
{
return await GetMusicProvider(platform).GetImageUrlAsync(id, extendDataJson);
}
public async Task<string> GetLyricAsync(PlatformEnum platform, string id, string extendDataJson = "")
{
return await GetMusicProvider(platform).GetLyricAsync(id, extendDataJson);
}
public Task<string> GetPlayPageUrlAsync(PlatformEnum platform, string id, string extendDataJson = "")
{
return GetMusicProvider(platform).GetShareUrlAsync(id, extendDataJson);
}
public async Task<PlatformMusicTag?> GetMusicTagsAsync(PlatformEnum platform)
{
return await GetMusicProvider(platform).GetMusicTagsAsync();
}
public async Task<List<SongMenu>> GetSongMenusFromTagAsync(PlatformEnum platform, string id, int page)
{
return await GetMusicProvider(platform).GetSongMenusFromTagAsync(id, page);
}
public Task<List<SongMenu>> GetSongMenusFromTop(PlatformEnum platform)
{
return GetMusicProvider(platform).GetSongMenusFromTop();
}
public async Task<List<Music>> GetTopMusicsAsync(PlatformEnum platform, string topId)
{
return await GetMusicProvider(platform).GetTopMusicsAsync(topId);
}
public async Task<List<Music>> GetTagMusicsAsync(PlatformEnum platform, string tagId)
{
return await GetMusicProvider(platform).GetTagMusicsAsync(tagId);
}
}