Пример #1
0
 public static int PurchaseAll(int comicId, string cookie, int?couponId)
 {
     try
     {
         ComicInfo comic = MangaUtils.GetComicInfo(comicId, cookie);
         return(PurchaseAll(comic, cookie, couponId));
     }
     catch (Exception e)
     {
         Console.WriteLine($"Unexpected Exception encountered while Getting ComicInfo:{e}");
         return(-1);
     }
 }
Пример #2
0
 public static int PurchaseOne(int episodeId, string cookie, int?couponId)
 {
     try
     {
         Coupon coupon = couponId.HasValue ? new Coupon(couponId.Value) : MangaUtils.GetRecommendCoupon(episodeId, cookie);
         MangaUtils.BuyEpisode(episodeId, coupon.Id, cookie);
         Console.WriteLine($"Successfully Unlocked Episode:{episodeId}");
         return(0);
     }
     catch (Exception e)
     {
         Console.WriteLine($"Can't Buy Episode because:{e}");
         return(-1);
     }
 }
Пример #3
0
        public static void DefaultExecution()
        {
            string cookie;

            while (true)
            {
                Console.Write("请输入你的Cookie:");
                cookie = Console.ReadLine();
                try
                {
                    if (MangaUtils.CheckLoginStatus(cookie))
                    {
                        break;
                    }
                    Console.WriteLine("给定的Cookie无效,请重新输入");
                    Console.ReadLine();
                }
                catch (Exception e)
                {
                    Console.WriteLine($"发生了意外情况:{e}\n请重试");
                    Console.ReadLine();
                }
            }
            while (true)
            {
                Console.Clear();
                Console.Write("请输入漫画Id/漫画名(支持输入部分名称):");
                string    keyword = Console.ReadLine();
                ComicInfo comic;
                try
                {
                    if (int.TryParse(keyword, out int comicId))
                    {
                        comic = MangaUtils.GetComicInfo(comicId, cookie);
                    }
                    else
                    {
                        ComicInfo[] comics = MangaUtils.SearchComic(keyword);
                        if ((comic = comics.FirstOrDefault(p => p.Name == keyword)) == null)
                        {
                            while (true)
                            {
                                Console.Clear();
                                Console.WriteLine("已搜索到下列漫画");
                                Console.WriteLine(string.Join("\r\n", comics.Select((p, q) => $"{q + 1}. {p.Name}")));
                                Console.Write("请输入对应序号,输入0取消操作:");
                                if (int.TryParse(Console.ReadLine(), out int seq) && seq <= comics.Length && seq > -1)
                                {
                                    if (seq > 0)
                                    {
                                        comic = comics[seq - 1];
                                    }
                                    break;
                                }
                                Console.WriteLine("输入无效,请重新输入");
                                Console.ReadLine();
                            }
                        }
                        if (comic == null)
                        {
                            continue;
                        }
                        comic = MangaUtils.GetComicInfo(comic.Id, cookie);
                    }
                    bool quitSig = false;
                    while (!quitSig)
                    {
                        Console.Clear();
                        Console.WriteLine($"当前漫画:{comic.Name}[{comic.Id}],你还剩{comic.Episodes.Count(p => p.Locked && !p.UserPurchased)}章未解锁");
                        Console.Write("是否全部解锁(Y/n)?");
                        switch (Console.ReadLine().ToLower())
                        {
                        case "y":
                        {
                            int unlocked = PurchaseAll(comic, cookie, null);
                            Console.WriteLine($"已成功解锁{unlocked}章");
                            Console.ReadLine();
                            quitSig = true;
                            break;
                        }

                        case "n":
                        {
                            quitSig = true;
                            break;
                        }

                        default:
                        {
                            Console.WriteLine("输入无效,请重新输入");
                            Console.ReadLine();
                            break;
                        }
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine($"发生了意外情况:{e}\n请重试");
                }
            }
        }