Exemplo n.º 1
0
        /// <summary>
        /// 获取新动态
        /// </summary>
        /// <returns>动态响应</returns>
        public async Task <NewDynamicResponse> GetNewDynamicAsync(string lastSeemId = "0")
        {
            var param = new Dictionary <string, string>();

            param.Add("cold_start", "1");
            param.Add("qn", "32");
            param.Add("rsp_type", "2");
            param.Add("type_list", "268435455");
            param.Add("uid", BiliTool.mid);
            if (!string.IsNullOrEmpty(lastSeemId) && lastSeemId != "0")
            {
                param.Add("update_num_dy_id", lastSeemId);
            }
            string url  = BiliTool.UrlContact(Api.DYNAMIC_NEW, param, true, useiPhone: true);
            var    data = await BiliTool.ConvertEntityFromWebAsync <NewDynamicResponse>(url);

            if (data != null && data.cards != null)
            {
                data.cards.RemoveAll(p => p == null || p.card == null || p.card.Length < 10 || p.desc.status != 1);
                AppTool.WriteLocalSetting(Enums.Settings.LastSeemDynamicId, data.max_dynamic_id);
            }
            return(data);
        }
        /// <summary>
        /// 获取话题动态
        /// </summary>
        /// <param name="topicId">话题ID</param>
        /// <param name="topicName">话题名</param>
        /// <param name="offset">偏移值,初次不需要,每次请求会返回下一次请求的偏移值</param>
        /// <returns>Item1:下次偏移值;Item2:视频列表</returns>
        public async Task <Tuple <string, List <Topic> > > GetTopicAsync(int topicId, string topicName, string offset = "")
        {
            var param = new Dictionary <string, string>();

            param.Add("topic_id", topicId.ToString());
            param.Add("topic_name", Uri.EscapeDataString(topicName));
            //param.Add("video_meta", "qn:32,fnval:16,fnver:0,fourk:1");
            if (!string.IsNullOrEmpty(offset))
            {
                param.Add("offset", offset);
            }
            string url  = BiliTool.UrlContact(Api.TOPIC_COMPLEX, param, true);
            var    data = await BiliTool.GetTextFromWebAsync(url);

            if (!string.IsNullOrEmpty(data))
            {
                var    jobj       = JObject.Parse(data);
                string nextOffset = jobj["offset"].ToString();
                var    topics     = JsonConvert.DeserializeObject <List <Topic> >(jobj["cards"].ToString());
                topics.RemoveAll(p => p == null || p.card == null || p.card.Length < 10 || p.desc.status != 1);
                return(new Tuple <string, List <Topic> >(nextOffset, topics));
            }
            return(null);
        }
        /// <summary>
        /// 发送弹幕
        /// </summary>
        /// <param name="message">弹幕信息</param>
        /// <param name="aid">视频ID</param>
        /// <param name="cid">弹幕块ID</param>
        /// <param name="progress">进度</param>
        /// <param name="color">颜色(已处理)</param>
        /// <param name="fontSize">文本大小</param>
        /// <param name="mode">模式</param>
        /// <returns></returns>
        public async Task <bool> SendDanmakuAsync(string message, int aid, int cid, double progress, string color, string fontSize, string mode)
        {
            var param = new Dictionary <string, string>();

            param.Add("aid", aid.ToString());
            param.Add("msg", Uri.EscapeDataString(message));
            param.Add("oid", cid.ToString());
            param.Add("color", color);
            param.Add("fontSize", fontSize);
            param.Add("mode", mode);
            param.Add("pool", "0");
            param.Add("plat", "3");
            param.Add("type", "1");
            param.Add("progress", Math.Round(progress).ToString());
            var data     = BiliTool.UrlContact("", param, true);
            var response = await BiliTool.PostContentToWebAsync(Api.VIDEO_SEND_DANMAKU, data);

            if (!string.IsNullOrEmpty(response))
            {
                var jobj = JObject.Parse(response);
                return(jobj["code"].ToString() == "0");
            }
            return(false);
        }
Exemplo n.º 4
0
        public async Task Init(VideoDetail detail, int partId = 0)
        {
            Reset();
            App.AppViewModel.CurrentPlayerType  = Models.Enums.PlayerType.Video;
            App.AppViewModel.CurrentVideoPlayer = VideoPlayer;
            _detail        = detail;
            _currentPartId = partId;
            TabletMainPage.Current.SetBackgroundImage(_detail.pic);
            if (!string.IsNullOrEmpty(_detail.redirect_url))
            {
                var result = BiliTool.GetResultFromUri(_detail.redirect_url);
                videoId        = 0;
                _currentPartId = 0;
                if (result.Type == UriType.Bangumi)
                {
                    throw new InvalidDataException(result.Param);
                }
            }
            TitleBlock.Text = detail.title;
            ToolTipService.SetToolTip(TitleBlock, _detail.title);
            videoId                = _detail.aid;
            bvId                   = _detail.bvid;
            PlayCountBlock.Text    = AppTool.GetNumberAbbreviation(_detail.stat.view);
            DanmakuCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.stat.danmaku);
            RepostButton.Text      = AppTool.GetNumberAbbreviation(_detail.stat.share);
            CommentButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.reply);
            BVBlock.Text           = _detail.bvid;
            AVBlock.Text           = _detail.aid.ToString();

            DescriptionBlock.Text = _detail.desc;

            LikeButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.like);
            CoinButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.coin);
            FavoriteButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.favorite);

            PublishBlock.Text = AppTool.GetReadDateString(_detail.pubdate);

            UPAvatar.ProfilePicture = string.IsNullOrEmpty(_detail.owner.face) ? null : new BitmapImage(new Uri(_detail.owner.face + "@50w.jpg"))
            {
                DecodePixelWidth = 40
            };
            UPNameBlock.Text = _detail.owner.name;

            if (_detail.pages != null)
            {
                _detail.pages.ForEach(p => VideoPartCollection.Add(p));
                PartGridView.SelectedIndex = 0;
            }
            PartContainer.Visibility = _detail.pages.Count > 1 ? Visibility.Visible : Visibility.Collapsed;
            if (_detail.tag != null && _detail.tag.Count > 0)
            {
                TagGridView.Visibility = Visibility.Visible;
                _detail.tag.ForEach(p => TagCollection.Add(p));
            }
            else
            {
                TagGridView.Visibility = Visibility.Collapsed;
            }

            if (_detail.staff != null && _detail.staff.Count > 0)
            {
                _detail.staff.ForEach(p => StaffCollection.Add(p));
                SingleUserContainer.Visibility = Visibility.Collapsed;
                StaffContainer.Visibility      = Visibility.Visible;
            }
            else
            {
                StaffContainer.Visibility      = Visibility.Collapsed;
                SingleUserContainer.Visibility = Visibility.Visible;
            }

            if (_detail.req_user != null)
            {
                LikeButton.IsCheck     = _detail.req_user.like != 0;
                CoinButton.IsCheck     = _detail.req_user.coin != 0;
                FavoriteButton.IsCheck = _detail.req_user.favorite != 0;
            }

            await MyVideoPlayer.Init(_detail, _currentPartId);

            CheckLikeHoldState();
        }
Exemplo n.º 5
0
        private bool InitDetail()
        {
            if (!string.IsNullOrEmpty(_detail.redirect_url))
            {
                var result = BiliTool.GetResultFromUri(_detail.redirect_url);
                videoId        = 0;
                _currentPartId = 0;
                App.AppViewModel.CurrentPagePanel.RemoveMainHistory(Models.Enums.AppMenuItemType.VideoPlayer);
                if (result.Type == UriType.Bangumi)
                {
                    new TipPopup("正在转到专题...").ShowMessage();
                    App.AppViewModel.PlayBangumi(Convert.ToInt32(result.Param), null, true);
                }
                return(false);
            }
            if (_isPlayList)
            {
                VideoPlayer.IsAutoReturnWhenEnd = false;
            }
            else
            {
                VideoPlayer.IsAutoReturnWhenEnd = _detail.pages.Count <= 1;
            }
            TitleBlock.Text = _detail.title;
            ToolTipService.SetToolTip(TitleBlock, _detail.title);
            videoId                = _detail.aid;
            bvId                   = _detail.bvid;
            PlayCountBlock.Text    = AppTool.GetNumberAbbreviation(_detail.stat.view);
            DanmukuCountBlock.Text = AppTool.GetNumberAbbreviation(_detail.stat.danmaku);
            RepostButton.Text      = AppTool.GetNumberAbbreviation(_detail.stat.share);
            CommentButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.reply);
            BVBlock.Text           = _detail.bvid;
            AVBlock.Text           = _detail.aid.ToString();

            DescriptionBlock.Text = _detail.desc;

            LikeButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.like);
            CoinButton.Text     = AppTool.GetNumberAbbreviation(_detail.stat.coin);
            FavoriteButton.Text = AppTool.GetNumberAbbreviation(_detail.stat.favorite);

            DateBlock.Text = AppTool.GetReadDateString(_detail.pubdate);

            UPAvatar.ProfilePicture = string.IsNullOrEmpty(_detail.owner.face) ? null : new BitmapImage(new Uri(_detail.owner.face + "@50w.jpg"))
            {
                DecodePixelWidth = 40
            };
            UPNameBlock.Text = _detail.owner.name;

            _detail.pages.ForEach(p => VideoPartCollection.Add(p));
            PartListView.SelectedIndex = PartGridView.SelectedIndex = 0;
            PartContainer.Visibility   = _detail.pages.Count > 1 ? Visibility.Visible : Visibility.Collapsed;

            if (_detail.tag != null && _detail.tag.Count > 0)
            {
                TagListView.Visibility = Visibility.Visible;
                _detail.tag.ForEach(p => TagCollection.Add(p));
            }
            else
            {
                TagListView.Visibility = Visibility.Collapsed;
            }

            if (_detail.staff != null && _detail.staff.Count > 0)
            {
                _detail.staff.ForEach(p => StaffCollection.Add(p));
                SingleUserContainer.Visibility = Visibility.Collapsed;
                StaffContainer.Visibility      = Visibility.Visible;
            }
            else
            {
                StaffContainer.Visibility      = Visibility.Collapsed;
                SingleUserContainer.Visibility = Visibility.Visible;
            }

            if (_detail.req_user != null)
            {
                LikeButton.IsCheck     = _detail.req_user.like != 0;
                CoinButton.IsCheck     = _detail.req_user.coin != 0;
                FavoriteButton.IsCheck = _detail.req_user.favorite != 0;
                FollowButton.Style     = _detail.req_user.attention == 1 ? UIHelper.GetStyle("DefaultAsyncButtonStyle") : UIHelper.GetStyle("PrimaryAsyncButtonStyle");
                FollowButton.Text      = _detail.req_user.attention == 1 ? "已关注" : "关注";
            }

            if (_detail.relates != null && _detail.relates.Count > 0)
            {
                _detail.relates.Where(p => p.@goto == "av").Take(10).ToList().ForEach(p => RelatedCollection.Add(p));
            }
            CheckLikeHoldState();
            return(true);
        }