Example #1
0
        private async void Initialize(string mylistid, string orderby)
        {
            MylistId = mylistid;
            OrderBy  = "0";

            var xml = await WebUtil.GetXmlChannelAsync(MylistUrl);

            // マイリスト情報を本インスタンスのプロパティに転記
            MylistTitle       = xml.Element("title").Value;
            MylistCreator     = xml.Element(XName.Get("creator", "http://purl.org/dc/elements/1.1/")).Value;
            MylistDate        = DateTime.Parse(xml.Element("lastBuildDate").Value);
            MylistDescription = xml.Element("description").Value;

            const string thumbnailurl = "https://secure-dcdn.cdn.nimg.jp/nicoaccount/usericon/";
            var          mylistpage   = await WebUtil.GetStringAsync($"http://www.nicovideo.jp/mylist/{MylistId}");

            // サムネイルURLを取得
            var iframestr = thumbnailurl + Regex.Match(mylistpage, thumbnailurl + "(?<url>[^\"]+)").Groups["url"].Value;

            // ユーザIDを取得
            var userid = Regex.Match(iframestr, @"\/(?<user_id>[\d]+)\.").Groups["user_id"].Value;

            UserId = userid;

            // サムネイル取得
            await NicoUtil
            .GetThumbnailAsync(iframestr)
            .ContinueWith(x => Thumbnail = x.Result);
        }
        private async void Intialize(NicoVideoModel x)
        {
            SetModel(x);

            var urls = new string[]
            {
                $"{x.ThumbnailUrl}.L",
                $"{x.ThumbnailUrl}.M",
                $"{x.ThumbnailUrl}",
            };

            await NicoUtil
            .GetThumbnailAsync(urls)
            .ContinueWith(image => Thumbnail = image.Result);
        }
        private async void Initialize(NicoVideoModel video, bool reload)
        {
            SetModel(video, false);

            if (reload)
            {
                await NicoUtil
                .GetVideo(VideoId)
                .ContinueWith(x => SetModel(x.Result, true));
            }

            var urls = new string[]
            {
                $"{video.ThumbnailUrl}.L",
                $"{video.ThumbnailUrl}.M",
                $"{video.ThumbnailUrl}",
            };

            await NicoUtil
            .GetThumbnailAsync(urls)
            .ContinueWith(x => Thumbnail = x.Result);
        }