Beispiel #1
0
        public void ParsePointRssTest1()
        {
            string mylist_id = TestUtility.TestData[TestUtility.KEY_MYLIST_ID];
            string video_id = TestUtility.TestData[TestUtility.KEY_VIDEO_ID];
            string video_title = TestUtility.TestData[TestUtility.KEY_VIDEO_TITLE];
            string video_description = TestUtility.TestData[TestUtility.KEY_VIDEO_DESCRIPTION];
            DateTime video_submit_date = DateTime.Parse(TestUtility.TestData[TestUtility.KEY_VIDEO_SUBMIT_DATE]);
            string video_length = TestUtility.TestData[TestUtility.KEY_VIDEO_LENGTH];

            TestUtility.EnsureLogin(network_);

            string rss = network_.GetMylistHtml(mylist_id, true);
            List<Video> video_list = new List<Video>();
            NicoListManager.ParsePointRss(rss, DateTime.Now, video_list, false, true);
            Assert.That(video_list.Count, Is.GreaterThanOrEqualTo(1), "ParsePointRssTest1-1");
            Video video = video_list[0];
            Assert.That(video.title, Is.EqualTo(video_title), "ParsePointRssTest1-x");
            Assert.That(video.video_id, Is.EqualTo(video_id), "ParsePointRssTest1-2");
            Assert.That(video.description, Is.EqualTo(video_description), "ParsePointRssTest1-4");
            Assert.That(video.submit_date, Is.EqualTo(video_submit_date), "ParsePointRssTest1-5");
            Assert.That(video.length, Is.EqualTo(video_length), "ParsePointRssTest1-6");
        }
Beispiel #2
0
        public void GetMylistHtmlTest()
        {
            string mylist_id = TestUtility.TestData[TestUtility.KEY_MYLIST_ID];
            string id        = TestUtility.TestData[TestUtility.KEY_VIDEO_ID];

            TestUtility.EnsureLogin(network_);

            string str = network_.GetMylistHtml(mylist_id, true);

            Assert.That(str, Text.Contains(id), "GetMylistHtmlTest1");

            str = network_.GetMylistHtml(mylist_id, false);
            Assert.That(str, Text.Contains(id), "GetMylistHtmlTest2");
        }
Beispiel #3
0
        public void AddMylist(InputOutputOption iooption, string mylist_id)
        {
            const int try_times       = 5;
            const int large_wait_time = 50000;
            const int large_wait_num  = 70;
            RankFile  rank_file       = iooption.GetRankFile();

            if (rank_file.Count == 0)
            {
                msgout_.Write("追加する動画がありません。\r\n");
                return;
            }

            msgout_.Write("マイリスト " + mylist_id + " への追加を開始します。\r\n");
            // 最小3秒、最大10秒
            int wait_time       = Math.Min(Math.Max(rank_file.Count * 1000 * 8 / 10, 3000), 10000);
            int total_wait_time = (wait_time * rank_file.Count + large_wait_time * (rank_file.Count / large_wait_num)) / 1000 / 60 + 1;

            msgout_.Write(rank_file.Count + "件の追加には推定" + total_wait_time.ToString() + "分かかります。\r\n");

            List <Video> exist_video_list = new List <Video>();

            NicoListManager.ParsePointRss(niconico_network_.GetMylistHtml(mylist_id, true), DateTime.Now, exist_video_list, false, true);
            cancel_object_.Wait(1000);

            for (int i = 0; i < rank_file.Count; ++i)
            {
                if (RankFile.SearchVideo(exist_video_list, rank_file[i]) >= 0)
                {
                    msgout_.Write(rank_file[i] + " はすでに存在します。\r\n");
                    continue;
                }
                for (int j = 0; j < try_times; ++j)
                {
                    try
                    {
                        niconico_network_.AddMylist(mylist_id, rank_file[i]);
                        msgout_.Write(rank_file[i] + " をマイリストに追加しました。\r\n");
                    }
                    catch (NiconicoAddingMylistExistException) // 上でチェックしているが念のためもう一度チェック
                    {
                        msgout_.Write(rank_file[i] + " はすでに存在します。\r\n");
                    }
                    catch (Exception e)
                    {
                        if (j < try_times - 1)
                        {
                            msgout_.Write("エラー:" + e.Message + "\r\n3秒後に再試行します。\r\n");
                            cancel_object_.Wait(3000);
                            continue;
                        }
                        else
                        {
                            msgout_.Write("エラー:" + e.Message + "\r\n");
                            cancel_object_.Wait(3000);
                        }
                    }
                    if (i < rank_file.Count - 1)
                    {
                        msgout_.Write("待機しています。\r\n");
                        // 基本的には wait_time ミリ秒だけ待つが、large_wait_num 回に1回は
                        // large_wait_time ミリ秒待つ。
                        if ((i + 1) % large_wait_num == 0)
                        {
                            cancel_object_.Wait(large_wait_time, large_wait_time + 1000);
                        }
                        else
                        {
                            cancel_object_.Wait(wait_time, wait_time + 1000);
                        }
                    }
                    break;
                }
            }
            msgout_.Write("マイリストへの追加を終了します。\r\n");
        }