public static async Task <FavViewModel> CreateAsync(BiliFav fav)
        {
            var model = new FavViewModel()
            {
                Title = fav.Title,
                Id    = fav.Id
            };

            var list = new ObservableCollection <FavVideoViewModel>();

            foreach (var video in fav.VideoList)
            {
                list.Add(await FavVideoViewModel.CreateAsync(video.Title, video.Bv, video.Picture));
            }

            list.Add(new FavVideoViewModel()
            {
                Bv       = "加载更多",
                Title    = "加载更多",
                CoverImg = new BitmapImage(new Uri("ms-appx:///Assets/LoadMore.png"))
            });

            model.VideoList = list;

            return(model);
        }
Esempio n. 2
0
        public static async Task <BiliFav> GetBiliFavAsync(int id, int pn, string sESSDATA)
        {
            List <(string, string)> cookies = null;

            if (!string.IsNullOrWhiteSpace(sESSDATA))
            {
                cookies = new List <(string, string)>();
                cookies.Add(("SESSDATA", sESSDATA));
            }

            var json = JsonConvert.DeserializeObject <FavJson>
                           (await NetHelper.HttpGet("https://api.bilibili.com/x/v3/fav/resource/list", cookies, $"media_id={id}", $"pn={pn}", "ps=20", "order=mtime"));

            if (json.data.medias == null)
            {
                return(null);
            }
            var fav = new BiliFav()
            {
                Id         = json.data.info.id,
                Title      = json.data.info.title,
                MediaCount = json.data.info.media_count,
                VideoList  = json.data.medias.Select(m => new BiliVideoMaster()
                {
                    Bv      = m.bvid,
                    Picture = m.cover,
                    Title   = m.title
                }).ToList()
            };

            return(fav);
        }