Exemplo n.º 1
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            ResponseResult result = Login();
            if(result == null)
            {
                return;
            }

            CookieCollection cl = result.CookieContainer.GetCookies(new Uri("http://www.nicovideo.jp/"));
            if (cl != null && cl.Count > 1)
            {
                Cookie cookie = cl[1];
                Cef.SetCookie("http://www.nicovideo.jp/", cookie.Name, cookie.Value, cookie.Domain, cookie.Path, cookie.Secure, cookie.HttpOnly, cookie.Expired, cookie.Expires);

                cefbrowser.Address = Constants.NicoNicoUrl;

                // 履歴情報を取得する。
                historyData = NicoVideoApiAccessor.GetHistory(result.CookieContainer);
                if (Constants.HistoryStatus.Fail.Equals(historyData.status))
                {
                    MessageBox.Show(Constants.GetHistoryFailedMessage, Constants.CaptionError, MessageBoxButton.OK, MessageBoxImage.Error);
                    return;
                }
                movieViewList = new List<MovieData>();

                historyCount = historyData.history.Count();
                currentHistoryidx = 0;

                HistoryData.History history = historyData.history[currentHistoryidx++];

                LoadMovieList(movieViewList, cc, history);

                // 動画一覧を表示する。
                movieList.ItemsSource = movieViewList;
            }
        }
Exemplo n.º 2
0
        private void LoadMovieList(List<MovieData> list, CookieContainer cc, HistoryData.History history)
        {
            if(list.Count() != 0 && list[list.Count() - 1].Title == "更に読み込む")
            {
                list.RemoveAt(list.Count() - 1);
            }

            related_video videos = NicoVideoApiAccessor.GetRelatedMovie(cc, history.video_id);

            for (int i = 0; i < videos.data_count; i++)
            {
                MovieData data = new MovieData();
                Video video = videos.video[i];
                data.Thumbnail = video.thumbnail;
                data.Title = video.title;
                data.View = "再生:" + video.view.ToString();
                data.Comment = "コメ:" + video.comment.ToString();
                data.Mylist = "マイ:" + video.mylist.ToString();

                TimeSpan ts = new TimeSpan(0, 0, video.length);
                data.Length ="再生時間:" + ts.ToString();
                data.Url = video.url;
                data.Type = "Movie";
                list.Add(data);
            }

            if(currentHistoryidx < historyData.history.Count())
            {
                MovieData button = new MovieData();
                button.Title = "更に読み込む";
                button.Type = null;

                list.Add(button);
            }

            movieList.Items.Refresh();
        }