Пример #1
0
        public HathFileInfo Parse()
        {
            HathFileInfo HathFileInfo = new HathFileInfo();

            HathFileInfo.Raw = FileData;

            Match           matchGID   = Regex.Match(FileData, @"GID.([0-9]{1,20})");
            Match           matchFileC = Regex.Match(FileData, @"FILES.([0-9]{1,20})");
            Match           matchTitle = Regex.Match(FileData, @"TITLE.(.*)");
            MatchCollection matchFiles = Regex.Matches(FileData, @"(([0-9]{1,6}).([a-zA-Z0-9]{40}\-[0-9]{1,9}\-[0-9]{1,9}\-[0-9]{1,9}\-[a-zA-Z0-9]{1,50}).(.*))", RegexOptions.Multiline);

            if (matchGID.Success)
            {
                HathFileInfo.GID = Convert.ToInt32(matchGID.Groups[1].Value);
            }
            if (matchFileC.Success)
            {
                HathFileInfo.Files = Convert.ToInt32(matchFileC.Groups[1].Value);
            }
            if (matchTitle.Success)
            {
                HathFileInfo.Title = matchTitle.Groups[1].Value;
            }
            if (matchFiles.Count >= 1)
            {
                foreach (Match mach in matchFiles)
                {
                    HathFileInfo.FileList.Add(new HathFile(int.Parse(mach.Groups[2].Value), mach.Groups[3].Value, mach.Groups[4].Value, HathFileInfo.Title));
                }
            }

            return(HathFileInfo);
        }
Пример #2
0
        public static void Add(HathFileInfo Item, string[] IgnoreFiles = null)
        {
            if (IgnoreFiles != null)
            {
                List <HathFile> rm = new List <HathFile> {
                };

                foreach (HathFile fl in Item.FileList)
                {
                    foreach (string file in IgnoreFiles)
                    {
                        if (fl.FileNameOriginal == Path.GetFileName(file))
                        {
                            rm.Add(fl);
                        }
                    }
                }

                foreach (HathFile fl in rm)
                {
                    Item.FileList.Remove(fl);
                }
            }

            if (!Directory.Exists(Settings.Downloads + Item.Title) || IgnoreFiles != null)
            {
                try
                {
                    Directory.CreateDirectory(Settings.Downloads + Item.Title);
                }
                catch { return; }

                Quoque.Add(Item);

                if (IgnoreFiles == null)
                {
                    using (StreamWriter StreamWriter = new StreamWriter(Settings.Downloads + Item.Title + Settings.TempDlFile))
                    {
                        StreamWriter.Write(Item.Raw);
                    }
                }

                Log.Add("Added gallery \"" + Item.Title + "\" to quoque.", LogType.Info, true);
            }
            else
            {
                Log.Add("Directory already exists with that gallery name. Probobly it was already downloaded.", LogType.Warning, true);
            }
        }