private async void AutoSuggestBox_TextChanged(AutoSuggestBox sender, AutoSuggestBoxTextChangedEventArgs args) { try { if (sender.Text.Length != 0) { //ObservableCollection<String> var data = new ObservableCollection<string>(); var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/new/app/i/search.php?cmd=302&keyword="+sender.Text); var httpresult = await httpclient.Get(); var jsondata = httpresult.GetString(); var obj = Windows.Data.Json.JsonObject.Parse(jsondata); var arryobj = obj.GetNamedArray("data"); foreach (var item in arryobj) { data.Add(item.GetObject().GetNamedString("keyword")); } sender.ItemsSource = data; //sender.IsSuggestionListOpen = true; } else { sender.IsSuggestionListOpen = false; } } catch (Exception) { } }
public async static Task<string> get_musicurl_by_hash(string hash) { var sign = MD5.GetMd5String(hash + "kgcloudv2"); Noear.UWP.Http.AsyncHttpClient httpget = new Noear.UWP.Http.AsyncHttpClient(); httpget.Url("http://trackercdn.kugou.com/i/v2/?cmd=23&hash=" + hash + "&key=" + sign + "&pid=1&vipToken=&behavior=play"); var result = await httpget.Get(); var json = result.GetString(); JsonObject obj = JsonObject.Parse(json); return obj.GetNamedString("url"); }
public async static Task<List<search_album>> searchalbum(string keyword, int page) { Noear.UWP.Http.AsyncHttpClient httpget = new Noear.UWP.Http.AsyncHttpClient(); httpget.Url("http://mobilecdn.kugou.com/api/v3/search/album?iscorrect=1&pagesize=20&plat=20&sver=3&showtype=14&page=" + page + "&keyword=" + keyword); var result = await httpget.Get(); var json = result.GetString(); JsonObject obj = JsonObject.Parse(json); json = obj.GetNamedObject("data").GetNamedArray("info").ToString(); return data.DataContractJsonDeSerialize<List<search_album>>(json); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { var vlistid = e.Parameter.ToString(); var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://service.mobile.kugou.com/v1/mv/vspecialdetail?vid=" + vlistid); var json = (await httpclient.Get()).GetString(); json = json.Replace("{size}", "240"); var obj = Windows.Data.Json.JsonObject.Parse(json); var vlistdata = Class.data.DataContractJsonDeSerialize<MVListData>(obj.GetNamedObject("data").GetNamedObject("info").ToString()); mainGrid.DataContext = vlistdata; }
private async Task<Album_Info> GetAlbumInfo(string albumid) { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/api/v3/album/info?albumid="+albumid); var json = (await httpclient.Get()).GetString(); json = json.Replace("{size}", "400"); var obj = Windows.Data.Json.JsonObject.Parse(json); var data = Class.data.DataContractJsonDeSerialize<Album_Info>(obj.GetNamedObject("data").ToString()); data.publishtime = data.publishtime.Replace("00:00:00", ""); data.publishtime = data.publishtime + "发行"; GetSingerInfo(data.singerid); return data; }
private async Task<List<BannerModel>> GetBanner() { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://service.mobile.kugou.com/v1/show/banner?type=1&plat=0&version=8150"); var json = (await httpclient.Get()).GetString(); var obj = Windows.Data.Json.JsonObject.Parse(json); var bannerdata = new List<BannerModel>(); var banners = obj.GetNamedObject("data").GetNamedArray("info"); foreach (var item in banners) { var banner = Class.data.DataContractJsonDeSerialize<BannerModel>(item.ToString()); bannerdata.Add(banner); } return bannerdata; }
public async void LoadTuiJianData() { TuiJianLoadProgress.IsActive = true; //获取推荐页全部资源 await LoadBannerData(); var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://service.mobile.kugou.com/v1/yueku/recommend?type=7&operator=7&plat=0&version=8150"); var json = (await httpclient.Get()).GetString(); json = json.Replace("{size}", "150"); var obj = Windows.Data.Json.JsonObject.Parse(json); alldata = Class.data.DataContractJsonDeSerialize<TuiJianData>((obj.GetNamedObject("data").GetNamedObject("info").ToString())); //加载最新音乐 NewSong1_Text.Text = alldata.song[0].filename; NewSong1_Img.Source = new BitmapImage() { UriSource=new Uri(alldata.song[0].singerimgurl) }; NewSong2_Text.Text = alldata.song[1].filename; NewSong3_Text.Text = alldata.song[2].filename; NewAlbum1_Img.Source = new BitmapImage() { UriSource = new Uri(alldata.album[0].imgurl) }; NewAlbum1_Text.Text = alldata.album[0].singername + " - 《"+ alldata.album[0].albumname + "》"; NewAlbum2_Text.Text = alldata.album[1].singername + " - 《" + alldata.album[1].albumname + "》"; NewAlbum3_Text.Text = alldata.album[2].singername + " - 《" + alldata.album[2].albumname + "》"; //加载热门歌单 recommend1.DataContext = alldata.recommend[0].extra; recommend2.DataContext = alldata.recommend[1].extra; recommend3.DataContext = alldata.recommend[2].extra; recommend4.DataContext = alldata.recommend[3].extra; recommend5.DataContext = alldata.recommend[4].extra; recommend6.DataContext = alldata.recommend[5].extra; //加载主题歌单 specialTitle.Text = alldata.custom_special[0].title; specialView1.DataContext = alldata.custom_special[0].special[0]; specialView2.DataContext = alldata.custom_special[0].special[1]; specialView3.DataContext = alldata.custom_special[0].special[2]; //加载MV歌单 vlist1.DataContext = alldata.vlist[0]; vlist2.DataContext = alldata.vlist[1]; vlist3.DataContext = alldata.vlist[2]; vlist4.DataContext = alldata.vlist[3]; //加载精选专题 foreach (var item in alldata.topic) { topicList.Items.Add(item); } topicList.SelectionChanged += TopicList_SelectionChanged; //加载完成 TuiJianLoadProgress.IsActive = false; }
private async void init_hotsearct() { var httpclient=new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/api/v3/search/hot?count=8&plat=0"); var httpresult=await httpclient.Get(); var jsondata= httpresult.GetString(); var obj = Windows.Data.Json.JsonObject.Parse(jsondata); var arryobj = obj.GetNamedObject("data").GetNamedArray("info"); for (int i = 0; i < 8; i++) { var item = (GridViewItem)(HotSearchView.Items[i]); var button = (Button)item.Content; button.Content= arryobj[i].GetObject().GetNamedString("keyword"); } HotSearchView.Visibility = Visibility.Visible; var result = SearchBox.Focus(FocusState.Pointer); }
public static async Task<string> get_song_url(string hash) { try { var sign = MD5.GetMd5String(hash + "kgcloudv2"); var request = new Noear.UWP.Http.AsyncHttpClient(); request.Url("http://trackercdn.kugou.com/i/v2/?cmd=23&hash=" + hash + "&key=" + sign + "&pid=1&vipToken=&behavior=play"); var result = await request.Get(); var json = result.GetString(); JsonObject obj = JsonObject.Parse(json); var url = obj["url"]; return url.GetString(); } catch (Exception) { return null; } }
public async Task LoadBannerData() { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); var time= Convert.ToInt64(ts.TotalSeconds).ToString(); var key = Class.MD5.GetMd5String("1100Ilwieks28dk2k092lksi2UIkp8150"+time); httpclient.Url("http://ads.service.kugou.com/v1/mobile_fmbanner?userid=366079534&appid=1100&type=4&networktype=1&operator=7&version=8150&plat=0&ismonthly=0&clienttime="+time+"&clientver=8150&mid=&key="+key+"&isvip=0"); var json = (await httpclient.Get()).GetString(); json = json.Replace("{size}", "400"); var obj = Windows.Data.Json.JsonObject.Parse(json); bannerdata = Class.data.DataContractJsonDeSerialize<List<BannerData>>(obj.GetNamedObject("data").GetNamedArray("info").ToString()); var pics = new List<string>(); foreach (var item in bannerdata) { pics.Add(item.imgurl); } bannerView.SetItems(pics); }
private async void LoadData() { LoadProess.IsActive = true; var hashlist = await GetHashList(); if(hashlist!="") { var key = Class.MD5.GetMd5String("2022000kgyzone"); var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://y.service.kugou.com/song/qulity?pid=20&ver=2200&mid=0&key=" + key + "&hashlist=" + hashlist); var json = (await httpclient.Get()).GetString(); var obj = Windows.Data.Json.JsonObject.Parse(json); var musicdata = Class.data.DataContractJsonDeSerialize<List<MusicData>>(obj.GetNamedArray("list").ToString()); for (int i = 0; i < musicdata.Count; i++) { musicdata[i].moredata = hashdata[i]; } MusicList.ItemsSource = musicdata; MusicList.SelectionChanged += MusicList_SelectionChanged; } LoadProess.IsActive = false; }
private async void GetCloudList() { var rid= await GetridList(); if(rid!="") { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); var key = Class.MD5.GetMd5String(uid+rid+"18150kgyzone"); httpclient.Url("http://y.service.kugou.com/song/info?uid="+uid+"&pid=1&mid=&ver=8150&rid="+rid+"&key="+key); var json = (await httpclient.Get()).GetString(); json = json.Replace("{size}", "150"); var obj = Windows.Data.Json.JsonObject.Parse(json); listdata = Class.data.DataContractJsonDeSerialize<List<MuiscListData>>(obj.GetNamedArray("list").ToString()); var mylist = new List<MuiscListData>(); var cloudlist = new List<MuiscListData>(); for (int i = 0; i < listdata.Count; i++) { listdata[i].moredata = riddata[i]; if (listdata[i].icon=="") { listdata[i].icon = "ms-appx:///Assets/image/songimg.png"; } if (listdata[i].type == "1") { mylist.Add(listdata[i]); } else { cloudlist.Add(listdata[i]); } } MyMusicList.ItemsSource = mylist; CloudMusicList.ItemsSource = cloudlist; MyListNum.Text = mylist.Count.ToString(); CloudListNum.Text = cloudlist.Count.ToString(); MyMusicList.SelectionChanged += MusicListChanged; CloudMusicList.SelectionChanged += MusicListChanged; this.NavigationCacheMode = NavigationCacheMode.Enabled; } }
public async void LoadLrcFromSongName(string songname, string duration) { try { var lrcfile = await (await KnownFolders.MusicLibrary.GetFolderAsync("kugou_lrc")).CreateFileAsync(songname + ".lrc"); try { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://lyrics.kugou.com/search?ver=1&man=yes&client=pc&keyword=" + songname + "&duration=" + duration); var json = (await httpclient.Get()).GetString(); var arry = Windows.Data.Json.JsonObject.Parse(json).GetNamedArray("candidates"); if (arry.Count != 0) { var id = arry[0].GetObject().GetNamedString("id"); var accesskey = arry[0].GetObject().GetNamedString("accesskey"); LoadLrcFormId(id, accesskey, songname); } else { await FileIO.WriteTextAsync(lrcfile, "暂无歌词"); nolrcview.Visibility = Visibility.Visible; lrcdatapanel.Visibility = Visibility.Collapsed; LoadLrcFromLocal(); } } catch (Exception) { await FileIO.WriteTextAsync(lrcfile, "暂无歌词"); nolrcview.Visibility = Visibility.Visible; lrcdatapanel.Visibility = Visibility.Collapsed; } } catch (Exception) { } }
public async Task<List<SongData>> GetSongList(string albumid) { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/api/v3/album/song?pagesize=-1&plat=0&page=1&version=8150&albumid=" + albumid); var json = (await httpclient.Get()).GetString(); json = json.Replace("320hash", "hash320"); var obj = Windows.Data.Json.JsonObject.Parse(json); var data = Class.data.DataContractJsonDeSerialize<List<SongData>>(obj.GetNamedObject("data").GetNamedArray("info").ToString()); foreach (var item in data) { item.filename = item.filename.Replace(" ", ""); item.title = item.filename.Split('-')[1]; item.singername = item.filename.Split('-')[0]; if(item.mvhash=="") { item.hasmv = "Collapsed"; } else { item.hasmv = "Visible"; } } return data; }
public static async Task<ObservableCollection<Class.Model.SearchResultModel.Song>> GetSongResult(string keyword, int page) { try { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/api/v3/search/song?pagesize=20&sver=2&page=" + page + "&version=8150&keyword=" + keyword); var httpresult = await httpclient.Get(); var jsondata = httpresult.GetString(); jsondata = jsondata.Replace("320hash", "hash320"); var obj = Windows.Data.Json.JsonObject.Parse(jsondata); var arry = obj.GetNamedObject("data").GetNamedArray("info"); var resultdata = new ObservableCollection<Class.Model.SearchResultModel.Song>(); foreach (var item in arry) { var music = Class.data.DataContractJsonDeSerialize<Class.Model.SearchResultModel.Song>(item.ToString()); music.filename = music.filename.Replace("-", ""); if (music.singername!=null) { music.filename = music.filename.Replace(music.singername, ""); } music.filename = music.filename.Replace(" ", ""); if(music.filename.Contains("【")) { music.filename = music.filename.Split('【')[0]; } if(music.mvhash.Length>0) { music.mvview = "Visible"; } else { music.mvview = "Collapsed"; } resultdata.Add(music); } return resultdata; } catch (Exception) { return null; } }
public async Task<string> LoadLrcFormId(string id, string accesskey) { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://lyrics.kugou.com/download?ver=1&client=pc&id=" + id + "&accesskey=" + accesskey + "&fmt=lrc&charset=utf8"); var json = (await httpclient.Get()).GetString(); var content = Windows.Data.Json.JsonObject.Parse(json).GetNamedString("content"); var data = Convert.FromBase64String(content); json = System.Text.ASCIIEncoding.UTF8.GetString(data); return json; }
public async void LoadBaiHangData() { PaiHangLoadProgress.IsActive = true; //获取排行榜全部资源 var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/api/v3/rank/list?parentid=0&withsong=1&plat=0&apiver=2&showtype=2&version=8150"); var json = (await httpclient.Get()).GetString(); json = json.Replace("{size}", "150"); var obj = Windows.Data.Json.JsonObject.Parse(json); var alldata1 = Class.data.DataContractJsonDeSerialize<List<PaiHangData>>((obj.GetNamedObject("data").GetNamedArray("info").ToString())); alldata1.RemoveAt(0); //加载数据 paihangdata = new List<ViewMode.PaiHang>(); foreach (var item in alldata1) { var paihang = new ViewMode.PaiHang(); paihang.id = item.id.ToString(); paihang.rankname = item.rankname; paihang.rankid = item.rankid.ToString(); paihang.imgurl = item.imgurl; paihang.song1 = item.songinfo[0].songname; paihang.song2 = item.songinfo[1].songname; paihang.song3 = item.songinfo[2].songname; paihangdata.Add(paihang); } foreach (var item in paihangdata) { PaiHangList.Items.Add(item); } PaiHangLoadProgress.IsActive = false; }
public static async Task<Class.Model.SearchResultModel.Singer> GetSingerResult(string singername) { try { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/api/v3/singer/info?singername=" + singername); var httpresult = await httpclient.Get(); var jsondata = httpresult.GetString(); jsondata = jsondata.Replace("{size}", "150"); var obj = Windows.Data.Json.JsonObject.Parse(jsondata).GetNamedObject("data").ToString(); var resultdata = Class.data.DataContractJsonDeSerialize<Model.SearchResultModel.Singer>(obj); return resultdata; } catch (Exception) { return null; } }
private async Task<string> GetHashList() { TimeSpan ts = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, 0); var time = Convert.ToInt64(ts.TotalSeconds).ToString(); var key = Class.MD5.GetMd5String("100010TKbNapLfhKd89VxM" + uid + rid + time + "netfavorite"); var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://wp.cloudlist.service.kugou.com/song/getfile?uid=366079534&appid=100010&rid="+rid+"&ts="+time+"&key="+key); var json = (await httpclient.Get()).GetString(); var obj = Windows.Data.Json.JsonObject.Parse(json); hashdata = Class.data.DataContractJsonDeSerialize<List<HashData>>(obj.GetNamedObject("data").GetNamedArray("File").ToString()); string result = ""; for (int i = 0; i < hashdata.Count; i++) { if(i==hashdata.Count-1) { result = result + hashdata[i].hash; } else { result = result + hashdata[i].hash + ","; } } return result; }
public async void LoadLrcFormId(string id,string accesskey,string filename) { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://lyrics.kugou.com/download?ver=1&client=pc&id="+id+"&accesskey="+accesskey+"&fmt=lrc&charset=utf8"); var json = (await httpclient.Get()).GetString(); var content = Windows.Data.Json.JsonObject.Parse(json).GetNamedString("content"); var data = Convert.FromBase64String(content); json=System.Text.ASCIIEncoding.UTF8.GetString(data); var lrcfolder= await KnownFolders.MusicLibrary.GetFolderAsync("kugou_lrc"); try { var file = await lrcfolder.CreateFileAsync(filename + ".lrc"); await FileIO.WriteTextAsync(file, json); LoadLrcFromLocal(); } catch (Exception) { var file = await lrcfolder.GetFileAsync(filename + ".lrc"); await FileIO.WriteTextAsync(file, json); LoadLrcFromLocal(); } }
public async void LoadGeDan(string categoryid = "") { GeDanLoadProgress.IsActive = true; var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/api/v3/category/special?pagesize=20&withsong=0&plat=0&categoryid="+ categoryid + "&sort="+gd_sort+"&page="+gd_page); var json = (await httpclient.Get()).GetString(); json = json.Replace("{size}", "150"); var obj = Windows.Data.Json.JsonObject.Parse(json); GeDanListData = Class.data.DataContractJsonDeSerialize<ObservableCollection<GeDanData>>(obj.GetNamedObject("data").GetNamedArray("info").ToString()); foreach (var item in GeDanListData) { if(double.Parse(item.playcount)>10000) { item.playcount = Math.Floor(double.Parse(item.playcount) / 10000).ToString() + "万"; } } GeDanListView.ItemsSource = GeDanListData; GeDanLoadProgress.IsActive = false; }
private async Task<string> GetAlbumImg(string Albumid) { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/api/v3/album/info?albumid=" + Albumid); var json = (await httpclient.Get()).GetString(); var obj = Windows.Data.Json.JsonObject.Parse(json); var url = obj.GetNamedObject("data").GetNamedString("imgurl"); url = url.Replace("{size}", "400"); return url; }
public static async Task<ObservableCollection<Album>> GetAlbumResult(string keyword, int page) { try { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/api/v3/search/album?pagesize=20&sver=2&page=" + page + "&version=8150&keyword=" + keyword); var httpresult = await httpclient.Get(); var jsondata = httpresult.GetString(); jsondata = jsondata.Replace("{size}", "150"); jsondata = jsondata.Replace("00:00:00", ""); var obj = Windows.Data.Json.JsonObject.Parse(jsondata); var arry = obj.GetNamedObject("data").GetNamedArray("info"); var resultdata = new ObservableCollection<Class.Model.SearchResultModel.Album>(); foreach (var item in arry) { resultdata.Add(Class.data.DataContractJsonDeSerialize<Class.Model.SearchResultModel.Album>(item.ToString())); } return resultdata; } catch (Exception) { return null; } }
public static async Task<mvdata> get_mv_url(string hash) { try { var sign = MD5.GetMd5String(hash + "kugoumvcloud"); var request = new Noear.UWP.Http.AsyncHttpClient(); request.Url("http://trackermv.kugou.com/interface/index?cmd=100&pid=2&ext=mp4&hash=" + hash + "&quality=3&key=" + sign); var result = await request.Get(); var json = result.GetString(); JsonObject obj = JsonObject.Parse(json); obj.GetNamedObject("mvdata").Add("songname", JsonValue.CreateStringValue(obj.GetNamedString("songname"))); obj.GetNamedObject("mvdata").Add("singer", JsonValue.CreateStringValue(obj.GetNamedString("singer"))); json = obj.GetNamedObject("mvdata").ToString(); return data.DataContractJsonDeSerialize<mvdata>(json); } catch (Exception) { return null; } }
public async void GetSingerInfo(string singerid) { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://mobilecdn.kugou.com/api/v3/singer/info?singerid=" + singerid); var json = (await httpclient.Get()).GetString(); json = json.Replace("{size}", "150"); var obj = Windows.Data.Json.JsonObject.Parse(json); singerimg.ImageSource = new Windows.UI.Xaml.Media.Imaging.BitmapImage() { UriSource = new Uri(obj.GetNamedObject("data").GetNamedString("imgurl")) }; }
public async Task<string> LoadLrcFromSongName(string songname, string duration) { var httpclient = new Noear.UWP.Http.AsyncHttpClient(); httpclient.Url("http://lyrics.kugou.com/search?ver=1&man=yes&client=pc&keyword=" + songname + "&duration=" + duration+"000"); var json = (await httpclient.Get()).GetString(); var arry = Windows.Data.Json.JsonObject.Parse(json).GetNamedArray("candidates"); if (arry.Count != 0) { var id = arry[0].GetObject().GetNamedString("id"); var accesskey = arry[0].GetObject().GetNamedString("accesskey"); var lrc=await LoadLrcFormId(id, accesskey); return lrc; } else { return null; } }