public void GetExistedMusicTest([Random(0, MusicCount - 1, 5)] int id) { var expectedMusic = _fakeDbMusicData.Music.Find(f => f.Id == id); var actualMusic = _musicDetailedInfoService.GetMusic(id); actualMusic.Should().BeEquivalentTo(expectedMusic, options => options.ExcludingMissingMembers().Excluding(mus => mus.Duration)); actualMusic.Musicians.Should().BeEquivalentTo(expectedMusic.Musicians, options => options.ExcludingMissingMembers()); actualMusic.Genres.Should().BeEquivalentTo(expectedMusic.Genres, options => options.ExcludingMissingMembers()); }
public CollectResult CollectSearch([FromQuery] string t, [FromQuery] string id, [FromQuery] int p, [FromQuery] int s) { if (string.IsNullOrEmpty(t)) { return(new CollectResult { ErrorCode = 403, ErrorMsg = "请输入搜索类型" }); } if (string.IsNullOrEmpty(id)) { return(new CollectResult { ErrorCode = 403, ErrorMsg = "请输入歌单ID" }); } if (p == 0) { p = 1; } if (s == 0) { s = 1000; } return(MusicService.GetMusic(t).CollectSearch(id, p, s)); }
public ArtistResult SearchArtist([FromQuery] string t, [FromQuery] string id, [FromQuery] int p, [FromQuery] int s) { if (string.IsNullOrEmpty(t)) { return(new ArtistResult { ErrorCode = 403, ErrorMsg = "请输入搜索类型" }); } if (string.IsNullOrEmpty(id)) { return(new ArtistResult { ErrorCode = 403, ErrorMsg = "请输入艺术家ID" }); } if (p == 0) { p = 1; } if (s == 0) { s = 50; } return(MusicService.GetMusic(t).ArtistSearch(id, p, s)); }
public SearchResult Search([FromQuery] string t, [FromQuery] string k, [FromQuery] int p, [FromQuery] int s) { if (string.IsNullOrEmpty(t)) { return(new SearchResult { ErrorCode = 403, ErrorMsg = "请输入搜索类型" }); } if (string.IsNullOrEmpty(k)) { return(new SearchResult { ErrorCode = 403, ErrorMsg = "请输入关键词" }); } if (p == 0) { p = 1; } if (s == 0) { s = 30; } return(MusicService.GetMusic(t).SongSearch(k, p, s)); }
public SongResult SongSearch([FromQuery] string t, [FromQuery] string id) { if (string.IsNullOrEmpty(t) || string.IsNullOrEmpty(id)) { return(null); } return(MusicService.GetMusic(t).GetSingleSong(id)); }
public List <SongResult> SearchAlbum([FromQuery] string t, [FromQuery] string id) { if (string.IsNullOrEmpty(t) || string.IsNullOrEmpty(id)) { Response.StatusCode = 403; return(null); } return(MusicService.GetMusic(t).AlbumSearch(id)); }
public void Get(string path, [FromQuery] string sign) { if (CommonHelper.Md5(path + CommonHelper.SignKey) != sign) { Response.StatusCode = 403; return; } if (string.IsNullOrEmpty(path)) { Response.StatusCode = 403; return; } var paths = path.Split('.'); if (paths.Length != 2) { Response.StatusCode = 403; return; } var keys = paths[0].Split('_'); if (keys.Length != 3) { Response.StatusCode = 403; return; } var linkInfo = MusicService.GetMusic(keys[0]).GetSongUrl(keys[2], keys[1], paths[1]); if (linkInfo == null) { Response.StatusCode = 404; return; } if (linkInfo.StartsWith("http://")) { Response.StatusCode = 302; Response.Headers.Add("Location", linkInfo); } else { if (string.IsNullOrEmpty(linkInfo)) { Response.StatusCode = 404; } else { Response.StatusCode = 200; Response.WriteAsync(linkInfo); } } }
public List <SongResult> CollectSearch([FromQuery] string t, [FromQuery] string id, [FromQuery] int p, [FromQuery] int s) { if (string.IsNullOrEmpty(t) || string.IsNullOrEmpty(id)) { Response.StatusCode = 403; return(null); } if (p == 0) { p = 1; } if (s == 0) { s = 1000; } return(MusicService.GetMusic(t).CollectSearch(id, p, s)); }
public List <SongResult> Search([FromQuery] string t, [FromQuery] string k, [FromQuery] int p, [FromQuery] int s) { if (string.IsNullOrEmpty(t) || string.IsNullOrEmpty(k)) { Response.StatusCode = 403; return(null); } if (p == 0) { p = 1; } if (s == 0) { s = 30; } return(MusicService.GetMusic(t).SongSearch(k, p, s)); }
public AlbumResult SearchAlbum([FromQuery] string t, [FromQuery] string id) { if (string.IsNullOrEmpty(t)) { return(new AlbumResult { ErrorCode = 403, ErrorMsg = "请输入搜索类型" }); } if (string.IsNullOrEmpty(id)) { return(new AlbumResult { ErrorCode = 403, ErrorMsg = "请输入专辑ID" }); } return(MusicService.GetMusic(t).AlbumSearch(id)); }
private static string GetUrlFromThird(string id, string quality) { var singleSong = SearchSingle(id); var songListQq = MusicService.GetMusic("qq") .SongSearch(singleSong.ArtistName + "-" + singleSong.SongName, 1, 30); SongResult song = null; if (songListQq != null) { song = songListQq.FirstOrDefault(t => CommonHelper.CompareStr(t.SongName, singleSong.SongName) && (CommonHelper.CompareStr(t.ArtistName, singleSong.ArtistName) || CommonHelper.CompareStr(t.AlbumName, singleSong.AlbumName))); } if (song == null) { var songList = MusicService.GetMusic("xm") .SongSearch(singleSong.ArtistName + "-" + singleSong.SongName, 1, 30); song = songList.FirstOrDefault(t => CommonHelper.CompareStr(t.SongName, singleSong.SongName) && (CommonHelper.CompareStr(t.ArtistName, singleSong.ArtistName) || CommonHelper.CompareStr(t.AlbumName, singleSong.AlbumName))); if (song == null) { song = songListQq.FirstOrDefault(t => CommonHelper.CompareStr(t.SongName, singleSong.SongName)); } if (song == null) { song = songList.FirstOrDefault(t => CommonHelper.CompareStr(t.SongName, singleSong.SongName)); } } if (song == null) { return(""); } if (quality == "999000") { if (!string.IsNullOrEmpty(song.FlacUrl)) { return(song.FlacUrl); } if (!string.IsNullOrEmpty(song.ApeUrl)) { return(song.ApeUrl); } if (!string.IsNullOrEmpty(song.WavUrl)) { return(song.WavUrl); } if (!string.IsNullOrEmpty(song.SqUrl)) { return(song.SqUrl); } if (!string.IsNullOrEmpty(song.HqUrl)) { return(song.HqUrl); } } else if (quality == "320000" || quality == "192000") { if (!string.IsNullOrEmpty(song.SqUrl)) { return(song.SqUrl); } } return(song.LqUrl); }