public async Task GetQZRank()
 {
     try
     {
         
             WebClientClass wc = new WebClientClass();
             string results = await wc.GetResults(new Uri("http://api.bilibili.cn/list?appkey=84b739484c36d653&order=hot&original=0&page=1&pagesize=20"));
             InfoModel model = new InfoModel();
             model = JsonConvert.DeserializeObject<InfoModel>(results);
             JObject json = JObject.Parse(model.list.ToString());
             QQ_Rank_QZ.Items.Clear();
             List<InfoModel> ReList = new List<InfoModel>();
             for (int i = 0; i < 20; i++)
             {
                 ReList.Add(new InfoModel
                 {
                     aid = (string)json[i.ToString()]["aid"],
                     title = (string)json[i.ToString()]["title"],
                     pic = (string)json[i.ToString()]["pic"],
                     author = (string)json[i.ToString()]["author"],
                     play = (string)json[i.ToString()]["play"],
                     video_review = (string)json[i.ToString()]["video_review"],
                     num = i + 1
                 });
             }
             QQ_Rank_QZ.ItemsSource = ReList;
     }
     catch (Exception ex)
     {
         MessageDialog md = new MessageDialog(ex.Message);
         await md.ShowAsync();
     }
 }
 public async Task<string> GetVideoUri(string cid, int quality)
 {
     //http://interface.bilibili.com/playurl?platform=android&cid=5883400&quality=2&otype=json&appkey=422fd9d7289a1dd9&type=mp4
     try
     {
         wc = new WebClientClass();
         string results = await wc.GetResults(new Uri("http://interface.bilibili.com/playurl?platform=android&cid=" + cid + "&quality=" + quality + "&otype=json&appkey=422fd9d7289a1dd9&type=mp4"));
         VideoUriModel model = JsonConvert.DeserializeObject<VideoUriModel>(results);
         List<VideoUriModel> model1 = JsonConvert.DeserializeObject<List<VideoUriModel>>(model.durl.ToString());
         return model1[0].url;
     }
     catch (Exception)
     {
         return null;
     }
 }
        public async void DownDanMu(string cid, StorageFolder folder)
        {
            try
            {
                wc = new WebClientClass();
                string results = await wc.GetResults(new Uri("http://comment.bilibili.com/" + cid + ".xml"));
                //将弹幕存在在应用文件夹
                //StorageFolder folder = ApplicationData.Current.LocalFolder;
                //StorageFolder DowFolder = await KnownFolders.VideosLibrary.CreateFolderAsync("Bili-Download", CreationCollisionOption.OpenIfExists);
                StorageFile fileWrite = await folder.CreateFileAsync(cid + ".xml", CreationCollisionOption.ReplaceExisting);
                await FileIO.WriteTextAsync(fileWrite, results);
            }
            catch (Exception)
            {
                //return null;
            }

        }
 private async void GetTopic()
 {
     try
     {
         pr_Load.Visibility = Visibility.Visible;
         WebClientClass wc = new WebClientClass();
         string results = await wc.GetResults(new Uri("http://www.bilibili.com/index/slideshow.json"));
         TopicModel model = JsonConvert.DeserializeObject<TopicModel>(results);
         list_Topic.ItemsSource = JsonConvert.DeserializeObject<List<TopicModel>>(model.list.ToString());
     }
     catch (Exception ex)
     {
         messShow.Show("读取话题失败\r\n" + ex.Message, 3000);
     }
     finally
     {
         pr_Load.Visibility = Visibility.Collapsed;
     }
 }
 private async Task GetTagInfo(int page, string tid, int type)
 {
     try
     {
             WebClientClass wc = new WebClientClass();
             string results = await wc.GetResults(new Uri(String.Format("http://bangumi.bilibili.com/api/get_season_by_tag?indexType={0}&page={1}&pagesize=20&tag_id={2}", type, page, tid)));
             BanSeasonTagModel model = JsonConvert.DeserializeObject<BanSeasonTagModel>(results);
             List<BanSeasonTagModel> ls = JsonConvert.DeserializeObject<List<BanSeasonTagModel>>(model.result.ToString());
             foreach (BanSeasonTagModel item in ls)
             {
                 ls_Tag.Items.Add(item);
             }
             getPage++;
             if (model.pages < getPage)
             {
                 btn_LoadMore.IsEnabled = false;
                 btn_LoadMore.Content = "加载完了...";
             }
     }
     catch (Exception)
     {
         messShow.Show("读取失败,请重试",3000);
     }
 }
Beispiel #6
0
        private async void GetFilter()
        {
            try
            {
                string results = await WebClientClass.GetResults(new Uri("http://api.bilibili.com/x/dm/filter/user?jsonp=jsonp"));

                var ls = SettingHelper.Get_Guanjianzi().Split('|').ToList();
                ls.Remove(string.Empty);
                var ls2 = SettingHelper.Get_Yonghu().Split('|').ToList();
                ls2.Remove(string.Empty);

                DMFilterModel fm = JsonConvert.DeserializeObject <DMFilterModel>(results);
                if (fm.code == 0)
                {
                    foreach (var item in fm.data.rule)
                    {
                        if (item.type == 0)
                        {
                            if (!ls.Contains(item.filter))
                            {
                                SettingHelper.Set_Guanjianzi(SettingHelper.Get_Guanjianzi() + "|" + item.filter);
                            }
                        }
                        if (item.type == 2)
                        {
                            if (!ls2.Contains(item.filter))
                            {
                                SettingHelper.Set_Yonghu(SettingHelper.Get_Yonghu() + "|" + item.filter);
                            }
                        }
                    }
                    List <string> s  = new List <string>();
                    List <string> s2 = new List <string>();
                    fm.data.rule.ForEach(x => {
                        if (x.type == 0)
                        {
                            s.Add(x.filter);
                        }
                        if (x.type == 2)
                        {
                            s2.Add(x.filter);
                        }
                    });


                    foreach (var item in ls)
                    {
                        if (!s.Contains(item))
                        {
                            AddInfo(0, item);
                        }
                    }
                    foreach (var item in ls2)
                    {
                        if (!s2.Contains(item))
                        {
                            AddInfo(2, item);
                        }
                    }
                    LoadSetting();
                }
                else
                {
                    Utils.ShowMessageToast("同步失败," + fm.message, 3000);
                }
            }
            catch (Exception)
            {
                Utils.ShowMessageToast("同步失败", 3000);
            }
        }
 private async void GetNotify()
 {
     try
     {
         wc = new WebClientClass();
         //http://message.bilibili.com/api/notify/query.sysnotify.list.do?_device=android&_hwid=68fc5d795c256cd1&_ulv=10000&access_key=a36a84cc8ef4ea2f92c416951c859a25&actionKey=appkey&appkey=c1b107428d337928&build=414000&data_type=1&page_size=40&platform=android&ts=1461404973000&sign=fc3b4e26348a1204e2064e7712d10179
         string url = string.Format("http://message.bilibili.com/api/notify//query.sysnotify.list.do?_device=wp&&_ulv=10000&access_key={0}&actionKey=appkey&appkey={1}&build=410005&data_type=1&page_size=40&platform=android&ts={2}", ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetTimeSpen);
         url += "&sign=" + ApiHelper.GetSign(url);
         string results = await wc.GetResults(new Uri(url));
         MessageReplyModel model = JsonConvert.DeserializeObject<MessageReplyModel>(results);
         if (model.code == 0)
         {
             List<MessageReplyModel> list = JsonConvert.DeserializeObject<List<MessageReplyModel>>(model.data.ToString());
             list_Notify.ItemsSource = list;
         }
         else
         {
             messShow.Show("读取失败" + model.message, 3000);
         }
     }
     catch (Exception)
     {
         messShow.Show("读取失败", 3000);
     }
     
 }
Beispiel #8
0
        public static async Task <string> LoginBilibili(string UserName, string Password)
        {
            try
            {
                //https://api.bilibili.com/login?appkey=422fd9d7289a1dd9&platform=wp&pwd=JPJclVQpH4jwouRcSnngNnuPEq1S1rizxVJjLTg%2FtdqkKOizeIjS4CeRZsQg4%2F500Oye7IP4gWXhCRfHT6pDrboBNNkYywcrAhbOPtdx35ETcPfbjXNGSxteVDXw9Xq1ng0pcP1burNnAYtNRSayEKC1jiugi1LKyWbXpYE6VaM%3D&type=json&userid=xiaoyaocz&sign=74e4c872ec7b9d83d3a8a714e7e3b4b3
                //发送第一次请求,得到access_key

                string url = "https://api.bilibili.com/login?appkey=422fd9d7289a1dd9&platform=wp&pwd=" + WebUtility.UrlEncode(await GetEncryptedPassword(Password)) + "&type=json&userid=" + WebUtility.UrlEncode(UserName);
                url += "&sign=" + ApiHelper.GetSign(url);

                string results = await WebClientClass.GetResults(new Uri(url));

                //Json解析及数据判断
                LoginModel model = new LoginModel();
                model = JsonConvert.DeserializeObject <LoginModel>(results);
                if (model.code == -627)
                {
                    return("登录失败,密码错误!");
                }
                if (model.code == -626)
                {
                    return("登录失败,账号不存在!");
                }
                if (model.code == -625)
                {
                    return("密码错误多次");
                }
                if (model.code == -628)
                {
                    return("未知错误");
                }
                if (model.code == -1)
                {
                    return("登录失败,程序注册失败!请联系作者!");
                }
                Windows.Web.Http.HttpClient hc = new Windows.Web.Http.HttpClient();
                if (model.code == 0)
                {
                    access_key = model.access_key;
                    Windows.Web.Http.HttpResponseMessage hr2 = await hc.GetAsync(new Uri("http://api.bilibili.com/login/sso?&access_key=" + model.access_key + "&appkey=422fd9d7289a1dd9&platform=wp"));

                    hr2.EnsureSuccessStatusCode();

                    SettingHelper.Set_Access_key(model.access_key);
                }
                //看看存不存在Cookie
                HttpBaseProtocolFilter hb = new HttpBaseProtocolFilter();
                HttpCookieCollection   cookieCollection = hb.CookieManager.GetCookies(new Uri("http://bilibili.com/"));

                List <string> ls = new List <string>();
                foreach (HttpCookie item in cookieCollection)
                {
                    ls.Add(item.Name);
                }
                if (ls.Contains("DedeUserID"))
                {
                    return("登录成功");
                }
                else
                {
                    return("登录失败");
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867)
                {
                    return("登录失败,检查你的网络连接!");
                }
                else
                {
                    return("登录发生错误");
                }
            }
        }
Beispiel #9
0
        private async void GetInfo()
        {
            try
            {
                canLoad            = false;
                pr_load.Visibility = Visibility.Visible;
                wc = new WebClientClass();
                string url = "http://bangumi.bilibili.com/web_api/season/index?page=" + PageNum + "&pagesize=" + 30;
                url += "&version" + DHLX;
                url += "&is_finish=" + ZT;
                //url += "&is_finish=" + ZT;
                url += "&update_period=" + GXSJ;
                if (DQ.Length != 0)
                {
                    url += "&area=" + DQ;
                }
                if (FG.Length != 0)
                {
                    url += "&tag_id=" + FG;
                }
                if (NF.Length != 0)
                {
                    url += "&start_year=" + NF;
                }
                url += "&index_type=" + index_type.ToString();
                //url += "&index_sort=" + index_sort.ToString();

                string results = await wc.GetResults(new Uri(url));

                ALLBangumiModel all = JsonConvert.DeserializeObject <ALLBangumiModel>(results);
                if (all.code == 0)
                {
                    if (all.result.list.Count != 0)
                    {
                        foreach (var item in all.result.list)
                        {
                            items.Items.Add(item);
                        }
                        PageNum++;
                    }
                    else
                    {
                        messShow.Show("没有结果了", 2000);
                    }
                }
                else
                {
                    messShow.Show(all.message, 2000);
                }
            }
            catch (Exception ex)
            {
                messShow.Show("发生错误" + ex.Message, 2000);
                //throw;
            }
            finally
            {
                canLoad            = true;
                pr_load.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #10
0
        private async Task LoadVideo()
        {
            try
            {
                pivot.SelectedIndex = 0;
                comment.ClearComment();
                isMovie = false;
                tag.Children.Clear();
                pr_Load.Visibility = Visibility.Visible;
                string uri = $"https://app.bilibili.com/x/v2/view?access_key={ ApiHelper.access_key }&aid={ _aid }&appkey={ApiHelper.AndroidKey.Appkey}&build={ApiHelper.build}&mobi_app=android&plat=0&platform=android&ts={ApiHelper.GetTimeSpan}";
                uri += "&sign=" + ApiHelper.GetSign(uri);
                string results = await WebClientClass.GetResults(new Uri(uri));

                VideoInfoModels m = JsonConvert.DeserializeObject <VideoInfoModels>(results);

                if (m.code == -404 || m.code == -403)
                {
                    string re2 = await WebClientClass.GetResults(new Uri("https://www.biliplus.com/api/view?id=" + _aid + "&access_key=" + ApiHelper.access_key));

                    JObject obj = JObject.Parse(re2);
                    if (obj["code"] == null)
                    {
                        m.code = 0;
                        m.data = JsonConvert.DeserializeObject <VideoInfoModels>(obj["v2_app_api"].ToString());
                    }
                }


                if (m.code == 0)
                {
                    if (m.data.redirect_url != null && m.data.redirect_url != "")
                    {
                        this.Frame.GoBack();
                        Utils.ShowMessageToast("正在跳转至专题");
                        await MessageCenter.HandelUrl(m.data.redirect_url);

                        return;
                    }
                    this.DataContext = m.data;

                    if (m.data.movie != null)
                    {
                        //isMovie = true;

                        grid_Movie.Visibility = Visibility.Visible;
                        if (m.data.movie.movie_status == 1)
                        {
                            if (m.data.movie.pay_user.status == 0)
                            {
                                movie_pay.Visibility = Visibility.Visible;
                                txt_PayMonery.Text   = m.data.movie.payment.price.ToString("0.00");
                            }
                            else
                            {
                                isMovie = true;
                                movie_pay.Visibility = Visibility.Collapsed;
                            }
                        }
                        else
                        {
                            movie_pay.Visibility = Visibility.Collapsed;
                        }
                    }
                    else
                    {
                        grid_Movie.Visibility = Visibility.Collapsed;
                        movie_pay.Visibility  = Visibility.Collapsed;
                    }
                    if (m.data.interaction != null)
                    {
                        Utils.ShowMessageToast("这是一个互动视频,你的选项会决定剧情走向哦", 5000);
                    }

                    //m.data.pages
                    gv_Play.SelectedIndex = 0;
                    if (m.data.req_user.attention != 1)
                    {
                        btn_AttUp.Visibility       = Visibility.Visible;
                        btn_CancelAttUp.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        btn_AttUp.Visibility       = Visibility.Collapsed;
                        btn_CancelAttUp.Visibility = Visibility.Visible;
                    }
                    if (m.data.season != null)
                    {
                        ISBAN = true;
                        grid_season.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        ISBAN = false;
                        grid_season.Visibility = Visibility.Collapsed;
                    }
                    if (m.data.tag != null)
                    {
                        grid_tag.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        grid_tag.Visibility = Visibility.Collapsed;
                    }

                    if (m.data.elec != null)
                    {
                        grid_elec.Visibility  = Visibility.Visible;
                        txt_NotCb.Visibility  = Visibility.Collapsed;
                        grid_elec.DataContext = m.data.elec;
                    }
                    else
                    {
                        grid_elec.Visibility = Visibility.Collapsed;
                        txt_NotCb.Visibility = Visibility.Visible;
                    }

                    if (m.data.audio != null)
                    {
                        grid_audio.DataContext = m.data.audio;
                        grid_audio.Visibility  = Visibility.Visible;
                    }
                    else
                    {
                        grid_audio.Visibility = Visibility.Collapsed;
                    }

                    list_About.ItemsSource = null;
                    if (m.data.relates != null)
                    {
                        list_About.ItemsSource = m.data.relates;
                    }

                    if (m.data.tag != null)
                    {
                        foreach (var item in m.data.tag)
                        {
                            HyperlinkButton hy = new HyperlinkButton();
                            hy.Content    = item.tag_name;
                            hy.Margin     = new Thickness(0, 0, 10, 0);
                            hy.Foreground = App.Current.Resources["Bili-ForeColor"] as SolidColorBrush;
                            hy.Click     += Hy_Click;;
                            tag.Children.Add(hy);
                        }
                    }
                    if (m.data.staff != null && m.data.staff.Count != 0)
                    {
                        staff.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        staff.Visibility = Visibility.Collapsed;
                    }
                    if (m.data.pages != null && m.data.pages.Count != 0)
                    {
                        var qualitys = await download.GetVideoQualitys(_aid, m.data.pages[0].cid.ToString(), ApiHelper.access_key, ApiHelper.GetUserId());

                        cb_Qu.ItemsSource = qualitys.data;
                        if (qualitys.data.Count != 0)
                        {
                            cb_Qu.SelectedIndex = 0;
                        }
                    }
                    comment.LoadComment(new LoadCommentInfo()
                    {
                        commentMode      = CommentMode.Video,
                        conmmentSortMode = ConmmentSortMode.All,
                        oid = _aid
                    });
                }
                else
                {
                    if (m.code == -403)
                    {
                        error.Visibility = Visibility.Visible;
                        txt_error.Text   = "您的权限不足或者不支持你所在地区";
                        return;
                    }
                    if (m.code == -404)
                    {
                        error.Visibility = Visibility.Visible;
                        txt_error.Text   = "视频不存在或已被删除";
                        return;
                    }

                    Utils.ShowMessageToast(m.message, 3000);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867 || ex.HResult == -2147012889)
                {
                    Utils.ShowMessageToast("无法连接服务器,请检查你的网络连接", 3000);
                }
                else
                {
                    Utils.ShowMessageToast("更新数据失败了", 3000);
                }
            }
            finally
            {
                btn_HideAll_Click(null, null);
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #11
0
        private async void SetHome(bool local)
        {
            try
            {
                disaid             = "";
                pr_Load.Visibility = Visibility.Visible;

                string results = "";

                if (local)
                {
                    results = await SettingHelper.Get_HomeInfo();
                }
                else
                {
                    string url = string.Format("http://app.bilibili.com/x/v2/show?access_key={0}&appkey={1}&build=429001&mobi_app=android&platform=android&ts={2}000", ApiHelper.access_key, ApiHelper._appKey_Android, ApiHelper.GetTimeSpan);
                    url    += "&sign=" + ApiHelper.GetSign_Android(url);
                    results = await WebClientClass.GetResults(new Uri(url));

                    results = results.Replace("goto", "_goto");
                }
                HomeModel m = JsonConvert.DeserializeObject <HomeModel>(results);
                if (m.code == 0)
                {
                    if (!local && SettingHelper.IsPc())
                    {
                        SettingHelper.Set_HomeInfo(results);
                    }
                    //var ls = m.data.Where(x => x.type == "topic").ToList();

                    //topic_2.DataContext = ls[1].body[0];
                    //topic_3.DataContext = ls[2].body[0];
                    int i = 0;
                    foreach (var item in m.data)
                    {
                        switch (item.title)
                        {
                        case "热门焦点":
                            home_GridView_Hot.ItemsSource = item.body;
                            home_flipView.ItemsSource     = item.banner.top;

                            break;

                        case "正在直播":
                            home_GridView_Live.ItemsSource = item.body;
                            break;

                        case "番剧推荐":
                            home_GridView_Bangumi.ItemsSource = item.body;
                            break;

                        case "动画区":
                            home_GridView_DH.ItemsSource = item.body;
                            break;

                        case "音乐区":
                            home_GridView_YY.ItemsSource = item.body;
                            break;

                        case "舞蹈区":
                            home_GridView_WD.ItemsSource = item.body;
                            break;

                        case "游戏区":
                            home_GridView_YX.ItemsSource = item.body;
                            break;

                        case "鬼畜区":
                            home_GridView_GC.ItemsSource = item.body;
                            break;

                        case "科技区":
                            home_GridView_KJ.ItemsSource = item.body;
                            break;

                        case "活动中心":
                            home_GridView_Activity.ItemsSource = item.body;
                            break;

                        case "生活区":
                            home_GridView_SH.ItemsSource = item.body;
                            break;

                        case "娱乐区":
                            home_GridView_YL.ItemsSource = item.body;
                            break;

                        case "时尚区":
                            home_GridView_SS.ItemsSource = item.body;
                            break;

                        case "电视剧区":
                            home_GridView_DSJ.ItemsSource = item.body;
                            break;

                        case "电影区":
                            home_GridView_DY.ItemsSource = item.body;
                            break;

                        case "广告区":
                            home_GridView_GG.ItemsSource = item.body;
                            break;

                        default:
                        {
                            if (item.type == "topic")
                            {
                                switch (i)
                                {
                                case 0:
                                    topic_1.DataContext = item.body[0];
                                    break;

                                case 1:
                                    topic_2.DataContext = item.body[0];
                                    break;

                                case 2:
                                    topic_3.DataContext = item.body[0];
                                    break;

                                default:
                                    break;
                                }
                                i++;
                            }
                        }
                        break;
                        }
                    }

                    //home_GridView_Hot.ItemsSource = m.data.First(x => x.title == "热门焦点").body;
                    // home_flipView.ItemsSource = m.data.First(x => x.title == "热门焦点").banner.top;
                    //home_GridView_Live.ItemsSource = m.data.First(x => x.title == "正在直播").body;
                    //home_GridView_Bangumi.ItemsSource = m.data.First(x => x.title == "番剧推荐").body;
                    //home_GridView_Activity.ItemsSource = m.data.First(x => x.title == "活动中心").body;
                    //home_GridView_DH.ItemsSource = m.data.First(x => x.title == "动画区").body;
                    //home_GridView_DSJ.ItemsSource = m.data.First(x => x.title == "电视剧区").body;
                    //home_GridView_DY.ItemsSource = m.data.First(x => x.title == "电影区").body;
                    //home_GridView_GC.ItemsSource = m.data.First(x => x.title == "鬼畜区").body;
                    //home_GridView_GG.ItemsSource = m.data.First(x => x.title == "广告区").body;
                    //home_GridView_KJ.ItemsSource = m.data.First(x => x.title == "科技区").body;
                    //home_GridView_SH.ItemsSource = m.data.First(x => x.title == "生活区").body;
                    //home_GridView_SS.ItemsSource = m.data.First(x => x.title == "时尚区").body;
                    //home_GridView_WD.ItemsSource = m.data.First(x => x.title == "舞蹈区").body;
                    //home_GridView_YL.ItemsSource = m.data.First(x => x.title == "娱乐区").body;
                    //home_GridView_YX.ItemsSource = m.data.First(x => x.title == "游戏区").body;
                    //home_GridView_YY.ItemsSource = m.data.First(x => x.title == "音乐区").body;
                }
                else
                {
                    await new MessageDialog(m.message).ShowAsync();
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867 || ex.HResult == -2147012889)
                {
                    messShow.Show("无法连接服务器,请检查你的网络连接", 3000);
                }
                else
                {
                    messShow.Show("更新数据失败了", 3000);
                }
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #12
0
        private async void GetMessage()
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;

                // http://message.bilibili.com/api/msg/query.room.list.do?access_key=a36a84cc8ef4ea2f92c416951c859a25&actionKey=appkey&appkey=c1b107428d337928&build=414000&page_size=100&platform=android&ts=1461404884000&sign=5e212e424761aa497a75b0fb7fbde775
                string url = string.Format("https://message.bilibili.com/api/notify/query.notify.count.do?_device=android&_ulv=10000&access_key={0}&actionKey=appkey&appkey={1}&build=518000&platform=android&ts={2}", ApiHelper.AccessKey, ApiHelper.AndroidKey.Appkey, ApiHelper.TimeStamp);
                url += "&sign=" + ApiHelper.GetSign(url);
                string results = await WebClientClass.GetResults(new Uri(url));

                MessageModel model = JsonConvert.DeserializeObject <MessageModel>(results);
                if (model.code == 0)
                {
                    MessageModel list = JsonConvert.DeserializeObject <MessageModel>(model.data.ToString());
                    if (list.reply_me != 0)
                    {
                        bor_HF.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        bor_HF.Visibility = Visibility.Collapsed;
                    }

                    if (list.at_me != 0)
                    {
                        bor_At.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        bor_At.Visibility = Visibility.Collapsed;
                    }

                    if (list.praise_me != 0)
                    {
                        bor_Zan.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        bor_Zan.Visibility = Visibility.Collapsed;
                    }

                    if (list.notify_me != 0)
                    {
                        bor_TZ.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        bor_TZ.Visibility = Visibility.Collapsed;
                    }

                    if (list.chat_me != 0)
                    {
                        bor_SX.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        bor_SX.Visibility = Visibility.Collapsed;
                    }
                }
                else
                {
                    Utils.ShowMessageToast("读取通知失败," + model.message, 3000);
                }
            }
            catch (Exception)
            {
                Utils.ShowMessageToast("读取通知失败", 3000);
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }
 private async void GetChatMe()
 {
     try
     {
         wc = new WebClientClass();
         // http://message.bilibili.com/api/msg/query.room.list.do?access_key=a36a84cc8ef4ea2f92c416951c859a25&actionKey=appkey&appkey=c1b107428d337928&build=414000&page_size=100&platform=android&ts=1461404884000&sign=5e212e424761aa497a75b0fb7fbde775
         string url = string.Format("http://message.bilibili.com/api/msg/query.room.list.do?access_key={0}&actionKey=appkey&appkey={1}&build=411005&page_size=100&platform=android&ts={2}", ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetTimeSpen);
         url += "&sign=" + ApiHelper.GetSign(url);
         string results = await wc.GetResults(new Uri(url));
         MessageChatModel model = JsonConvert.DeserializeObject<MessageChatModel>(results);
         if (model.code == 0)
         {
             List<MessageChatModel> list = JsonConvert.DeserializeObject<List<MessageChatModel>>(model.data.ToString());
             list_ChatMe.ItemsSource = list;
         }
         else
         {
             messShow.Show("读取失败" + model.message, 3000);
         }
     }
     catch (Exception)
     {
         messShow.Show("读取失败", 3000);
     }
   
 }
Beispiel #14
0
        private async void LoadInfo()
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;

                string url = string.Format("http://live.bilibili.com/mobile/getUser?_device=android&access_key={0}&appkey={1}&build=434000&mobi_app=android&platform=android", ApiHelper.access_key, ApiHelper._appKey_Android);
                url += "&sign=" + ApiHelper.GetSign_Android(url);
                string results = await WebClientClass.GetResults(new Uri(url));

                LiveCenterModel m = JsonConvert.DeserializeObject <LiveCenterModel>(results);
                if (m.code == 0)
                {
                    m.data.uname = ApiHelper.userInfo.name;
                    m.data.pic   = ApiHelper.userInfo.face;

                    if (m.data.ShowVip)
                    {
                        isvip.Visibility = Visibility.Visible;
                        novip.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        isvip.Visibility = Visibility.Collapsed;
                        novip.Visibility = Visibility.Visible;
                    }
                    this.DataContext  = m.data;
                    bor_UL.Background = GetColor(m.data.user_level_color);

                    if (m.data.medal != null)
                    {
                        bor_Medal.Visibility = Visibility.Visible;
                        bor_Medal.Background = GetColor(m.data.medal.color);
                    }
                    else
                    {
                        bor_Medal.Visibility = Visibility.Collapsed;
                    }

                    if (m.data.isSign == 1)
                    {
                        btn_sign.Visibility = Visibility.Collapsed;
                        signed.Visibility   = Visibility.Visible;
                    }
                    else
                    {
                        btn_sign.Visibility = Visibility.Visible;
                        signed.Visibility   = Visibility.Collapsed;
                    }
                }
                else
                {
                    messShow.Show(m.message, 3000);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867)
                {
                    messShow.Show("检查你的网络连接!", 3000);
                }
                else
                {
                    messShow.Show("发生错误\r\n" + ex.Message, 3000);
                }
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }
        private async void GetAttention()
        {
            try
            {
                _Loading = true;
                if (_PageNum == 1)
                {
                    User_ListView_Attention.Items.Clear();
                }
                User_load_more.IsEnabled = false;
                User_load_more.Content   = "加载中...";
                _Loading = true;
                pr_Load_DT.Visibility = Visibility.Visible;
                string url = string.Format("http://api.bilibili.com/x/feed/pull?access_key={0}&actionKey=appkey&appkey={1}&platform=wp&pn={2}&ps=30&ts={3}&type=0", ApiHelper.access_key, ApiHelper._appKey, _PageNum, ApiHelper.GetTimeSpan);
                url += "&sign=" + ApiHelper.GetSign(url);
                string results = await WebClientClass.GetResults(new Uri(url));

                //一层
                AttentionModel model1 = JsonConvert.DeserializeObject <AttentionModel>(results);
                if (model1.code == 0)
                {
                    AttentionModel model2 = JsonConvert.DeserializeObject <AttentionModel>(model1.data.ToString());
                    if (model2.feeds.Count == 0)
                    {
                        messShow.Show("加载完了", 3000);
                    }
                    else
                    {
                        try
                        {
                            if (_PageNum == 1)
                            {
                                //var updater = TileUpdateManager.CreateTileUpdaterForApplication();
                                //updater.EnableNotificationQueueForWide310x150(true);
                                //updater.EnableNotificationQueueForSquare150x150(true);
                                //updater.EnableNotificationQueueForSquare310x310(true);
                                //updater.EnableNotificationQueue(true);

                                List <string> oldList = new List <string>();
                                //updater.Clear();
                                string s1 = "";
                                foreach (var item in model2.feeds)
                                {
                                    //if (SettingHelper.Get_DTCT())
                                    //{
                                    //    if (model2.feeds.IndexOf(item) <= 4)
                                    //    {
                                    //        var doc = new XmlDocument();
                                    //        var xml = string.Format(TileTemplateXml, item.addition.pic, item.addition.title, item.addition.title);
                                    //        doc.LoadXml(WebUtility.HtmlDecode(xml), new XmlLoadSettings
                                    //        {
                                    //            ProhibitDtd = false,
                                    //            ValidateOnParse = false,
                                    //            ElementContentWhiteSpace = false,
                                    //            ResolveExternals = false
                                    //        });
                                    //        updater.Update(new TileNotification(doc));
                                    //    }
                                    //}


                                    s1 += item.addition.aid + ",";
                                }

                                s1 = s1.Remove(s1.Length - 1);
                                SettingHelper.Set_TsDt(s1);
                                //container.Values["TsDt"] = s1;
                            }
                        }
                        catch (Exception)
                        {
                        }

                        model2.feeds.ForEach(x => User_ListView_Attention.Items.Add(x));
                        _PageNum++;
                    }
                }
                else
                {
                    messShow.Show(model1.message, 3000);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867 || ex.HResult == -2147012889)
                {
                    messShow.Show("无法连接服务器,请检查你的网络连接", 3000);
                }
                else
                {
                    messShow.Show("动态加载错误", 3000);
                }
            }
            finally
            {
                _Loading = false;
                User_load_more.IsEnabled = true;
                User_load_more.Content   = "加载更多";
                pr_Load_DT.Visibility    = Visibility.Collapsed;
                if (User_ListView_Attention.Items.Count == 0)
                {
                    DT_1.Visibility           = Visibility.Visible;
                    User_load_more.Visibility = Visibility.Collapsed;
                }
                else
                {
                    DT_1.Visibility           = Visibility.Collapsed;
                    User_load_more.Visibility = Visibility.Visible;
                }
            }
        }
Beispiel #16
0
        public async Task <string> GetVideoUri(string cid, int quality)
        {
            //http://interface.bilibili.com/playurl?platform=android&cid=5883400&quality=2&otype=json&appkey=422fd9d7289a1dd9&type=mp4
            try
            {
                wc = new WebClientClass();
                string url = "http://interface.bilibili.com/playurl?platform=android&cid=" + cid + "&quality=" + quality + "&otype=json&appkey=422fd9d7289a1dd9&type=mp4";
                url += "&sign=" + ApiHelper.GetSign(url);
                // url += "&sign=" + ApiHelper.GetSign(url);

                string        results = "";
                VideoUriModel model   = null;
                string        area    = "";
                if (useHkIp)
                {
                    area = "hk";
                }
                if (userTwIp)
                {
                    area = "tw";
                }
                if (userDlIp)
                {
                    area = "cn";
                }
                if (!userDlIp && !userTwIp && !useHkIp)
                {
                    results = await wc.GetResults(new Uri(url));

                    model = JsonConvert.DeserializeObject <VideoUriModel>(results);
                }
                else
                {
                    results = await wc.GetResults(new Uri("http://52uwp.com/api/BiliBili?area=" + area + "&url=" + Uri.EscapeDataString(url)));

                    MessageModel ms = JsonConvert.DeserializeObject <MessageModel>(results);


                    if (ms.code == 0)
                    {
                        model = JsonConvert.DeserializeObject <VideoUriModel>(ms.message);
                    }
                    if (ms.code == -100)
                    {
                        await new MessageDialog("远程代理失效,请联系开发者更新!").ShowAsync();
                    }
                    if (ms.code == -200)
                    {
                        await new MessageDialog("代理读取信息失败,请重试!").ShowAsync();
                    }
                }
                //-5021
                if (model.code == -5021)
                {
                    await new MessageDialog("不支持你所在地区!").ShowAsync();
                }
                List <VideoUriModel> model1 = JsonConvert.DeserializeObject <List <VideoUriModel> >(model.durl.ToString());
                return(model1[0].url);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #17
0
        public static async Task<string> LoginBilibili(string UserName, string Password)
        {
            try
            {
                //发送第一次请求,得到access_key
                WebClientClass wc = new WebClientClass();
                string results =await wc.GetResults(new Uri("https://api.bilibili.com/login?appkey=422fd9d7289a1dd9&platform=wp&pwd=" +WebUtility.UrlEncode(Password) + "&type=json&userid=" + WebUtility.UrlEncode(UserName)));
                //Json解析及数据判断
                LoginModel model = new LoginModel();
                model = JsonConvert.DeserializeObject<LoginModel>(results);
                if (model.code == -627)
                {
                    return "登录失败,密码错误!";
                }
                if (model.code == -626)
                {
                    return "登录失败,账号不存在!";
                }
                if (model.code == -625)
                {
                    return "密码错误多次";
                }
                if (model.code==-628)
                {
                    return "未知错误";
                }
                if (model.code == -1)
                {
                    return "登录失败,程序注册失败!请联系作者!";
                }
                Windows.Web.Http.HttpClient hc = new Windows.Web.Http.HttpClient();
                if (model.code == 0)
                {
                    access_key = model.access_key;
                    Windows.Web.Http.HttpResponseMessage hr2 = await hc.GetAsync(new Uri("http://api.bilibili.com/login/sso?&access_key=" + model.access_key + "&appkey=422fd9d7289a1dd9&platform=wp"));
                    hr2.EnsureSuccessStatusCode();
                    StorageFolder folder = ApplicationData.Current.LocalFolder;
                    StorageFile file = await folder.CreateFileAsync("us.bili", CreationCollisionOption.OpenIfExists);
                    await FileIO.WriteTextAsync(file, model.access_key);
                }
                //看看存不存在Cookie
                HttpBaseProtocolFilter hb = new HttpBaseProtocolFilter();
                HttpCookieCollection cookieCollection = hb.CookieManager.GetCookies(new Uri("http://bilibili.com/"));
                List<string> ls = new List<string>();
                foreach (HttpCookie item in cookieCollection)
                {
                    ls.Add(item.Name);
                }
                if (ls.Contains("DedeUserID"))
                {
                    return "登录成功";
                }
                else
                {
                    return "登录失败";
                }
            }
            catch (Exception)
            {
                return "登录发生错误";
            }

        }
 public async Task GetPlayInfo(string mid, int quality)
 {
     try
     {
         pro_Num.Text = "读取视频地址...";
         WebClientClass wc = new WebClientClass();
         string url = "http://interface.bilibili.com/playurl?platform=android&cid=" + mid + "&quality=" + quality + "&otype=json&appkey=422fd9d7289a1dd9&type=mp4";
         url += "&sign=" + ApiHelper.GetSign(url);
         string results = await wc.GetResults(new Uri(url));
         VideoUriModel model = JsonConvert.DeserializeObject<VideoUriModel>(results);
         List<VideoUriModel> model1 = JsonConvert.DeserializeObject<List<VideoUriModel>>(model.durl.ToString());
         mediaElement.Source = new Uri(model1[0].url);
         pro_Num.Text = "开始缓冲视频...";
     }
     catch (Exception)
     {
         MessageDialog md = new MessageDialog("视频地址获取失败!", "错误");
         await md.ShowAsync();
     }
 }
Beispiel #19
0
        public async void GetLiveInfo()
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;
                gridview_Hot.Items.Clear();
                gridview_SJ.Items.Clear();
                gridview_DJ.Items.Clear();
                gridview_FY.Items.Clear();
                gridview_HH.Items.Clear();
                gridview_JJ.Items.Clear();
                //gridview_MZ.Items.Clear();
                gridview_SY.Items.Clear();
                gridview_WL.Items.Clear();
                gridview_YZ.Items.Clear();
                gridview_CW.Items.Clear();
                WebClientClass wc  = new WebClientClass();
                string         url = string.Format("http://live.bilibili.com/AppIndex/home?_device=wp&_ulv=10000&access_key={0}&appkey={1}&build=411005&platform=android&scale=xxhdpi&rnd={2}", ApiHelper.access_key, ApiHelper._appKey, new Random().Next(1, 9999));
                url += "&sign=" + ApiHelper.GetSign(url);
                string results = await wc.GetResults(new Uri(url));

                HomeLiveModel model = JsonConvert.DeserializeObject <HomeLiveModel>(results);
                if (model.code == 0)
                {
                    HomeLiveModel        dataModel = JsonConvert.DeserializeObject <HomeLiveModel>(model.data.ToString());
                    List <HomeLiveModel> partModel = JsonConvert.DeserializeObject <List <HomeLiveModel> >(dataModel.partitions.ToString());
                    foreach (HomeLiveModel item in partModel)
                    {
                        HomeLiveModel        partitionModel = JsonConvert.DeserializeObject <HomeLiveModel>(item.partition.ToString());
                        List <HomeLiveModel> livesModel     = JsonConvert.DeserializeObject <List <HomeLiveModel> >(item.lives.ToString());
                        switch (partitionModel.name)
                        {
                        //case "热门直播":
                        //    for (int i = 0; i < livesModel.Count; i++)
                        //    {
                        //        HomeLiveModel ownerModel = JsonConvert.DeserializeObject<HomeLiveModel>(livesModel[i].owner.ToString());
                        //        HomeLiveModel coverModel = JsonConvert.DeserializeObject<HomeLiveModel>(livesModel[i].cover.ToString());
                        //        livesModel[i].src = coverModel.src;
                        //        livesModel[i].name = ownerModel.name;
                        //        livesModel[i].mid = ownerModel.mid;
                        //        livesModel[i].face = ownerModel.face;
                        //        gridview_Hot.Items.Add(livesModel[i]);
                        //    }
                        //    break;
                        case "手机直播":
                            for (int i = 0; i < livesModel.Count; i++)
                            {
                                HomeLiveModel ownerModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].owner.ToString());
                                HomeLiveModel coverModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].cover.ToString());
                                livesModel[i].src  = coverModel.src;
                                livesModel[i].name = ownerModel.name;
                                livesModel[i].mid  = ownerModel.mid;
                                livesModel[i].face = ownerModel.face;
                                gridview_SJ.Items.Add(livesModel[i]);
                            }
                            break;

                        case "唱见舞见":
                            for (int i = 0; i < livesModel.Count; i++)
                            {
                                HomeLiveModel ownerModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].owner.ToString());
                                HomeLiveModel coverModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].cover.ToString());
                                livesModel[i].src  = coverModel.src;
                                livesModel[i].name = ownerModel.name;
                                livesModel[i].mid  = ownerModel.mid;
                                livesModel[i].face = ownerModel.face;
                                gridview_CW.Items.Add(livesModel[i]);
                            }
                            break;

                        //case "萌宅推荐":
                        //    for (int i = 0; i < livesModel.Count; i++)
                        //    {
                        //        HomeLiveModel ownerModel = JsonConvert.DeserializeObject<HomeLiveModel>(livesModel[i].owner.ToString());
                        //        HomeLiveModel coverModel = JsonConvert.DeserializeObject<HomeLiveModel>(livesModel[i].cover.ToString());
                        //        livesModel[i].src = coverModel.src;
                        //        livesModel[i].name = ownerModel.name;
                        //        livesModel[i].mid = ownerModel.mid;
                        //        livesModel[i].face = ownerModel.face;
                        //        gridview_MZ.Items.Add(livesModel[i]);
                        //    }
                        //    break;
                        case "绘画专区":
                            for (int i = 0; i < livesModel.Count - 1; i++)
                            {
                                HomeLiveModel ownerModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].owner.ToString());
                                HomeLiveModel coverModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].cover.ToString());
                                livesModel[i].src  = coverModel.src;
                                livesModel[i].name = ownerModel.name;
                                livesModel[i].mid  = ownerModel.mid;
                                livesModel[i].face = ownerModel.face;
                                gridview_HH.Items.Add(livesModel[i]);
                            }
                            break;

                        case "御宅文化":
                            for (int i = 0; i < livesModel.Count; i++)
                            {
                                HomeLiveModel ownerModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].owner.ToString());
                                HomeLiveModel coverModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].cover.ToString());
                                livesModel[i].src  = coverModel.src;
                                livesModel[i].name = ownerModel.name;
                                livesModel[i].mid  = ownerModel.mid;
                                livesModel[i].face = ownerModel.face;
                                gridview_YZ.Items.Add(livesModel[i]);
                            }
                            break;

                        case "手游直播":
                            for (int i = 0; i < livesModel.Count; i++)
                            {
                                HomeLiveModel ownerModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].owner.ToString());
                                HomeLiveModel coverModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].cover.ToString());
                                livesModel[i].src  = coverModel.src;
                                livesModel[i].name = ownerModel.name;
                                livesModel[i].mid  = ownerModel.mid;
                                livesModel[i].face = ownerModel.face;
                                gridview_SY.Items.Add(livesModel[i]);
                            }
                            break;

                        case "单机联机":
                            for (int i = 0; i < livesModel.Count; i++)
                            {
                                HomeLiveModel ownerModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].owner.ToString());
                                HomeLiveModel coverModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].cover.ToString());
                                livesModel[i].src  = coverModel.src;
                                livesModel[i].name = ownerModel.name;
                                livesModel[i].mid  = ownerModel.mid;
                                livesModel[i].face = ownerModel.face;
                                gridview_DJ.Items.Add(livesModel[i]);
                            }
                            break;

                        case "网络游戏":
                            for (int i = 0; i < livesModel.Count; i++)
                            {
                                HomeLiveModel ownerModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].owner.ToString());
                                HomeLiveModel coverModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].cover.ToString());
                                livesModel[i].src  = coverModel.src;
                                livesModel[i].name = ownerModel.name;
                                livesModel[i].mid  = ownerModel.mid;
                                livesModel[i].face = ownerModel.face;
                                gridview_WL.Items.Add(livesModel[i]);
                            }
                            break;

                        case "电子竞技":
                            for (int i = 0; i < livesModel.Count; i++)
                            {
                                HomeLiveModel ownerModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].owner.ToString());
                                HomeLiveModel coverModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].cover.ToString());
                                livesModel[i].src  = coverModel.src;
                                livesModel[i].name = ownerModel.name;
                                livesModel[i].mid  = ownerModel.mid;
                                livesModel[i].face = ownerModel.face;
                                gridview_JJ.Items.Add(livesModel[i]);
                            }
                            break;

                        case "放映厅":
                            for (int i = 0; i < livesModel.Count; i++)
                            {
                                HomeLiveModel ownerModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].owner.ToString());
                                HomeLiveModel coverModel = JsonConvert.DeserializeObject <HomeLiveModel>(livesModel[i].cover.ToString());
                                livesModel[i].src  = coverModel.src;
                                livesModel[i].name = ownerModel.name;
                                livesModel[i].mid  = ownerModel.mid;
                                livesModel[i].face = ownerModel.face;
                                gridview_FY.Items.Add(livesModel[i]);
                            }
                            break;
                        }
                    }
                    isLoaded = true;
                }
                else
                {
                    ErrorEvent("读取直播失败" + model.message);
                    isLoaded = false;
                }
            }
            catch (Exception ex)
            {
                ErrorEvent("读取直播失败" + ex.Message);
                isLoaded = false;
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #20
0
        /// <summary>
        /// 取稍后再看列表
        /// </summary>
        /// <returns></returns>
        public async Task <ReturnModel <ObservableCollection <ToViewsModel> > > GetToViewList()
        {
            try
            {
                if (!ApiHelper.IsLogin())
                {
                    return(new ReturnModel <ObservableCollection <ToViewsModel> >()
                    {
                        message = "请先登录",
                        success = false
                    });
                }
                string url = string.Format("https://api.bilibili.com/x/v2/history/toview/web?access_key={0}&appkey={1}&ts={2}", ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetTimeSpan);
                url += "&sign=" + ApiHelper.GetSign(url);

                var results = await WebClientClass.GetResults(new Uri(url));

                ToViewsModel model = JsonConvert.DeserializeObject <ToViewsModel>(results);
                if (model.code == 0)
                {
                    if (model.data.list == null)
                    {
                        model.data.list = new ObservableCollection <ToViewsModel>();
                    }
                    return(new ReturnModel <ObservableCollection <ToViewsModel> >()
                    {
                        success = true,
                        message = "",
                        data = model.data.list,
                    });
                }
                else
                {
                    return(new ReturnModel <ObservableCollection <ToViewsModel> >()
                    {
                        success = false,
                        message = model.message
                    });
                }
            }
            catch (Exception ex)
            {
                if (LogHelper.IsNetworkError(ex))
                {
                    return(new ReturnModel <ObservableCollection <ToViewsModel> >()
                    {
                        success = false,
                        message = "无法连接服务器,请检查网络连接"
                    });
                }
                else
                {
                    LogHelper.WriteLog(ex);
                    return(new ReturnModel <ObservableCollection <ToViewsModel> >()
                    {
                        success = false,
                        message = "出现了一个未处理错误,已记录"
                    });
                }
            }
        }
Beispiel #21
0
        private async void GetComment()
        {
            if (_page == 1)
            {
                noRepost.Visibility    = Visibility.Collapsed;
                closeRepost.Visibility = Visibility.Collapsed;
                //ls_hot.ItemsSource = null;
                ls_new.ItemsSource = null;
            }
            try
            {
                var sort = 0;
                if (_loadCommentInfo.conmmentSortMode == ConmmentSortMode.Hot)
                {
                    sort = 2;
                }

                btn_LoadMore.Visibility = Visibility.Collapsed;
                _loading           = true;
                pr_load.Visibility = Visibility.Visible;
                ObservableCollection <CommentModel> ls = new ObservableCollection <CommentModel>();
                var url = string.Format("https://api.bilibili.com/x/v2/reply?access_key={0}&appkey={1}&build={7}&mobi_app=android&oid={2}&plat=2&platform=android&pn={3}&ps=20&sort={6}&ts={4}&type={5}",
                                        ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, _loadCommentInfo.oid, _page, ApiHelper.GetTimeSpan_2, _type, sort, ApiHelper.build);
                url += "&sign=" + ApiHelper.GetSign(url);

                //var url = "https://api.bilibili.com/x/v2/reply?oid=2381475&plat=2&pn=1&ps=20&sort=0&type=11";

                var re = await WebClientClass.GetResults(new Uri(url));

                dataCommentModel m = JsonConvert.DeserializeObject <dataCommentModel>(re);
                if (m.code == 0)
                {
                    if (m.data.replies != null && m.data.replies.Count != 0)
                    {
                        if (_page == 1)
                        {
                            if (m.data.upper.top != null)
                            {
                                m.data.upper.top.showTop = Visibility.Visible;
                                m.data.replies.Insert(0, m.data.upper.top);
                            }
                            //ls_hot.ItemsSource = m.data.hots;
                            ls_new.ItemsSource = m.data.replies;
                        }
                        else
                        {
                            foreach (var item in m.data.replies)
                            {
                                (ls_new.ItemsSource as ObservableCollection <CommentModel>).Add(item);
                            }
                        }
                        _page++;

                        if (m.data.replies.Count >= 20)
                        {
                            btn_LoadMore.Visibility = Visibility.Visible;
                        }
                    }
                    else
                    {
                        if (_page == 1)
                        {
                            noRepost.Visibility = Visibility.Visible;
                        }
                        else
                        {
                            Utils.ShowMessageToast("全部加载完了...");
                        }
                    }
                }
                else
                {
                    if (m.code == 12002)
                    {
                        closeRepost.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        Utils.ShowMessageToast(m.message);
                    }
                }
            }
            catch (Exception)
            {
                Utils.ShowMessageToast("加载评论失败");
            }
            finally
            {
                _loading           = false;
                pr_load.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #22
0
        private async void LoadMusic(string id)
        {
            try
            {
                string url = string.Format("https://api.bilibili.com/audio/music-service-c/songs/playing?access_key={0}&appkey={1}&build=5250000&mid={2}&mobi_app=android&platform=android&song_id={3}&ts={4}",
                                           ApiHelper.AccessKey, ApiHelper.AndroidKey.Appkey, ApiHelper.GetUserId(), id, ApiHelper.TimeStamp);
                url += "&sign=" + ApiHelper.GetSign(url);

                string re = await WebClientClass.GetResults(new Uri(url));

                SongInfoModel obj = JsonConvert.DeserializeObject <SongInfoModel>(re);
                if (obj.code == 0)
                {
                    if (obj.data.mid == 0)
                    {
                        user.Visibility  = Visibility.Collapsed;
                        intro.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        user.Visibility  = Visibility.Visible;
                        intro.Visibility = Visibility.Visible;
                    }
                    if (obj.data.pgc_info != null)
                    {
                        btn_OpenPcMenu.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        btn_OpenPcMenu.Visibility = Visibility.Collapsed;
                    }
                    this.DataContext = obj.data;

                    //if (obj.data.is_collect==0)
                    //{
                    //    btn_Collect.Visibility = Visibility.Visible;
                    //    btn_CancelCollect.Visibility = Visibility.Collapsed;
                    //}
                    //else
                    //{
                    //    btn_Collect.Visibility = Visibility.Collapsed;
                    //    btn_CancelCollect.Visibility = Visibility.Visible;
                    //}

                    if (obj.data.up_is_follow == 0)
                    {
                        btn_FollowUser.Visibility       = Visibility.Visible;
                        btn_CancelFollowUser.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        btn_FollowUser.Visibility       = Visibility.Collapsed;
                        btn_CancelFollowUser.Visibility = Visibility.Visible;
                    }


                    if (MusicHelper.playList.Find(x => x.songid == _songId) == null)
                    {
                        var m = await MusicHelper.GetMusicUri(_songId);

                        if (m != null)
                        {
                            MusicHelper.AddToPlay(new MusicPlayModel()
                            {
                                url    = m,
                                artist = obj.data.author,
                                pic    = obj.data.cover_url,
                                songid = id,
                                title  = obj.data.title
                            });
                        }
                        else
                        {
                            await new MessageDialog("无法读取歌曲播放地址").ShowAsync();
                        }
                        Utils.ShowMessageToast("已经添加到播放列表");
                    }
                }
                else
                {
                    Utils.ShowMessageToast(obj.msg);
                }
            }
            catch (Exception)
            {
                Utils.ShowMessageToast("读取歌曲信息错误");
            }
        }
        //时间表
        public async void GetBangumiTimeLine()
        {
            try
            {
                pr_Load_Ban.Visibility = Visibility.Visible;
                WebClientClass wc      = new WebClientClass();
                string         results = await wc.GetResults(new Uri("http://app.bilibili.com/bangumi/timeline_v2"));

                BangumiTimeLineModel model = new BangumiTimeLineModel();
                model = JsonConvert.DeserializeObject <BangumiTimeLineModel>(results);
                List <BangumiTimeLineModel> ban = JsonConvert.DeserializeObject <List <BangumiTimeLineModel> >(model.list.ToString());
                list_0.Items.Clear();
                list_1.Items.Clear();
                list_2.Items.Clear();
                list_3.Items.Clear();
                list_4.Items.Clear();
                list_5.Items.Clear();
                list_6.Items.Clear();
                list_7.Items.Clear();
                foreach (BangumiTimeLineModel item in ban)
                {
                    switch (item.weekday)
                    {
                    case -1:
                        list_7.Items.Add(item);
                        break;

                    case 0:
                        switch (taday)
                        {
                        case 0:
                            list_0.Items.Add(item);
                            break;

                        case 1:
                            list_1.Items.Add(item);
                            break;

                        case 2:
                            list_2.Items.Add(item);
                            break;

                        case 3:
                            list_3.Items.Add(item);
                            break;

                        case 4:
                            list_4.Items.Add(item);
                            break;

                        case 5:
                            list_5.Items.Add(item);
                            break;

                        case 6:
                            list_6.Items.Add(item);
                            break;

                        default:
                            break;
                        }
                        break;

                    case 1:
                        switch (taday)
                        {
                        case 1:
                            list_0.Items.Add(item);
                            break;

                        case 2:
                            list_1.Items.Add(item);
                            break;

                        case 3:
                            list_2.Items.Add(item);
                            break;

                        case 4:
                            list_3.Items.Add(item);
                            break;

                        case 5:
                            list_4.Items.Add(item);
                            break;

                        case 6:
                            list_5.Items.Add(item);
                            break;

                        case 0:
                            list_6.Items.Add(item);
                            break;

                        default:
                            break;
                        }
                        break;

                    case 2:
                        switch (taday)
                        {
                        case 2:
                            list_0.Items.Add(item);
                            break;

                        case 3:
                            list_1.Items.Add(item);
                            break;

                        case 4:
                            list_2.Items.Add(item);
                            break;

                        case 5:
                            list_3.Items.Add(item);
                            break;

                        case 6:
                            list_4.Items.Add(item);
                            break;

                        case 0:
                            list_5.Items.Add(item);
                            break;

                        case 1:
                            list_6.Items.Add(item);
                            break;

                        default:
                            break;
                        }
                        break;

                    case 3:
                        switch (taday)
                        {
                        case 3:
                            list_0.Items.Add(item);
                            break;

                        case 4:
                            list_1.Items.Add(item);
                            break;

                        case 5:
                            list_2.Items.Add(item);
                            break;

                        case 6:
                            list_3.Items.Add(item);
                            break;

                        case 0:
                            list_4.Items.Add(item);
                            break;

                        case 1:
                            list_5.Items.Add(item);
                            break;

                        case 2:
                            list_6.Items.Add(item);
                            break;

                        default:
                            break;
                        }
                        break;

                    case 4:
                        switch (taday)
                        {
                        case 4:
                            list_0.Items.Add(item);
                            break;

                        case 5:
                            list_1.Items.Add(item);
                            break;

                        case 6:
                            list_2.Items.Add(item);
                            break;

                        case 0:
                            list_3.Items.Add(item);
                            break;

                        case 1:
                            list_4.Items.Add(item);
                            break;

                        case 2:
                            list_5.Items.Add(item);
                            break;

                        case 3:
                            list_6.Items.Add(item);
                            break;

                        default:
                            break;
                        }
                        break;

                    case 5:
                        switch (taday)
                        {
                        case 5:
                            list_0.Items.Add(item);
                            break;

                        case 6:
                            list_1.Items.Add(item);
                            break;

                        case 0:
                            list_2.Items.Add(item);
                            break;

                        case 1:
                            list_3.Items.Add(item);
                            break;

                        case 2:
                            list_4.Items.Add(item);
                            break;

                        case 3:
                            list_5.Items.Add(item);
                            break;

                        case 4:
                            list_6.Items.Add(item);
                            break;

                        default:
                            break;
                        }
                        break;

                    case 6:
                        switch (taday)
                        {
                        case 6:
                            list_0.Items.Add(item);
                            break;

                        case 0:
                            list_1.Items.Add(item);
                            break;

                        case 1:
                            list_2.Items.Add(item);
                            break;

                        case 2:
                            list_3.Items.Add(item);
                            break;

                        case 3:
                            list_4.Items.Add(item);
                            break;

                        case 4:
                            list_5.Items.Add(item);
                            break;

                        case 5:
                            list_6.Items.Add(item);
                            break;

                        default:
                            break;
                        }
                        break;

                    default:
                        break;
                    }
                }
                pr_Load_Ban.Visibility = Visibility.Collapsed;
            }
            catch (Exception ex)
            {
                MessageDialog md = new MessageDialog("读取番剧更新失败\r\n" + ex.Message);
                await md.ShowAsync();
            }
        }
Beispiel #24
0
        private async void LoadMenu()
        {
            try
            {
                loading                 = true;
                pr_load.Visibility      = Visibility.Visible;
                btn_LoadMore.Visibility = Visibility.Collapsed;
                int catId  = 0;
                int itemId = 0;
                if (_selectCategroies != null)
                {
                    catId  = _selectCategroies.cateId;
                    itemId = _selectCategroies.itemId;
                }
                if (_page == 1)
                {
                    list_menus.ItemsSource = null;
                }
                string url = "";
                switch (_opentype)
                {
                case OpenMenuType.Menu:
                    url = string.Format("https://api.bilibili.com/audio/music-service-c/menus/filteMenu?appkey={0}&build=5250000&cateId={1}&itemId={2}&mobi_app=android&orderBy={3}&pageNum={4}&pageSize=24&platform=android&ts={5}", ApiHelper._appKey, catId, itemId, _sort, _page, ApiHelper.GetTimeSpan);
                    break;

                case OpenMenuType.Album:
                    url = string.Format("https://api.bilibili.com/audio/music-service-c/menus/filte-pmenu?appkey={0}&build=5250000&cateId={1}&itemId={2}&mobi_app=android&orderBy={3}&pageNum={4}&pageSize=24&platform=android&ts={5}", ApiHelper._appKey, catId, itemId, _sort, _page, ApiHelper.GetTimeSpan);
                    break;

                case OpenMenuType.MissEvan:
                    url = string.Format("https://api.bilibili.com/audio/music-service-c/menus/missevan?appkey={0}&build=5250000&cateId={1}&itemId={2}&mobi_app=android&orderBy={3}&pageNum={4}&pageSize=24&platform=android&ts={5}", ApiHelper._appKey, catId, itemId, _sort, _page, ApiHelper.GetTimeSpan);
                    break;

                default:
                    break;
                }
                url += "&sign=" + ApiHelper.GetSign(url);
                var results = await WebClientClass.GetResults(new Uri(url));

                MusicCateMenusModel obj = JsonConvert.DeserializeObject <MusicCateMenusModel>(results);

                if (obj.code == 0)
                {
                    if (obj.data.list != null && obj.data.list.Count != 0)
                    {
                        if (_page == 1)
                        {
                            list_menus.ItemsSource = obj.data.list;
                        }
                        else
                        {
                            var ls = list_menus.ItemsSource as ObservableCollection <MusicHomeMenuModel>;
                            foreach (var item in obj.data.list)
                            {
                                ls.Add(item);
                            }
                        }
                        btn_LoadMore.Visibility = Visibility.Visible;
                        _page++;
                    }
                    else
                    {
                        Utils.ShowMessageToast("加载完了");
                    }
                }
                else
                {
                    Utils.ShowMessageToast(obj.msg);
                }
            }
            catch (Exception)
            {
                Utils.ShowMessageToast("加载失败歌单");
            }
            finally
            {
                loading            = false;
                pr_load.Visibility = Visibility.Collapsed;
            }
        }
 public async void GetPlayInfo(string mid, int quality)
 {
     //http://interface.bilibili.com/playurl?platform=android&cid=5883400&quality=2&otype=json&appkey=422fd9d7289a1dd9&type=mp4
     try
     {
         WebClientClass wc = new WebClientClass();
             string results = await wc.GetResults(new Uri("http://interface.bilibili.com/playurl?platform=android&cid=" + mid + "&quality=" + 2 + "&otype=json&appkey=422fd9d7289a1dd9&type=mp4"));
         VideoUriModel model = JsonConvert.DeserializeObject<VideoUriModel>(results);
             List<VideoUriModel> model1 = JsonConvert.DeserializeObject<List<VideoUriModel>>(model.durl.ToString());
             mediaElment.Source = new Uri(model1[0].url);
     }
     catch (Exception)
     {
         MessageDialog md = new MessageDialog("视频地址获取失败!", "错误");
         await md.ShowAsync();
     }
 }
Beispiel #26
0
        private async void GetUserInfo()
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;
                try
                {
                    string results = await WebClientClass.PostResults(new Uri("http://space.bilibili.com/ajax/member/GetInfo"), "mid=" + Uid + "&_=" + ApiHelper.TimeStamp2, "http://space.bilibili.com/" + Uid + "/");

                    JObject jObject = JObject.Parse(results);
                    img_bg.ImageSource = new BitmapImage(new Uri("https://i0.hdslb.com/" + jObject["data"]["toutu"]));
                }
                catch (Exception)
                {
                    img_bg.ImageSource = new BitmapImage(new Uri("ms-appx:///Assets/Img/toutu.png"));
                }

                string url = string.Format("https://app.bilibili.com/x/v2/space?access_key={0}&appkey={1}&build=5250000&from=712&mobi_app=android&platform=android&ps=10&ts={2}&vmid={3}", ApiHelper.AccessKey, ApiHelper.AndroidKey.Appkey, ApiHelper.TimeStamp, Uid);
                url += "&sign=" + ApiHelper.GetSign(url);
                string results1 = await WebClientClass.GetResults(new Uri(url));

                UserInfoModel m = JsonConvert.DeserializeObject <UserInfoModel>(results1);
                if (m.code == 0)
                {
                    if (m.data.relation == 1 && ApiHelper.IsLogin())
                    {
                        btn_AddFollow.Visibility    = Visibility.Collapsed;
                        btn_CancelFollow.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        btn_AddFollow.Visibility    = Visibility.Visible;
                        btn_CancelFollow.Visibility = Visibility.Collapsed;
                    }

                    if (Uid == ApiHelper.GetUserId())
                    {
                        btn_AddFollow.Visibility    = Visibility.Collapsed;
                        btn_CancelFollow.Visibility = Visibility.Collapsed;
                    }

                    if (m.data.season != null && m.data.season.item != null)
                    {
                        DT_0.Visibility = Visibility.Collapsed;
                    }
                    else
                    {
                        DT_0.Visibility = Visibility.Visible;
                    }

                    if (m.data.card.vip.vipType != 0)
                    {
                        if (m.data.card.vip.vipType == 2)
                        {
                            viptype.Text = "年度大会员";
                        }
                        else
                        {
                            viptype.Text = "大会员";
                        }
                        bor_Vip.Visibility = Visibility.Visible;
                    }
                    else
                    {
                        bor_Vip.Visibility = Visibility.Collapsed;
                    }

                    if (m.data.card.level_info.current_level <= 3)
                    {
                        bor_Level.Background = new SolidColorBrush(new Windows.UI.Color()
                        {
                            R = 48, G = 161, B = 255, A = 200
                        });
                    }
                    else
                    {
                        if (m.data.card.level_info.current_level <= 6)
                        {
                            bor_Level.Background = new SolidColorBrush(new Windows.UI.Color()
                            {
                                R = 255, G = 48, B = 48, A = 200
                            });
                        }
                        else
                        {
                            bor_Level.Background = new SolidColorBrush(new Windows.UI.Color()
                            {
                                R = 255, G = 199, B = 45, A = 200
                            });
                        }
                    }

                    switch (m.data.card.sex)
                    {
                    case "男":
                        ic_female.Visibility = Visibility.Collapsed;
                        ic_gay.Visibility    = Visibility.Collapsed;
                        ic_male.Visibility   = Visibility.Visible;
                        break;

                    case "女":
                        ic_female.Visibility = Visibility.Visible;
                        ic_gay.Visibility    = Visibility.Collapsed;
                        ic_male.Visibility   = Visibility.Collapsed;
                        break;

                    default:
                        ic_female.Visibility = Visibility.Collapsed;
                        ic_gay.Visibility    = Visibility.Visible;
                        ic_male.Visibility   = Visibility.Collapsed;
                        break;
                    }
                    if (m.data.coin_archive != null && m.data.coin_archive.item != null)
                    {
                        list_ACoin.ItemsSource = m.data.coin_archive.item;
                    }
                    info.DataContext          = m.data.card;
                    grid_UserInfo.DataContext = m.data.card;
                    data.DataContext          = m.data;
                }

                user_GridView_FovBox.ItemsSource = await GetUserFovBox();
            }
            catch (Exception)
            {
                Utils.ShowMessageToast("读取用户信息失败", 3000);
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }
        private async void btn_concern_Click(object sender, RoutedEventArgs e)
        {
            UserClass getLogin = new UserClass();
            wc = new WebClientClass();
            if (getLogin.IsLogin())
            {
                try
                {
                    if (btn_concern.Label == "订阅")
                    {
                        //http://www.bilibili.com/api_proxy?app=bangumi&action=/concern_season&season_id=779
                        string results = await wc.GetResults(new Uri("http://www.bilibili.com/api_proxy?app=bangumi&action=/concern_season&season_id=" + banID));
                        JObject json = JObject.Parse(results);
                        if ((int)json["code"] == 0)
                        {
                            font_icon.Glyph = "\uE00B";
                            btn_concern.Label = "取消订阅";
                            messShow.Show("订阅成功!", 3000);
                            //MessageDialog md = new MessageDialog("订阅成功!");
                            //  await md.ShowAsync();

                        }
                        else
                        {
                            messShow.Show("订阅失败!", 3000);
                        }
                    }
                    else
                    {
                        //http://www.bilibili.com/api_proxy?app=bangumi&action=/concern_season&season_id=779

                        string results = await wc.GetResults(new Uri("http://www.bilibili.com/api_proxy?app=bangumi&action=/unconcern_season&season_id=" + banID));
                        JObject json = JObject.Parse(results);
                        if ((int)json["code"] == 0)
                        {
                            font_icon.Glyph = "\uE006";
                            btn_concern.Label = "订阅";
                            messShow.Show("取消订阅成功!", 3000);
                            
                        }
                        else
                        {
                            messShow.Show("取消订阅失败!", 3000);
                        }
                    }
                }
                catch (Exception)
                {
                    MessageDialog md = new MessageDialog("订阅操作失败!");

                    await md.ShowAsync();
                }
            }
            else
            {
                MessageDialog md = new MessageDialog("先登录好伐", "(´・ω・`) ");
                await md.ShowAsync();
            }
        }
Beispiel #28
0
        public async void GetBangumiInfo(string banID)
        {
            //string uri = "http://bangumi.bilibili.com/api/season?_device=wp&_ulv=10000&build=411005&platform=android&appkey=422fd9d7289a1dd9&ts="+APIHelper.GetTimeSpen+ "000&type=sp&sp_id=56719";
            //string sign=  APIHelper.GetSign(uri);
            //uri += "&sign=" + sign;
            try
            {
                pr_load.Visibility = Visibility.Visible;
                wc = new WebClientClass();
                string uri = "";
                uri  = string.Format("http://bangumi.bilibili.com/api/season_v3?_device=wp&access_key={2}&_ulv=10000&build=411005&platform=android&appkey=422fd9d7289a1dd9&ts={0}000&type=bangumi&season_id={1}", ApiHelper.GetTimeSpen, banID, ApiHelper.access_key);
                uri += "&sign=" + ApiHelper.GetSign(uri);
                string area   = "";
                string result = "";
                if (useHkIp)
                {
                    area = "hk";
                }
                if (userTwIp)
                {
                    area = "tw";
                }
                if (userDlIp)
                {
                    area = "cn";
                }
                if (!userDlIp && !userTwIp && !useHkIp)
                {
                    result = await wc.GetResults(new Uri(uri));
                }
                else
                {
                    string re = await wc.GetResults(new Uri("http://52uwp.com/api/BiliBili?area=" + area + "&url=" + Uri.EscapeDataString(uri)));

                    MessageModel ms = JsonConvert.DeserializeObject <MessageModel>(re);
                    if (ms.code == 0)
                    {
                        result = ms.message;
                    }
                    if (ms.code == -100)
                    {
                        await new MessageDialog("远程代理失效,请联系开发者更新!").ShowAsync();
                    }
                    if (ms.code == -200)
                    {
                        await new MessageDialog("代理读取信息失败,请重试!").ShowAsync();
                    }
                }
                BangumiInfoModel model = new BangumiInfoModel();
                if ((int)JObject.Parse(result)["code"] == 0)
                {
                    model = JsonConvert.DeserializeObject <BangumiInfoModel>(JObject.Parse(result)["result"].ToString());
                    grid_Info.DataContext = model;
                    BangumiInfoModel m = JsonConvert.DeserializeObject <BangumiInfoModel>(model.user_season.ToString());
                    if (m.attention == 0)
                    {
                        font_icon.Glyph   = "\uE006";
                        btn_concern.Label = "订阅";
                    }
                    else
                    {
                        font_icon.Glyph   = "\uE00B";
                        btn_concern.Label = "取消订阅";
                    }
                    if (model.rank != null)
                    {
                        BangumiInfoModel rank = JsonConvert.DeserializeObject <BangumiInfoModel>(model.rank.ToString());
                        grid_Cb.DataContext  = rank;
                        grid_Cb.Visibility   = Visibility.Visible;
                        txt_NotCb.Visibility = Visibility.Collapsed;
                        GetRankInfo();
                    }
                    else
                    {
                        txt_NotCb.Visibility = Visibility.Visible;
                        grid_Cb.Visibility   = Visibility.Collapsed;
                    }

                    if (model.seasons != null)
                    {
                        Grid_About.Visibility = Visibility.Visible;
                        List <BangumiInfoModel> seasons = JsonConvert.DeserializeObject <List <BangumiInfoModel> >(model.seasons.ToString());
                        WrapPanel_About.Children.Clear();
                        if (seasons.Count == 1)
                        {
                            Grid_About.Visibility = Visibility.Collapsed;
                        }
                        else
                        {
                            foreach (BangumiInfoModel item in seasons)
                            {
                                HyperlinkButton btn = new HyperlinkButton();
                                btn.DataContext = item;
                                btn.Margin      = new Thickness(0, 0, 10, 0);
                                btn.Content     = item.title;
                                btn.Foreground  = App.Current.Resources["Bili-ForeColor"] as SolidColorBrush;
                                if (item.season_id == banID)
                                {
                                    btn.IsEnabled = false;
                                }
                                btn.Click += Btn_Click1;
                                WrapPanel_About.Children.Add(btn);
                            }
                        }

                        //Grid_About
                    }
                    else
                    {
                        Grid_About.Visibility = Visibility.Collapsed;
                    }

                    SqlHelper sql = new SqlHelper();
                    List <BangumiInfoModel> list  = JsonConvert.DeserializeObject <List <BangumiInfoModel> >(model.episodes.ToString());
                    List <BangumiInfoModel> list2 = new List <BangumiInfoModel>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        list[i].Num = i;
                        if (sql.ValuesExists(list[i].danmaku.ToString()))
                        {
                            list[i].color = new SolidColorBrush()
                            {
                                Color = Colors.Gray
                            };
                        }
                        else
                        {
                            list[i].color = new SolidColorBrush()
                            {
                                Color = Colors.White
                            };
                        }
                        if (DownloadManage.Downloaded.Contains(list[i].danmaku.ToString()))
                        {
                            list[i].inLocal = true;
                        }
                        list2.Add(list[i]);
                    }
                    list_E.ItemsSource = list2;
                    cb_H.ItemsSource   = list2;

                    List <BangumiInfoModel> list_CV = JsonConvert.DeserializeObject <List <BangumiInfoModel> >(model.actor.ToString());
                    txt_CV.Text = "";
                    foreach (BangumiInfoModel item in list_CV)
                    {
                        txt_CV.Text += string.Format("{0}:{1}\r\n", item.role, item.actor);
                    }
                    List <BangumiInfoModel> list_Tag = JsonConvert.DeserializeObject <List <BangumiInfoModel> >(model.tags.ToString());
                    Grid_tag.Children.Clear();
                    foreach (BangumiInfoModel item in list_Tag)
                    {
                        HyperlinkButton btn = new HyperlinkButton();
                        btn.DataContext = item;
                        btn.Margin      = new Thickness(0, 0, 10, 0);
                        btn.Content     = item.tag_name;
                        btn.Foreground  = App.Current.Resources["Bili-ForeColor"] as SolidColorBrush;
                        btn.Click      += Btn_Click;
                        Grid_tag.Children.Add(btn);
                    }
                    if (list_E.Items.Count != 0)
                    {
                        GetVideoComment_Hot(list2[0].av_id);
                        cb_H.SelectedIndex = 0;
                    }
                }
                if ((int)JObject.Parse(result)["code"] == -3)
                {
                    messShow.Show("密钥注册失败,请联系作者", 3000);
                }
                if ((int)JObject.Parse(result)["code"] == 10)
                {
                    messShow.Show(JObject.Parse(result)["message"].ToString(), 3000);
                }
            }
            catch (Exception ex)
            {
                if (ex.HResult == -2147012867)
                {
                    messShow.Show("检查你的网络连接!", 3000);
                }
                else
                {
                    messShow.Show("发生错误\r\n" + ex.Message, 3000);
                }
            }
            finally
            {
                pr_load.Visibility = Visibility.Collapsed;
            }
        }
        private async void GetRoomInfo(string room_id)
        {
            try
            {
                pr_Load.Visibility = Visibility.Visible;
                wc = new WebClientClass();
                string url = string.Format("http://live.bilibili.com/AppRoom/index?_device=wp&appkey={0}&build=411005&access_key={1}&platform=android&room_id={2}&ts={3}", ApiHelper._appKey, ApiHelper.access_key, room_id, ApiHelper.GetTimeSpen);
                url += "&sign=" + ApiHelper.GetSign(url);
                string results = await wc.GetResults(new Uri(url));

                LiveInfoModel model = JsonConvert.DeserializeObject <LiveInfoModel>(results);
                if (model.code == 0)
                {
                    LiveInfoModel info = JsonConvert.DeserializeObject <LiveInfoModel>(model.data.ToString());
                    Video_UP.DataContext = info;
                    LiveInfoModel        meta     = JsonConvert.DeserializeObject <LiveInfoModel>(info.meta.ToString());
                    List <LiveInfoModel> giftList = JsonConvert.DeserializeObject <List <LiveInfoModel> >(info.roomgifts.ToString());
                    foreach (var item in giftList)
                    {
                        LiveInfoModel coin_type = JsonConvert.DeserializeObject <LiveInfoModel>(item.coin_type.ToString());
                        item.silver = coin_type.silver;
                        item.gold   = coin_type.gold;
                    }
                    gridview_Gifts.ItemsSource = giftList;
                    string b = @"<head><style>p{font-family:""微软雅黑"";}</style></head>";
                    web_Desc.NavigateToString(b + meta.description);
                    GetSliver();
                    if (info.is_attention == 1)
                    {
                        txt_guanzhu.Text = "已关注";
                    }
                    else
                    {
                        txt_guanzhu.Text = "关注";
                    }
                    if (info.status == "LIVE")
                    {
                        GetLiveUrl();
                    }
                    else
                    {
                        grid_Error.Visibility = Visibility.Visible;
                        txt_ErrorInfo.Text    = info.prepare ?? "主播正在换女装";
                    }
                }
                else
                {
                    grid_Error.Visibility = Visibility.Visible;
                    txt_ErrorInfo.Text    = model.message;
                }
            }
            catch (Exception ex)
            {
                grid_Error.Visibility = Visibility.Visible;
                txt_ErrorInfo.Text    = "读取错误" + ex.Message;
            }
            finally
            {
                pr_Load.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #30
0
        public async void GetBangumiInfo(string banID)
        {
            //string uri = "http://bangumi.bilibili.com/api/season?_device=wp&_ulv=10000&build=411005&platform=android&appkey=422fd9d7289a1dd9&ts="+APIHelper.GetTimeSpen+ "000&type=sp&sp_id=56719";
            //string sign=  APIHelper.GetSign(uri);
            //uri += "&sign=" + sign;
            try
            {
                pr_load.Visibility = Visibility.Visible;
                wc = new WebClientClass();
                string uri = "";
                uri  = string.Format("http://bangumi.bilibili.com/api/season?_device=wp&access_key={2}&_ulv=10000&build=411005&platform=android&appkey=422fd9d7289a1dd9&ts={0}000&type=bangumi&season_id={1}", ApiHelper.GetTimeSpen, banID, ApiHelper.access_key);
                uri += "&sign=" + ApiHelper.GetSign(uri);
                string result = await wc.GetResults(new Uri(uri));

                BangumiInfoModel model = new BangumiInfoModel();
                if ((int)JObject.Parse(result)["code"] == 0)
                {
                    model = JsonConvert.DeserializeObject <BangumiInfoModel>(JObject.Parse(result)["result"].ToString());
                    grid_Info.DataContext = model;
                    BangumiInfoModel m = JsonConvert.DeserializeObject <BangumiInfoModel>(model.user_season.ToString());
                    if (m.attention == 0)
                    {
                        font_icon.Glyph   = "\uE006";
                        btn_concern.Label = "订阅";
                    }
                    else
                    {
                        font_icon.Glyph   = "\uE00B";
                        btn_concern.Label = "取消订阅";
                    }

                    List <BangumiInfoModel> list  = JsonConvert.DeserializeObject <List <BangumiInfoModel> >(model.episodes.ToString());
                    List <BangumiInfoModel> list2 = new List <BangumiInfoModel>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        list[i].Num = i;
                        list2.Add(list[i]);
                        if (DownloadManage.Downloaded.Contains(list[i].danmaku.ToString()))
                        {
                            list[i].inLocal = true;
                        }
                    }
                    list_E.ItemsSource = list2;
                    List <BangumiInfoModel> list_CV = JsonConvert.DeserializeObject <List <BangumiInfoModel> >(model.actor.ToString());
                    txt_CV.Text = "";
                    foreach (BangumiInfoModel item in list_CV)
                    {
                        txt_CV.Text += string.Format("{0}:{1}\r\n", item.role, item.actor);
                    }
                    List <BangumiInfoModel> list_Tag = JsonConvert.DeserializeObject <List <BangumiInfoModel> >(model.tags.ToString());
                    Grid_tag.Children.Clear();
                    foreach (BangumiInfoModel item in list_Tag)
                    {
                        HyperlinkButton btn = new HyperlinkButton();
                        btn.DataContext = item;
                        btn.Margin      = new Thickness(0, 0, 10, 0);
                        btn.Content     = item.tag_name;
                        btn.Click      += Btn_Click;
                        Grid_tag.Children.Add(btn);
                    }
                }
                if ((int)JObject.Parse(result)["code"] == -3)
                {
                    messShow.Show("密钥注册失败,请联系作者", 3000);
                }
                if ((int)JObject.Parse(result)["code"] == 10)
                {
                    messShow.Show(JObject.Parse(result)["message"].ToString(), 3000);
                }
            }
            catch (Exception ex)
            {
                messShow.Show("发生错误\r\n" + ex.Message, 3000);
            }
            finally
            {
                pr_load.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #31
0
        /// <summary>
        /// 读取视频播放地址
        /// </summary>
        /// <param name="model"></param>
        /// <param name="quality"></param>
        /// <returns></returns>
        public static async Task <ReturnPlayModel> GetVideoUrl(string aid, string cid, int qn)
        {
            try
            {
                if (qn < 10)
                {
                    switch (qn)
                    {
                    case 1:
                        qn = 32;
                        break;

                    case 2:
                        qn = 64;
                        break;

                    case 3:
                        qn = 80;
                        break;

                    case 4:
                        qn = 116;
                        break;

                    default:
                        qn = 64;
                        break;
                    }
                }
                List <string> urls = new List <string>();

                //https://interface.bilibili.com/v2/playurl?cid=31452468&appkey=84956560bc028eb7&otype=json&type=&quality=112&qn=112&sign=38b1355368ee65d055c12b57bdb26e3a

                string url = string.Format("https://interface.bilibili.com/v2/playurl?cid={1}&appkey={0}&otype=json&type=&quality={2}&qn={2}&ts={3}", ApiHelper._appKey_VIDEO, cid, qn, ApiHelper.GetTimeSpan_2);
                url += "&sign=" + ApiHelper.GetSign_VIDEO(url);


                string re = await WebClientClass.GetResults(new Uri(url));

                //var mc = Regex.Matches(re, @"<length>(.*?)</length>.*?<size>(.*?)</size>.*?<url><!\[CDATA\[(.*?)\]\]></url>", RegexOptions.Singleline);
                FlvPlyaerUrlModel m = JsonConvert.DeserializeObject <FlvPlyaerUrlModel>(re);
                // FlvPlyaerUrlModel m = JsonConvert.DeserializeObject<FlvPlyaerUrlModel>(re);
                var playList = new SYEngine.Playlist(SYEngine.PlaylistTypes.NetworkHttp);
                if (m.code == 0)
                {
                    foreach (var item in m.durl)
                    {
                        urls.Add(item.url);
                        playList.Append(item.url, item.size, item.length / 1000);
                    }
                }
                else
                {
                    var re3 = await WebClientClass.GetResults(new Uri(string.Format("https://moe.nsapps.cn/api/v1/BiliVideoUrl?cid={0}&qn={1}&rnd={2}", cid, qn, ApiHelper.GetTimeSpan)));

                    JObject obj = JObject.Parse(re3);
                    if (Convert.ToInt32(obj["code"].ToString()) == 0)
                    {
                        if (obj["mode"].ToString() == "mp4")
                        {
                            return(new ReturnPlayModel()
                            {
                                urls = new List <string>()
                                {
                                    obj["data"][0]["url"].ToString()
                                },
                                usePlayMode = UsePlayMode.System,
                                url = obj["data"][0]["url"].ToString(),
                                from = "server"
                            });
                        }
                        else
                        {
                            var returnPlayModel = new ReturnPlayModel()
                            {
                                usePlayMode = UsePlayMode.SYEngine,
                                from        = "server"
                            };
                            foreach (var item in obj["data"])
                            {
                                urls.Add(item["url"].ToString());
                                playList.Append(item["url"].ToString(), item["size"].ToInt32(), item["length"].ToInt32() / 1000);
                            }
                            returnPlayModel.playlist = playList;
                            returnPlayModel.urls     = urls;
                            return(returnPlayModel);
                        }
                    }
                }



                SYEngine.PlaylistNetworkConfigs config = new SYEngine.PlaylistNetworkConfigs();
                config.DownloadRetryOnFail = true;
                config.HttpCookie          = string.Empty;

                config.UniqueId      = string.Empty;
                config.HttpReferer   = "https://www.bilibili.com/video/av" + aid + "/";
                config.HttpUserAgent = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36";

                playList.NetworkConfigs = config;

                // mediaPlay.Source = await playList.SaveAndGetFileUriAsync();
                return(new ReturnPlayModel()
                {
                    usePlayMode = UsePlayMode.SYEngine,
                    playlist = playList,
                    urls = urls,
                    from = "bilibili"
                });
            }
            catch (Exception)
            {
                return(null);
            }
        }
        private async void LoadSongs()
        {
            try
            {
                loading                 = true;
                pr_load.Visibility      = Visibility.Visible;
                btn_LoadMore.Visibility = Visibility.Collapsed;
                int cate1id = _selectCategroies.parentId;
                int cate2id = _selectCategroies.cateId;

                if (_page == 1)
                {
                    list_songs.ItemsSource = null;
                }
                string url = string.Format("https://api.bilibili.com/audio/music-service-c/songs/getcatesongslist?access_key={0}&appkey={1}&build=5250000&cate1id={2}&cate2id={3}&mid={4}&mobi_app=android&pageIndex={5}&pageSize=20&platform=android&sortBy={6}&ts={7}",
                                           ApiHelper.access_key, ApiHelper.AndroidKey.Appkey, cate1id, cate2id, ApiHelper.GetUserId(), _page, _sort, ApiHelper.GetTimeSpan);

                url += "&sign=" + ApiHelper.GetSign(url);
                var results = await WebClientClass.GetResults(new Uri(url));

                MusicCateSongsModel obj = JsonConvert.DeserializeObject <MusicCateSongsModel>(results);

                if (obj.code == 0)
                {
                    if (obj.data.list != null && obj.data.list.Count != 0)
                    {
                        if (_page == 1)
                        {
                            list_songs.ItemsSource = obj.data.list;
                        }
                        else
                        {
                            var ls = list_songs.ItemsSource as ObservableCollection <MusicHomeSongModel>;
                            foreach (var item in obj.data.list)
                            {
                                ls.Add(item);
                            }
                        }
                        btn_LoadMore.Visibility = Visibility.Visible;
                        _page++;
                    }
                    else
                    {
                        Utils.ShowMessageToast("加载完了");
                    }
                }
                else
                {
                    Utils.ShowMessageToast(obj.msg);
                }
            }
            catch (Exception)
            {
                Utils.ShowMessageToast("加载歌曲失败");
            }
            finally
            {
                loading            = false;
                pr_load.Visibility = Visibility.Collapsed;
            }
        }
Beispiel #33
0
        /// <summary>
        /// 读取番剧播放地址
        /// </summary>
        /// <param name="model"></param>
        /// <param name="quality"></param>
        /// <returns></returns>
        public static async Task <ReturnPlayModel> GetBangumiUrl(PlayerModel model, int qn)
        {
            try
            {
                if (qn < 10)
                {
                    switch (qn)
                    {
                    case 1:
                        qn = 32;
                        break;

                    case 2:
                        qn = 64;
                        break;

                    case 3:
                        qn = 80;
                        break;

                    case 4:
                        qn = 116;
                        break;

                    default:
                        qn = 64;
                        break;
                    }
                }


                List <string> urls = new List <string>();
                string        url  = string.Format("https://interface.bilibili.com/v2/playurl?cid={0}&player=1&quality={1}&qn={1}&ts={2}", model.Mid, qn, ApiHelper.GetTimeSpan);
                url += "&sign=" + ApiHelper.GetSign_PlayUrl(url);

                string re = await WebClientClass.GetResults(new Uri(url));

                var playList = new SYEngine.Playlist(SYEngine.PlaylistTypes.NetworkHttp);

                SYEngine.PlaylistNetworkConfigs config = new SYEngine.PlaylistNetworkConfigs();
                config.DownloadRetryOnFail = true;
                config.HttpCookie          = string.Empty;
                config.UniqueId            = string.Empty;
                config.HttpUserAgent       = "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36";

                if (re.Contains("<code>"))
                {
                    //string url2 = string.Format("https://bangumi.bilibili.com/player/web_api/playurl/?access_key={3}&cid={0}&module=bangumi&player=1&otype=json&type=flv&quality={1}&ts={2}", model.Mid, quality, GetTimeSpan_2,access_key);
                    //url2 += "&sign=" + ApiHelper.GetSign_VIP(url2);
                    //
                    string url2 = string.Format(
                        "https://bangumi.bilibili.com/player/web_api/v2/playurl?cid={1}&appkey={0}&otype=json&type=&quality={2}&module=bangumi&season_type=1&qn={2}&ts={3}", ApiHelper._appKey_VIDEO, model.Mid, qn, ApiHelper.GetTimeSpan_2);
                    url2 += "&sign=" + ApiHelper.GetSign_VIDEO(url2);
                    re    = await WebClientClass.GetResultsUTF8Encode(new Uri(url2));

                    FlvPlyaerUrlModel m = JsonConvert.DeserializeObject <FlvPlyaerUrlModel>(re);
                    if (m.code == 0 && !re.Contains("8986943") && (m.status == 13 && m.vip_status != 0))
                    {
                        //if (m.durl.Count==1)
                        //{
                        //    return new ReturnPlayModel()
                        //    {
                        //        usePlayMode = UsePlayMode.System,
                        //        url = m.durl[0].url,
                        //        urls = urls
                        //    };
                        //}

                        foreach (var item in m.durl)
                        {
                            urls.Add(item.url);
                            playList.Append(item.url, item.size, item.length / 1000);
                        }
                    }
                    else
                    {
                        string rnd = ApiHelper.GetTimeSpan.ToString();
                        if (SettingHelper.Get_UseVIP())
                        {
                            rnd = "true" + rnd;
                        }
                        var re3 = await WebClientClass.GetResults(new Uri(string.Format("https://moe.nsapps.cn/api/v1/BiliAnimeUrl?animeid={0}&cid={1}&epid={2}&rnd={3}", model.banId, model.Mid, model.banInfo.episode_id, rnd)));

                        JObject obj = JObject.Parse(re3);
                        if (Convert.ToInt32(obj["code"].ToString()) == 0)
                        {
                            if (obj["mode"].ToString() == "mp4")
                            {
                                urls.Add(obj["data"][0]["url"].ToString());
                                return(new ReturnPlayModel()
                                {
                                    usePlayMode = UsePlayMode.System,
                                    url = obj["data"][0]["url"].ToString(),
                                    urls = urls,
                                    from = "server"
                                });
                            }
                            else
                            {
                                var returnPlayModel = new ReturnPlayModel()
                                {
                                    usePlayMode = UsePlayMode.SYEngine,
                                    from        = "server"
                                };
                                foreach (var item in obj["data"])
                                {
                                    playList.Append(item["url"].ToString(), item["size"].ToInt32(), item["length"].ToInt32() / 1000);
                                    urls.Add(item["url"].ToString());
                                }
                                returnPlayModel.playlist = playList;
                                returnPlayModel.urls     = urls;
                                return(returnPlayModel);
                            }
                        }

                        if (SettingHelper.Get_UseOtherSite())
                        {
                            var playurl = await _5DMHelper.GetUrl(model.banId, Convert.ToInt32(model.No));

                            if (playurl == "")
                            {
                                return(null);
                            }
                            else
                            {
                                urls.Add(playurl);
                                return(new ReturnPlayModel()
                                {
                                    usePlayMode = UsePlayMode.System,
                                    url = playurl,
                                    urls = urls,
                                    from = "other_site"
                                });
                            }
                        }
                        else
                        {
                            return(null);
                        }
                    }
                }
                else
                {
                    var mc = Regex.Matches(re, @"<length>(.*?)</length>.*?<size>(.*?)</size>.*?<url><!\[CDATA\[(.*?)\]\]></url>", RegexOptions.Singleline);

                    foreach (Match item in mc)
                    {
                        playList.Append(item.Groups[3].Value, Convert.ToInt32(item.Groups[2].Value), Convert.ToInt64(item.Groups[1].Value) / 1000);
                    }
                }
                config.HttpReferer = "https://www.bilibili.com/bangumi/play/ep" + model.episode_id;
                //config.HttpReferer = "";
                //config.HttpCookie = "sid=aj08qul1; pgv_pvi=2726422528; fts=1498031012; rpdid=ikxqxlpildoplqwkwlqw; buvid3=0916A88B-F02E-46E2-95B1-BEF35678E1EE37229infoc; LIVE_BUVID=9b2dbd17fe02c6e0b9a5f7cbfe182be2; LIVE_BUVID__ckMd5=54bf74d417f1dfe6; OUTFOX_SEARCH_USER_ID_NCOO=301070296.3442316; uTZ=-480; biliMzIsnew=1; biliMzTs=0; UM_distinctid=16072fe8c3138-01d5f1e1fd27a6-5d4e211f-1fa400-16072fe8c32d6; _ga=GA1.2.701916902.1513903771; im_notify_type_7251681=0; BANGUMI_SS_21728_REC=164986; finger=81df3ec0; 21680=183802; 22843=173309; BANGUMI_SS_22843_REC=173309; BANGUMI_SS_21680_REC=183802; balh_server=https://biliplus.ipcjs.win; purl_token=bilibili_1518001366; balh_season_21680=1; pgv_si=s8821510144; DedeUserID=7251681; DedeUserID__ckMd5=e2742b2aff29c1cf; SESSDATA=83ace795%2C1520595578%2Ca2c615ce; bili_jct=a0f037944a8423a37efb566011d0a84b; _dfcaptcha=42d9ae3eecffafaf47b08effeef54128";
                playList.NetworkConfigs = config;
                //FlvPlyaerUrlModel m = JsonConvert.DeserializeObject<FlvPlyaerUrlModel>(re);
                // var playList = new SYEngine.Playlist(SYEngine.PlaylistTypes.NetworkHttp);



                //foreach (var item in m.durl)
                //{
                //    playList.Append(item.url, item.size, item.length / 1000);
                //}


                // mediaPlay.Source = await playList.SaveAndGetFileUriAsync();
                return(new ReturnPlayModel()
                {
                    playlist = playList,
                    usePlayMode = UsePlayMode.SYEngine,
                    urls = urls,
                    from = "bilibili"
                });
            }
            catch (Exception)
            {
                return(null);
            }
        }
        public async void GetBangumiInfo(string banID)
        {
            //string uri = "http://bangumi.bilibili.com/api/season?_device=wp&_ulv=10000&build=411005&platform=android&appkey=422fd9d7289a1dd9&ts="+APIHelper.GetTimeSpen+ "000&type=sp&sp_id=56719";
            //string sign=  APIHelper.GetSign(uri);
            //uri += "&sign=" + sign;
            try
            {
                pr_load.Visibility = Visibility.Visible;
                wc = new WebClientClass();
                string uri = "";
                    uri = string.Format("http://bangumi.bilibili.com/api/season?_device=wp&access_key={2}&_ulv=10000&build=411005&platform=android&appkey=422fd9d7289a1dd9&ts={0}000&type=bangumi&season_id={1}", ApiHelper.GetTimeSpen, banID, ApiHelper.access_key);
                uri += "&sign=" + ApiHelper.GetSign(uri);
                string result = await wc.GetResults(new Uri(uri));
                BangumiInfoModel model = new BangumiInfoModel();
                if ((int)JObject.Parse(result)["code"] == 0)
                {
                    model = JsonConvert.DeserializeObject<BangumiInfoModel>(JObject.Parse(result)["result"].ToString());
                    grid_Info.DataContext = model;
                    BangumiInfoModel m = JsonConvert.DeserializeObject<BangumiInfoModel>(model.user_season.ToString());
                    if (m.attention == 0)
                    {
                        font_icon.Glyph = "\uE006";
                        btn_concern.Label = "订阅";
                    }
                    else
                    {
                        font_icon.Glyph = "\uE00B";
                        btn_concern.Label = "取消订阅";
                    }

                    List<BangumiInfoModel> list = JsonConvert.DeserializeObject<List<BangumiInfoModel>>(model.episodes.ToString());
                    List<BangumiInfoModel> list2 = new List<BangumiInfoModel>();
                    for (int i = 0; i < list.Count; i++)
                    {
                        list[i].Num = i;
                        list2.Add(list[i]);
                        if (DownloadManage.Downloaded.Contains(list[i].danmaku.ToString()))
                        {
                            list[i].inLocal = true;
                        }
                    }
                    list_E.ItemsSource = list2;
                    List<BangumiInfoModel> list_CV = JsonConvert.DeserializeObject<List<BangumiInfoModel>>(model.actor.ToString());
                    txt_CV.Text = "";
                    foreach (BangumiInfoModel item in list_CV)
                    {
                        txt_CV.Text += string.Format("{0}:{1}\r\n", item.role, item.actor);
                    }
                    List<BangumiInfoModel> list_Tag = JsonConvert.DeserializeObject<List<BangumiInfoModel>>(model.tags.ToString());
                    Grid_tag.Children.Clear();
                    foreach (BangumiInfoModel item in list_Tag)
                    {
                        HyperlinkButton btn = new HyperlinkButton();
                        btn.DataContext = item;
                        btn.Margin = new Thickness(0, 0, 10, 0);
                        btn.Content = item.tag_name;
                        btn.Click += Btn_Click;
                        Grid_tag.Children.Add(btn);
                    }
                }
                if ((int)JObject.Parse(result)["code"] == -3)
                {
                    messShow.Show("密钥注册失败,请联系作者",3000);
                }
                if ((int)JObject.Parse(result)["code"] == 10)
                {
                    messShow.Show(JObject.Parse(result)["message"].ToString(), 3000);
                }
            }
            catch (Exception ex)
            {
                messShow.Show("发生错误\r\n" + ex.Message, 3000);
            }
            finally
            {
                pr_load.Visibility = Visibility.Collapsed;

            }
        }
Beispiel #35
0
        /// <summary>
        /// 读取下载地址
        /// </summary>
        /// <param name="m"></param>
        /// <returns></returns>
        public static async Task <List <string> > GetVideoUrl_Download(DownloadTaskModel m)
        {
            try
            {
                List <string> urls = new List <string>();
                var           qn   = 32;
                switch (m.quality)
                {
                case 1:
                    qn = 32;
                    break;

                case 2:
                    qn = 64;
                    break;

                case 3:
                    qn = 80;
                    break;

                case 4:
                    qn = 112;
                    break;

                default:
                    break;
                }

                //https://interface.bilibili.com/v2/playurl?cid=31452468&appkey=84956560bc028eb7&otype=json&type=&quality=112&qn=112&sign=38b1355368ee65d055c12b57bdb26e3a

                if (m.downloadMode == DownloadMode.Video)
                {
                    string url = string.Format("https://interface.bilibili.com/v2/playurl?cid={1}&appkey={0}&otype=json&type=&quality={2}&qn={2}&ts={3}", ApiHelper._appKey_VIDEO, m.cid, qn, ApiHelper.GetTimeSpan_2);
                    url += "&sign=" + ApiHelper.GetSign_VIDEO(url);
                    string re = await WebClientClass.GetResults(new Uri(url));

                    FlvPlyaerUrlModel flvPlyaerUrlModel = JsonConvert.DeserializeObject <FlvPlyaerUrlModel>(re);
                    if (flvPlyaerUrlModel.code == 0)
                    {
                        foreach (var item in flvPlyaerUrlModel.durl)
                        {
                            urls.Add(item.url);
                        }
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    string url = string.Format("https://interface.bilibili.com/playurl?cid={0}&player=1&quality={1}&qn={1}&ts={2}", m.cid, qn, ApiHelper.GetTimeSpan);
                    url += "&sign=" + ApiHelper.GetSign_PlayUrl(url);
                    string re = await WebClientClass.GetResults(new Uri(url));

                    if (re.Contains("<code>"))
                    {
                        string url2 = string.Format(
                            "https://bangumi.bilibili.com/player/web_api/v2/playurl?cid={1}&appkey={0}&otype=json&type=&quality={2}&module=bangumi&season_type=1&qn={2}&ts={3}", ApiHelper._appKey_VIDEO, m.cid, qn, ApiHelper.GetTimeSpan_2);
                        url2 += "&sign=" + ApiHelper.GetSign_VIDEO(url2);
                        re    = await WebClientClass.GetResults(new Uri(url2));

                        FlvPlyaerUrlModel flvPlyaerUrlModel = JsonConvert.DeserializeObject <FlvPlyaerUrlModel>(re);
                        if (flvPlyaerUrlModel.code == 0 && !re.Contains("8986943"))
                        {
                            foreach (var item in flvPlyaerUrlModel.durl)
                            {
                                urls.Add(item.url);
                            }
                        }
                        else
                        {
                            var re3 = await WebClientClass.GetResults(new Uri(string.Format("https://moe.nsapps.cn/api/v1/BiliAnimeUrl?animeid={0}&cid={1}&epid={2}&rnd={3}", m.sid, m.cid, m.epid, ApiHelper.GetTimeSpan)));

                            JObject obj = JObject.Parse(re3);
                            if (Convert.ToInt32(obj["code"].ToString()) == 0)
                            {
                                urls.Add(obj["data"][0]["url"].ToString());
                            }
                            else
                            {
                                var playurl = await _5DMHelper.GetUrl(m.sid, Convert.ToInt32(m.epIndex) - 1);

                                if (playurl == "")
                                {
                                    return(null);
                                }
                                else
                                {
                                    urls.Add(playurl);
                                }
                            }
                        }
                    }
                    else
                    {
                        var mc = Regex.Matches(re, @"<length>(.*?)</length>.*?<size>(.*?)</size>.*?<url><!\[CDATA\[(.*?)\]\]></url>", RegexOptions.Singleline);
                        foreach (Match item in mc)
                        {
                            urls.Add(item.Groups[3].Value);
                        }
                    }
                }


                return(urls);
            }
            catch (Exception)
            {
                return(null);
            }
        }
Beispiel #36
0
        public static async Task <List <QualityModel> > GetAnimeQualities(PlayerModel model)
        {
            List <QualityModel> qualities = new List <QualityModel>();

            try
            {
                var           qn   = 64;
                List <string> urls = new List <string>();
                string        url  = string.Format("https://interface.bilibili.com/v2/playurl?cid={0}&player=1&quality={1}&qn={1}&ts={2}", model.Mid, qn, ApiHelper.GetTimeSpan);
                url += "&sign=" + ApiHelper.GetSign_PlayUrl(url);

                string re = await WebClientClass.GetResultsUTF8Encode(new Uri(url));

                if (re.Contains("<code>"))
                {
                    string url2 = string.Format(
                        "https://bangumi.bilibili.com/player/web_api/v2/playurl?cid={1}&appkey={0}&otype=json&type=&quality={2}&module=bangumi&season_type=1&qn={2}&ts={3}", ApiHelper._appKey_VIDEO, model.Mid, qn, ApiHelper.GetTimeSpan_2);
                    url2 += "&sign=" + ApiHelper.GetSign_VIDEO(url2);
                    re    = await WebClientClass.GetResultsUTF8Encode(new Uri(url2));

                    FlvPlyaerUrlModel m = JsonConvert.DeserializeObject <FlvPlyaerUrlModel>(re);
                    if (m.code == 0 && !re.Contains("8986943") && (m.status == 13 && m.vip_status != 0))
                    {
                        foreach (var item in m.accept_description)
                        {
                            qualities.Add(new QualityModel()
                            {
                                description = item,
                                qn          = m.accept_quality[m.accept_description.IndexOf(item)]
                            });
                        }
                    }
                    else
                    {
                        var re3 = await WebClientClass.GetResults(new Uri(string.Format("https://moe.nsapps.cn/api/v1/BiliAnimeUrl?animeid={0}&cid={1}&epid={2}&rnd={3}", model.banId, model.Mid, model.banInfo.episode_id, ApiHelper.GetTimeSpan)));

                        JObject obj = JObject.Parse(re3);
                        if (Convert.ToInt32(obj["code"].ToString()) == 0)
                        {
                            qualities.Add(new QualityModel()
                            {
                                description = "默认",
                                qn          = 80
                            });
                        }
                        else
                        {
                            var playurl = await _5DMHelper.GetUrl(model.banId, Convert.ToInt32(model.No) - 1);

                            if (playurl != "")
                            {
                                qualities.Add(new QualityModel()
                                {
                                    description = "默认",
                                    qn          = 80
                                });
                            }
                        }
                    }
                }
                else
                {
                    qualities = new List <QualityModel>()
                    {
                        new QualityModel()
                        {
                            description = "流畅", qn = 32
                        },
                        new QualityModel()
                        {
                            description = "清晰", qn = 64
                        },
                        new QualityModel()
                        {
                            description = "高清", qn = 80
                        },
                        new QualityModel()
                        {
                            description = "超清", qn = 112
                        },
                    };
                }
                qualities = qualities.OrderBy(x => x.qn).ToList();
                return(qualities);
            }
            catch (Exception)
            {
                return(new List <QualityModel>()
                {
                    new QualityModel()
                    {
                        description = "流畅", qn = 32
                    },
                    new QualityModel()
                    {
                        description = "清晰", qn = 64
                    },
                    new QualityModel()
                    {
                        description = "高清", qn = 80
                    },
                    new QualityModel()
                    {
                        description = "超清", qn = 112
                    },
                });
            }
        }
 private async void GetReply()
 {
     try
     {
         wc = new WebClientClass();
         string url = string.Format("http://message.bilibili.com/api/notify/query.replyme.list.do?_device=wp&&_ulv=10000&access_key={0}&actionKey=appkey&appkey={1}&build=410005&data_type=1&page_size=40&platform=android&ts={2}", ApiHelper.access_key, ApiHelper._appKey, ApiHelper.GetTimeSpen);
         url += "&sign=" + ApiHelper.GetSign(url);
         string results = await wc.GetResults(new Uri(url));
         MessageReplyModel model = JsonConvert.DeserializeObject<MessageReplyModel>(results);
         if (model.code == 0)
         {
             List<MessageReplyModel> list = JsonConvert.DeserializeObject<List<MessageReplyModel>>(model.data.ToString());
             foreach (var item in list)
             {
                 MessageReplyModel models = JsonConvert.DeserializeObject<MessageReplyModel>(item.publisher.ToString());
                 item.mid = models.mid;
                 item.name = models.name;
                 item.face = models.face;
             }
             list_Reply.ItemsSource = list;
         }
         else
         {
             messShow.Show("读取失败" + model.message, 3000);
         }
     }
     catch (Exception)
     {
         messShow.Show("读取失败", 3000);
     }
     
 }