コード例 #1
0
    static void Main(string[] args)
    {
        if (args.Length >= 2)
        {
            if (!Directory.Exists(args[1]) && !File.Exists(args[1]))
            {
                Console.WriteLine("not exsits:" + args[1]);
                return;
            }
            switch (args[0].ToLower())
            {
            case "epub":
            {
                var gen = new AeroNovelEpub.GenEpub();
                if (args.Length >= 3)
                {
                    if (args[2] == "t2s")
                    {
                        gen = new AeroNovelEpub.GenEpub(AeroNovelEpub.ChineseConvertOption.T2S);
                    }
                }

                Epub e = gen.Gen(args[1]);
                e.filename = "[" + e.creator + "] " + e.title;
                e.Save("");
            }
            break;

            case "txt":
                GenTxt.Gen(args[1]);
                break;

            case "bbcode":
                GenBbcode.Gen(args[1]);
                break;

            case "restore":
                Publish.Restore(args[1]);
                break;

            case "epub2comment":
                Epub2Comment.Proc(args[1]);
                break;

            case "epub2atxt":
                Epub2Atxt.Proc(args[1]);
                break;

            default:
                Log.log("[Warn]Nothing happens. Usage:epub/txt/bbcode/restore/epub2comment");
                break;
            }
        }
        else
        {
            Log.log("[Warn]Usage:epub/txt/bbcode/restore/epub2comment");
        }
    }
コード例 #2
0
    static void Main(string[] args)
    {
        Console.ForegroundColor = ConsoleColor.Cyan;
        Console.WriteLine("AeroNovelTool by AE Ver." + Version.date);
        Console.ForegroundColor = ConsoleColor.White;
        if (args.Length >= 2)
        {
            switch (args[0].ToLower())
            {
            case "epub":
            {
                if (!DirectoryExist(args[1]))
                {
                    return;
                }
                var gen = new AeroNovelEpub.GenEpub();
                for (int i = 2; i < args.Length; i++)
                {
                    if (args[i] == "t2s")
                    {
                        gen = new AeroNovelEpub.GenEpub(AeroNovelEpub.ChineseConvertOption.T2S);
                    }
                }

                EpubFile      e          = gen.Gen(args[1]);
                List <string> creators   = new List <string>();
                string        dateString = DateTime.Today.ToString("yyyyMMdd");
                e.dc_creators.ForEach((x) =>
                    {
                        if (x.refines.Count > 0)
                        {
                            foreach (var refine in x.refines)
                            {
                                if (refine.name == "role")
                                {
                                    if (refine.value != "aut")
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                        creators.Add(x.value);
                    });
                try
                {
                    e.meta.ForEach((x) => { if (x.name == "dcterms:modified")
                                            {
                                                dateString = x.value.Replace("-", "").Substring(0, 8);
                                            }
                                   });
                }
                catch (ArgumentOutOfRangeException)
                {
                    Log.Warn("Error at getting modified date in metadata");
                }

                e.filename = $"[{string.Join(",", creators)}] {e.title} [{dateString}]";
                if (args.Length >= 3 && DirectoryExist(args[2]))
                {
                    e.Save(args[2]);
                }
                else
                {
                    e.Save("");
                }
            }
            break;

            case "txt":
                if (!DirectoryExist(args[1]))
                {
                    return;
                }
                GenTxt.Gen(args[1]);
                break;

            case "bbcode":
                if (!DirectoryExist(args[1]))
                {
                    return;
                }
                if (args.Length >= 3)
                {
                    if (DirectoryExist(args[2]))
                    {
                        GenBbcode.output_path        = Path.Combine(args[2], GenBbcode.output_path);
                        GenBbcode.output_path_single = Path.Combine(args[2], GenBbcode.output_path_single);
                    }
                }
                GenBbcode.GenSingle(args[1]);
                break;

            case "epub2comment":
                if (!FileExist(args[1]))
                {
                    return;
                }
                Epub2Comment e2c = new Epub2Comment(args[1]);
                if (args.Length > 2)
                {
                    switch (args[2])
                    {
                    case "BlackTranslatingMagic":
                        e2c.castBlackTranslatingMagic = true;
                        break;

                    case "Glossary":
                        if (args.Length > 3)
                        {
                            e2c.glossaryDocPath = args[3];
                        }
                        else
                        {
                            Log.Error("Should give glossary document.");
                        }
                        break;
                    }
                }
                e2c.Proc();
                break;

            case "epub2atxt":
                if (!FileExist(args[1]))
                {
                    return;
                }
                Epub2Atxt.Proc(args[1]);
                break;

            case "html2comment":
                if (!FileExist(args[1]))
                {
                    return;
                }
                Html2Comment.Proc(args[1]);
                break;

            case "atxt2bbcode":
                if (!FileExist(args[1]))
                {
                    return;
                }
                GenBbcode.Proc(args[1]);
                break;

            case "kakuyomu2comment":
            {
                var xhtml = WebSource.KakuyomuEpisode(args[1]);
                var atxt  = Html2Comment.ProcXHTML(xhtml.text);
                File.WriteAllText("output_kakuyomu2comment.txt", atxt);
                Log.Note("output_kakuyomu2comment.txt");
            }
            break;

            case "websrc":
            {
                TextEpubItemFile[] xhtmls;
                string             dirname = "output_websrc_";
                if (args[1].Contains("kakuyomu.jp"))
                {
                    xhtmls   = WebSource.KakuyomuAuto(args[1]);
                    dirname += "kakuyomu";
                }
                else
                {
                    Log.Error("什么网站");
                    break;
                }
                if (xhtmls != null)
                {
                    Directory.CreateDirectory(dirname);
                    foreach (var xhtml in xhtmls)
                    {
                        Save(xhtml, dirname);
                    }
                }
            }
            break;

            case "atxtcc":
            {
                if (!FileExist(args[1]))
                {
                    return;
                }
                bool t2s = false, s2t = false, replace = false;
                for (int i = 2; i < args.Length; i++)
                {
                    switch (args[i])
                    {
                    case "t2s": t2s = true; break;

                    case "s2t": s2t = true; break;

                    case "replace": replace = true; break;
                    }
                }
                if (t2s)
                {
                    AeroNovelEpub.AtxtChineseConvert.ProcT2C(args[1], replace);
                }
                else if (s2t)
                {
                    //Not Implemented
                }
            }
            break;

            default:
                Log.Warn("Nothing happens. " + usage);
                break;
            }
        }
        else
        {
            Log.Warn(usage);
        }
    }