Beispiel #1
0
        public static Video GetVideo(NicoNetwork network, string video_id, CancelObject cancel_object, MessageOut msgout)
        {
            Video video = null;

            for (int error_times = 0; ; ++error_times)
            {
                try
                {
                    video = new Video(network.GetThumbInfo(video_id));
                }
                catch (Exception)
                {
                    if (error_times >= checking_error_num_ - 1)
                    {
                        return(Video.GetOtherStateVideo());
                    }
                    else
                    {
                        if (msgout != null)
                        {
                            msgout.Write("ニコニコ動画へのアクセスエラーが起きました。3秒後に再試行します。\r\n");
                        }
                        cancel_object.Wait(3000);
                        continue;
                    }
                }
                break;
            }
            return(video);
        }
Beispiel #2
0
 public void Setup()
 {
     network_         = new NicoNetwork();
     msgout_          = new TestMessageOut();
     cancel_object_   = new CancelObject();
     network_manager_ = new NicoNetworkManager(network_, msgout_, cancel_object_);
     NicoTools.NicoNetworkManager.StringDelegate string_delegate = delegate(string str)
     {
         Console.WriteLine(str);
     };
     network_manager_.SetDelegateSetDonwloadInfo(string_delegate);
 }
Beispiel #3
0
        public ImportImageDrive(APPLICATION_DATA appData)
        {
            InitializeComponent();
            m_AppData = appData;
            m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
            m_Log = (ErrorLog)m_AppData.Logger;

            m_PathManager = (PATHS)m_AppData.PathManager;
            m_DVR = (DVR)m_AppData.DVR;

            m_CancelMove = new CancelObject();
            m_CancelMove.cancel = false;
        }
Beispiel #4
0
        public ImportImageDrive(APPLICATION_DATA appData)
        {
            InitializeComponent();
            m_AppData = appData;
            m_AppData.AddOnClosing(Stop, APPLICATION_DATA.CLOSE_ORDER.MIDDLE);
            m_Log = (ErrorLog)m_AppData.Logger;


            m_PathManager = (PATHS)m_AppData.PathManager;
            m_DVR         = (DVR)m_AppData.DVR;

            m_CancelMove        = new CancelObject();
            m_CancelMove.cancel = false;
        }
Beispiel #5
0
 public NicoCommentManager(NicoNetwork network, MessageOut msgout, CancelObject cancel_object)
 {
     niconico_network_ = network;
     msgout_           = msgout;
     cancel_object_    = cancel_object;
 }
Beispiel #6
0
 public NicoMylist(NicoNetwork network, MessageOut msgout, CancelObject cancel_object)
 {
     niconico_network_ = network;
     msgout_           = msgout;
     cancel_object_    = cancel_object;
 }
Beispiel #7
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());
            }
        }