コード例 #1
0
ファイル: UserRelated.cs プロジェクト: zhoushuqiang/bilibili
        /// <summary>
        /// 获取订阅番剧
        /// </summary>
        public static async Task <Site_Concern> GetConcernBangumiAsync(string mid, int page, bool isself, int pagesize = 20)
        {
            Site_Concern site = new Site_Concern();

            if (isself == false)
            {
                string url = "http://space.bilibili.com/ajax/Bangumi/getList?mid=" + mid + "&pagesize=" + pagesize.ToString() + "&page=" + page.ToString();
                url += ApiHelper.GetSign(url);
                string result = await BaseService.SentGetAsync(url);

                JsonObject json   = JsonObject.Parse(result);
                bool       status = json["status"].GetBoolean();
                if (status == false)
                {
                    if (json.ContainsKey("data"))
                    {
                        if (json["data"].GetString() == "用户隐私设置未公开")
                        {
                            List <ConcernItem> list = new List <ConcernItem>();
                            list.Add(new ConcernItem {
                                Title = "PRIVATE"
                            });
                            site.Result = list;
                            return(site);
                        }
                    }
                    return(null);
                }
                else
                {
                    if (json.ContainsKey("data"))
                    {
                        json = json["data"].GetObject();
                        if (json.ContainsKey("result"))
                        {
                            site.Result = JsonConvert.DeserializeObject <List <ConcernItem> >(json["result"].ToString());
                        }
                    }
                    return(null);
                }
            }
            else
            {
                string url = "http://bangumi.bilibili.com/api/get_concerned_season?_device=wp&_ulv=10000&build=430000&platform=android&scale=xhdpi&appkey=" + ApiHelper.appkey + "&access_key=" + ApiHelper.accesskey + "&page=" + page.ToString() + "&pagesize=" + pagesize.ToString() + "&ts=" + ApiHelper.GetLinuxTS().ToString();
                url += ApiHelper.GetSign(url);
                Site_Concern concern = JsonConvert.DeserializeObject <Site_Concern>(await BaseService.SentGetAsync(url));
                if (concern.Code == "0")
                {
                    site = concern;
                    return(site);
                }
                return(null);
            }
        }
コード例 #2
0
ファイル: Friends.xaml.cs プロジェクト: zhoushuqiang/bilibili
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            mid  = e.Parameter.ToString();
            user = await UserRelated.GetBasicInfoAsync(mid);

            sets = await UserRelated.GetUserSettingAsync(mid);

            Models.UserInfo info = user.Data;
            if (user.Status == true)
            {
                Face.ImageSource = new BitmapImage {
                    UriSource = new Uri(info.Face)
                };
                level.Source = new BitmapImage {
                    UriSource = new Uri("ms-appx:///Assets//Others//lv" + info.Level_Info.Current_level + ".png", UriKind.Absolute)
                };
                exp_current.Text = info.Level_Info.Current_exp;
                toutu.Source     = new BitmapImage(new Uri("http://i0.hdslb.com/" + info.Toutu));
                if (!string.IsNullOrWhiteSpace(info.BirthDay))
                {
                    birth.Text = "生日:" + info.BirthDay;
                }
                if (!string.IsNullOrWhiteSpace(info.RegTime))
                {
                    regdate.Text += "注册日期:" + StringDeal.LinuxToData(info.RegTime);
                }
                if (!string.IsNullOrWhiteSpace(info.Sex))
                {
                    sex.Text += "性别:" + info.Sex;
                }
                if (!string.IsNullOrWhiteSpace(info.Place))
                {
                    addr.Text = "地址:" + info.Place;
                }
                if (info.Level_Info.Current_level == "6")
                {
                    bar.Value = 100;
                }
                else
                {
                    bar.Value      = int.Parse(info.Level_Info.Current_exp);
                    bar.Maximum    = int.Parse(info.Level_Info.Next_exp);
                    exp_total.Text = info.Level_Info.Next_exp;
                }
                userName.Text = info.Name;
                sign.Text     = info.Sign;
            }
            if (sets.Status != true)
            {
                toutu.SizeChanged -= toutu_SizeChanged;
            }
            Site_Concern concern = await UserRelated.GetConcernBangumiAsync(mid, 1, false);

            if (concern != null)
            {
                var concerns = concern.Result;
                if (concerns != null)
                {
                    if (concerns[0].Title == "PRIVATE")
                    {
                        txt_private.Visibility = Visibility.Visible;
                        conlist.Visibility     = Visibility.Collapsed;
                    }
                    else
                    {
                        conlist.ItemsSource = concerns;
                    }
                }
            }
        }
コード例 #3
0
        async Task load()
        {
            try
            {
                if (!isLoaded)
                {
                    if (SettingHelper.GetValue("_accesskey").ToString().Length > 2)
                    {
                        string url = "http://account.bilibili.com/api/myinfo?access_key=" + ApiHelper.accesskey + "&appkey=" + ApiHelper.appkey + "&platform=wp&type=json";
                        url += ApiHelper.GetSign(url);
                        JsonObject json = await BaseService.GetJson(url);

                        if (json.ContainsKey("face"))
                        {
                            Face.Source = new BitmapImage {
                                UriSource = new Uri(StringDeal.delQuotationmarks((json["face"].ToString())))
                            }
                        }
                        ;
                        if (json.ContainsKey("coins"))
                        {
                            coins.Text = "硬币:" + json["coins"].ToString();
                        }
                        if (json.ContainsKey("sign"))
                        {
                            sign.Text = StringDeal.delQuotationmarks(json["sign"].ToString());
                        }
                        if (json.ContainsKey("uname"))
                        {
                            userName.Text = StringDeal.delQuotationmarks(json["uname"].ToString());
                        }
                        if (json.ContainsKey("level_info"))
                        {
                            JsonObject json2 = JsonObject.Parse(json["level_info"].ToString());
                            if (json2.ContainsKey("next_exp"))
                            {
                                exp_total.Text = json2["next_exp"].ToString();
                                bar.Maximum    = Convert.ToInt32(json2["next_exp"].ToString());
                            }
                            if (json2.ContainsKey("current_exp"))
                            {
                                exp_current.Text = json2["current_exp"].ToString();
                                bar.Value        = Convert.ToInt32(json2["current_exp"].ToString());
                            }
                            if (json2.ContainsKey("current_level"))
                            {
                                level.Source = new BitmapImage {
                                    UriSource = new Uri("ms-appx:///Assets//Others//lv" + json2["current_level"].ToString() + ".png", UriKind.Absolute)
                                };
                            }
                            string     url2       = "http://space.bilibili.com/ajax/settings/getSettings?mid=" + UserHelper.Mid;
                            JsonObject json_toutu = await BaseService.GetJson(url2);

                            if (json_toutu.ContainsKey("data"))
                            {
                                json_toutu = json_toutu["data"].GetObject();
                                if (json_toutu.ContainsKey("toutu"))
                                {
                                    json_toutu = json_toutu["toutu"].GetObject();
                                    if (json_toutu.ContainsKey("l_img"))
                                    {
                                        tl = "http://i0.hdslb.com/" + json_toutu["l_img"].GetString();
                                    }
                                    if (json_toutu.ContainsKey("s_img"))
                                    {
                                        ts = "http://i0.hdslb.com/" + json_toutu["s_img"].GetString();
                                    }
                                }
                            }
                            UpDateHeader();
                            int pagesize = 20;
                            if (SettingHelper.DeviceType == DeviceType.Mobile)
                            {
                                pagesize    = 3;
                                width.Width = ActualWidth / 3 - 8;
                            }
                            myFolder = await ContentServ.GetFavFolders();

                            folderlist.ItemsSource = myFolder;
                            Site_Concern concern = await UserRelated.GetConcernBangumiAsync("", 1, true, pagesize);

                            if (concern != null)
                            {
                                concern_count.Text  = concern.Count;
                                conlist.ItemsSource = concern.Result;
                            }
                            isLoaded = true;
                        }
                    }
                }
            }
            catch (Exception)
            {
            }
        }