Example #1
0
        /// <summary>
        /// 获取 / 搜索歌单列表
        /// </summary>
        /// <param name="SearchCondition">搜索依据</param>
        /// <param name="keyword">搜索关键词</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageRows">一页输出数量</param>
        /// <returns></returns>
        public static SongListList[] GetSongListList(string SearchCondition, string keyword, int PageIndex, int PageRows, string sortField, string sortType)
        {
            string postJson = JsonMapper.ToJson(new GetModules.ListPostModule {
                search = new GetModules.Search {
                    condition = SearchCondition, keyword = keyword
                }, pageIndex = PageIndex, pageRows = PageRows, sortField = sortField, sortType = sortType
            });
            var response = GetTools.PostApi("/v1/GetAlbumsList", postJson);

            if (response.IsSuccessful)
            {
                GetModules.SongListListGetModule jsonData = JsonMapper.ToObject <GetModules.SongListListGetModule>(response.Content);
                if (jsonData.Success)
                {
                    for (int i = 0; i != jsonData.Data.Length; i++)
                    {
                        if (string.IsNullOrEmpty(jsonData.Data[i].introduce))
                        {
                            jsonData.Data[i].introduce = "";
                        }
                    }
                    return(jsonData.Data);
                }
                else
                {
                    Log.WriteLine("请求失败:\r\n" + response.Content, Level.Error);
                    throw new Exception(jsonData.Msg.ToString());
                }
            }
            else
            {
                throw new Exception(response.StatusCode.ToString());
            }
        }
Example #2
0
        public static Song[] GetSongListSong(string id)
        {
            string postJson = JsonMapper.ToJson(new GetModules.SinglePostModule {
                id = id
            });
            var response = GetTools.PostApi("/v1/GetAlbumsData", postJson);

            if (response.IsSuccessful)
            {
                GetModules.SongListGetModule jsonData = JsonMapper.ToObject <GetModules.SongListGetModule>(response.Content);
                if (jsonData.Success)
                {
                    for (int i = 0; i != jsonData.Data.Data.Length; i++)
                    {
                        string[] assestUri = JointAssetsUrl.GetAssestUri(jsonData.Data.Data[i].CDN, GetTools.CDNList, jsonData.Data.Data[i].CoverImg, jsonData.Data.Data[i].Music, jsonData.Data.Data[i].Lyric);
                        jsonData.Data.Data[i].assestLink = new Song.AssestLink {
                            CoverImg = assestUri[0], Music = assestUri[1], Lyric = assestUri[2]
                        };
                    }
                    Log.WriteLine("获取歌单 " + id + " 成功", Level.Info);
                    return(jsonData.Data.Data);
                }
                else
                {
                    Log.WriteLine("请求失败:\r\n" + response.Content, Level.Error);
                    throw new Exception(jsonData.Msg.ToString());
                }
            }
            else
            {
                throw new Exception(response.StatusCode.ToString());
            }
        }
Example #3
0
        /// <summary>
        /// 获取 / 搜索歌曲
        /// </summary>
        /// <param name="SearchCondition">搜索依据</param>
        /// <param name="keyword">搜索关键词</param>
        /// <param name="PageIndex">页码</param>
        /// <param name="PageRows">一页输出数量</param>
        /// <returns></returns>
        public static Song[] GetMusicList(string SearchCondition, string keyword, int PageIndex, int PageRows, string sortField, string sortType)
        {
            string postJson = JsonMapper.ToJson(new GetModules.ListPostModule {
                search = new GetModules.Search {
                    condition = SearchCondition, keyword = keyword
                }, pageIndex = PageIndex, pageRows = PageRows, sortField = sortField, sortType = sortType
            });
            var response = GetTools.PostApi("/v1/GetMusicList", postJson);

            if (response.IsSuccessful)
            {
                GetModules.MusicListGetModule jsonData = JsonMapper.ToObject <GetModules.MusicListGetModule>(response.Content);
                if (jsonData.Success)
                {
                    for (int i = 0; i != jsonData.Data.Length; i++)
                    {
                        string[] assestUri = JointAssetsUrl.GetAssestUri(jsonData.Data[i].CDN, GetTools.CDNList, jsonData.Data[i].CoverImg, jsonData.Data[i].Music, jsonData.Data[i].Lyric);
                        jsonData.Data[i].assestLink = new AssestLink {
                            CoverImg = assestUri[0], Music = assestUri[1], Lyric = assestUri[2]
                        };
                    }
                    return(jsonData.Data);
                }
                else
                {
                    Log.WriteLine("请求失败:\r\n" + response.Content, Level.Error);
                    throw new Exception(jsonData.Msg.ToString());
                }
            }
            else
            {
                throw new Exception(response.StatusCode.ToString());
            }
        }
Example #4
0
        /// <summary>
        /// 获取横幅
        /// </summary>
        public static Banner[] GetBanners()
        {
            string postJson = JsonMapper.ToJson(new GetModules.ListPostModule {
                pageIndex = 1, pageRows = 20, sortField = "Id", sortType = "desc", search = new GetModules.Search()
            });
            var response = GetTools.PostApi("/v1/GetDataList", postJson); // 请求 Api

            if (response.IsSuccessful)
            {
                GetModules.BannerGetModule jsonData = JsonMapper.ToObject <GetModules.BannerGetModule>(response.Content); // 转 Json 为对象
                if (jsonData.Success)
                {
                    return(jsonData.Data);
                }
                else
                {
                    Log.WriteLine("请求失败:\r\n" + response.Content, Level.Error);
                    throw new Exception(jsonData.Msg.ToString());
                }
            }
            else
            {
                throw new Exception(response.StatusCode.ToString());
            }
        }
Example #5
0
        /// <summary>
        /// 获取热门歌曲
        /// </summary>
        /// <param name="PageIndex"></param>
        /// <param name="PageRows"></param>
        /// <returns></returns>
        public static Song[] GetHotMusic(int PageIndex, int PageRows)
        {
            string postJson = JsonMapper.ToJson(new GetModules.ListPostModule {
                pageIndex = PageIndex, pageRows = PageRows
            });
            var response = GetTools.PostApi("/v1/GetHotMusicList", postJson);

            if (response.IsSuccessful)
            {
                GetModules.MusicListGetModule jsonData = JsonMapper.ToObject <GetModules.MusicListGetModule>(response.Content);
                if (jsonData.Success)
                {
                    Song[] songs = jsonData.Data;
                    for (int i = 0; i != songs.Length; i++)
                    {
                        string[] assestUri = JointAssetsUrl.GetAssestUri(songs[i].CDN, GetTools.CDNList, songs[i].CoverImg, songs[i].Music, songs[i].Lyric);
                        songs[i].assestLink = new AssestLink {
                            CoverImg = assestUri[0], Music = assestUri[1], Lyric = assestUri[2]
                        };
                    }
                    return(songs);
                }
                else
                {
                    Log.WriteLine("请求失败:\r\n" + response.Content, Level.Error);
                    throw new Exception(jsonData.Msg.ToString());
                }
            }
            else
            {
                throw new Exception("错误代码:" + response.StatusCode.ToString());
            }
        }
Example #6
0
        /// <summary>
        /// 获取多个歌曲对象
        /// </summary>
        /// <param name="SongId">歌曲 Id</param>
        public static Song GetSongObjects(string[] SongId)
        {
            string postJson = JsonMapper.ToJson(new GetModules.ArrayPostModule {
                ids = SongId
            });
            var response = GetTools.PostApi("/v1/GetMusicData", postJson); // 请求 Api

            if (response.IsSuccessful)
            {
                GetModules.MusicListGetModule jsonData = JsonMapper.ToObject <GetModules.MusicListGetModule>(response.Content); // 转 Json 为对象
                if (jsonData.Success)
                {
                    string[] assestUri = JointAssetsUrl.GetAssestUri(jsonData.Data[0].CDN, GetTools.CDNList, jsonData.Data[0].CoverImg, jsonData.Data[0].Music, jsonData.Data[0].Lyric);
                    jsonData.Data[0].assestLink = new AssestLink {
                        CoverImg = assestUri[0], Music = assestUri[1], Lyric = assestUri[2]
                    };
                    return(jsonData.Data[0]);
                }
                else
                {
                    Log.WriteLine("请求失败:\r\n" + response.Content, Level.Error);
                    throw new Exception(jsonData.Msg.ToString());
                }
            }
            else
            {
                throw new Exception(response.StatusCode.ToString());
            }
        }
Example #7
0
        public static string GetToken(string User, string Password)
        {
            string postJson = JsonMapper.ToJson(new GetModules.LoginPostModule {
                userName = User, password = Password
            });
            var response = GetTools.PostApi("/v1/SubmitLogin", postJson); // 请求 Api

            if (response.IsSuccessful)
            {
                GetModules.LoginGetModules jsonData = JsonMapper.ToObject <GetModules.LoginGetModules>(response.Content); // 转 Json 为对象
                if (jsonData.Success)
                {
                    return(jsonData.Data);
                }
                else
                {
                    Log.WriteLine("请求失败:\r\n" + response.Content, Tools.Level.Error);
                    throw new Exception(jsonData.Msg.ToString());
                }
            }
            else
            {
                throw new Exception(response.StatusCode.ToString());
            }
        }
Example #8
0
        public static Vocal[] GetVocalList(string SearchCondition, string keyword, int PageIndex, int PageRows, string sortField, string sortType)
        {
            string postJson = JsonMapper.ToJson(new GetModules.ListPostModule {
                pageIndex = PageIndex, pageRows = PageRows, sortField = sortField, sortType = sortType, search = new GetModules.Search {
                    condition = SearchCondition, keyword = keyword
                }
            });
            var response = GetTools.PostApi("/v1/GetVtbsList", postJson); // 请求 Api

            if (response.IsSuccessful)
            {
                GetModules.VocalListGetModule jsonData = JsonMapper.ToObject <GetModules.VocalListGetModule>(response.Content); // 转 Json 为对象
                if (jsonData.Success)
                {
                    for (int i = 0; i != jsonData.Data.Length; i++)
                    {
                        if (string.IsNullOrEmpty(jsonData.Data[i].OriginalName))
                        {
                            jsonData.Data[i].OriginalName = "";
                        }
                        if (string.IsNullOrEmpty(jsonData.Data[i].JapaneseName))
                        {
                            jsonData.Data[i].JapaneseName = "";
                        }
                        if (string.IsNullOrEmpty(jsonData.Data[i].EnglistName))
                        {
                            jsonData.Data[i].EnglistName = "";
                        }
                        if (string.IsNullOrEmpty(jsonData.Data[i].ChineseName))
                        {
                            jsonData.Data[i].ChineseName = "";
                        }
                    }
                    return(jsonData.Data);
                }
                else
                {
                    Log.WriteLine("请求失败:\r\n" + response.Content, Level.Error);
                    throw new Exception(jsonData.Msg.ToString());
                }
            }
            else
            {
                throw new Exception(response.StatusCode.ToString());
            }
        }
Example #9
0
        public static Vocal GetVocalObject(string id)
        {
            string postJson = JsonMapper.ToJson(new GetModules.SinglePostModule {
                id = id
            });
            var response = GetTools.PostApi("/v1/GetVtbsData", postJson); // 请求 Api

            if (response.IsSuccessful)
            {
                GetModules.SingleVocalGetModule jsonData = JsonMapper.ToObject <GetModules.SingleVocalGetModule>(response.Content); // 转 Json 为对象
                if (jsonData.Success)
                {
                    if (string.IsNullOrEmpty(jsonData.Data.OriginalName))
                    {
                        jsonData.Data.OriginalName = "";
                    }
                    if (string.IsNullOrEmpty(jsonData.Data.JapaneseName))
                    {
                        jsonData.Data.JapaneseName = "";
                    }
                    if (string.IsNullOrEmpty(jsonData.Data.EnglistName))
                    {
                        jsonData.Data.EnglistName = "";
                    }
                    if (string.IsNullOrEmpty(jsonData.Data.ChineseName))
                    {
                        jsonData.Data.ChineseName = "";
                    }
                    return(jsonData.Data);
                }
                else
                {
                    Log.WriteLine("请求失败:\r\n" + response.Content, Level.Error);
                    throw new Exception(jsonData.Msg.ToString());
                }
            }
            else
            {
                throw new Exception(response.StatusCode.ToString());
            }
        }