Example #1
0
        public void GetDetailInfoTest1()
        {
            string temp_directory_path = TestUtility.TestData[TestUtility.KEY_TEMP_DIRECTORY];
            string video_id            = TestUtility.TestData[TestUtility.KEY_VIDEO_ID];
            string video_title         = TestUtility.TestData[TestUtility.KEY_VIDEO_TITLE];

            TestUtility.EnsureLogin(network_);

            DirectoryInfo temp_directory = new DirectoryInfo(temp_directory_path);

            Assert.That(TestUtility.InitDirectory(temp_directory), Is.True, "GetDetailInfoTest1-1");

            string rank_file_path = Path.Combine(temp_directory_path, "rank.txt");
            string rank_file_text = string.Format("{0}\r\n{1}\r\n", "sm9", video_id);

            IJFile.WriteVer2(rank_file_path, rank_file_text, IJFile.EncodingPriority.UTF8);

            RankFileCustomFormat custom_format = new RankFileCustomFormat();
            InputOutputOption    iooption      = new InputOutputOption(rank_file_path, rank_file_path, custom_format);

            RankingMethod ranking_method = new RankingMethod(HoseiKind.Nothing, SortKind.Nothing, 0);

            List <string> id_list = new List <string>(new string[] {
                video_id,
                "sm1097445"
            });

            network_manager_.GetDetailInfo(id_list, iooption, true, ranking_method, "1");

            RankFile     rank_file  = new RankFile(rank_file_path, custom_format);
            List <Video> video_list = rank_file.GetVideoList();

            Assert.That(video_list.Count, Is.EqualTo(3), "GetDetailInfoTest1-2");
            Assert.That(video_list[1].title, Is.EqualTo(video_title), "GetDetailInfoTest1-3");
        }
Example #2
0
        public InputOutputOption GetInputOutputOption()
        {
            InputOutputOption iooption = new InputOutputOption(radioButtonInputFromRankFile.Checked,
                                                               (checkBoxIsSameToInput.Checked ? true : radioButtonOutputToRankFile.Checked),
                                                               GetRankFileCustomFormat());

            if (radioButtonInputFromRankFile.Checked)
            {
                iooption.SetInputPath(nicorank_mgr_.GetPathMgr().GetFullPath(textBoxInputRankFilePath.Text));
            }
            else
            {
                iooption.SetInputText(textBoxInputRank.Text);
            }
            if (checkBoxIsSameToInput.Checked)
            {
                // 入力ファイルと出力ファイルを同じにする
                iooption.SetOutputPath(nicorank_mgr_.GetPathMgr().GetFullPath(textBoxInputRankFilePath.Text));
            }
            else if (radioButtonOutputToRankFile.Checked)
            {
                iooption.SetOutputPath(nicorank_mgr_.GetPathMgr().GetFullPath(textBoxOutputRankFilePath.Text));
            }
            else
            {
                iooption.SetOutputRankFileDelegate(SetTextBoxOutputRank);
            }
            return(iooption);
        }
Example #3
0
        static void Main(string[] args)
        {
            try
            {
                if (args.Length <= 1)
                {
                    ShowUsage();
                    System.Environment.Exit(1);
                }

                Receiver           receiver      = new Receiver();
                CancelObject       cancel_object = new CancelObject();
                NicoNetwork        network       = new NicoNetwork();
                NicoNetworkManager network_mgr   = new NicoNetworkManager(network, receiver, cancel_object);
                NicoMylist         nico_mylist   = new NicoMylist(network, receiver, cancel_object);

                for (int i = 2; i < args.Length; ++i)
                {
                    switch (args[i])
                    {
                    case "-i":
                        if (i < args.Length - 1)
                        {
                            input_rank_file_ = Dequote(args[i + 1]);
                            if (!File.Exists(input_rank_file_))
                            {
                                System.Console.WriteLine("入力ランクファイルが存在しません。");
                                System.Environment.Exit(1);
                            }
                            ++i;
                        }
                        else
                        {
                            System.Console.WriteLine("入力ランクファイルを指定してください。");
                            System.Environment.Exit(1);
                        }
                        break;

                    case "-o":
                        if (i < args.Length - 1)
                        {
                            output_rank_file_ = Dequote(args[i + 1]);
                            ++i;
                        }
                        break;

                    case "-c":
                        if (i < args.Length - 1)
                        {
                            config_file_ = Dequote(args[i + 1]);
                            ++i;
                        }
                        break;
                    }
                }

                if (string.IsNullOrEmpty(config_file_)) // config ファイル指定なしの場合
                {
                    config_file_ = Path.Combine(Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location), "config.txt");
                    if (!File.Exists(config_file_))
                    {
                        System.Console.WriteLine("最初に nicorank.exe を起動してオプションを指定してください。");
                        System.Environment.Exit(1);
                    }
                }
                else
                {
                    if (!File.Exists(config_file_))
                    {
                        System.Console.WriteLine("config ファイルが見つかりません。");
                        System.Environment.Exit(1);
                    }
                }
                ParseConfig(IJFile.Read(config_file_));

                InputOutputOption iooption = new InputOutputOption(!string.IsNullOrEmpty(input_rank_file_), !string.IsNullOrEmpty(output_rank_file_));
                if (string.IsNullOrEmpty(input_rank_file_)) // 標準入力から
                {
                    iooption.SetInputFromStdin();
                }
                else
                {
                    iooption.SetInputPath(input_rank_file_);
                }
                if (string.IsNullOrEmpty(output_rank_file_)) // 標準出力へ
                {
                    iooption.SetOutputRankFileDelegate(delegate(string s)
                    {
                        System.Console.Write(s);
                    });
                }
                else
                {
                    iooption.SetOutputPath(output_rank_file_);
                }

                switch (args[0])
                {
                case "download":
                    switch (args[1])
                    {
                    case "ranking":
                        CategoryManager category_manager = new CategoryManager();
                        category_manager.SetString(option_["dlrank_category"]);
                        category_manager.ParseCategoryFile();
                        network_mgr.DownloadRanking(GetDownloadKind(category_manager), option_["textBoxRankDlDir"]);
                        break;

                    case "video":
                        LoadCookie(network);
                        network_mgr.DownloadFlv(iooption, option_["textBoxDlInterval"], MakeDirectoryPath(option_["textBoxFlvDlDir"]),
                                                bool.Parse(option_["checkBoxIsFixFlvDlExtension"]));
                        break;

                    default:
                        ShowInvalidAndUsage(args[1]);
                        System.Environment.Exit(1);
                        break;
                    }
                    break;

                case "list":
                    switch (args[1])
                    {
                    case "searchtag":
                        network_mgr.MakeListAndWriteBySearchTag(iooption, MakeSearchingTagOption(), MakeRankingMethod());
                        break;

                    default:
                        ShowInvalidAndUsage(args[1]);
                        System.Environment.Exit(1);
                        break;
                    }
                    break;

                case "mylist":
                    switch (args[1])
                    {
                    case "add":
                        LoadCookie(network);
                        nico_mylist.AddMylist(iooption, option_["textBoxMylistId"]);
                        break;

                    default:
                        ShowInvalidAndUsage(args[1]);
                        System.Environment.Exit(1);
                        break;
                    }
                    break;

                default:
                    ShowInvalidAndUsage(args[0]);
                    System.Environment.Exit(1);
                    break;
                }
            }
            catch (KeyNotFoundException e)
            {
                System.Console.WriteLine("エラーが発生しました。");
                System.Console.WriteLine("キーが存在しません: " + e.Data.ToString());
            }
            catch (Exception e)
            {
                System.Console.WriteLine("エラーが発生しました。");
                System.Console.WriteLine("エラー\r\n---メッセージ\r\n" +
                                         e.Message + "\r\n---ソース\r\n" + e.Source + "\r\n---スタックトレース\r\n" +
                                         e.StackTrace + "\r\n---ターゲット\r\n" + e.TargetSite + "\r\n---文字列\r\n" +
                                         e.ToString());
            }
        }
Example #4
0
 public void SetPath(InputOutputOption iooption, string trans_after_dir)
 {
     trans_after_dir_ = trans_after_dir;
     iooption_        = iooption;
 }