예제 #1
0
        /// <summary>
        /// Preperation
        /// </summary>
        /// <param name="m"></param>
        /// <param name="startPage"></param>
        public void StartUp(Manga m, FrmStartPage startPage)
        {
            this.root      = m.mangaDirectory;
            this.startPage = startPage;

            foreach (DirectoryInfo dir in root.GetDirectories("*", SearchOption.TopDirectoryOnly)) // chapters
            {
                FileInfo[] files = dir.GetFiles("*");
                ArrayList  pages = new ArrayList();

                foreach (FileInfo fi in files) // pages
                {
                    string shortName = Path.GetFileNameWithoutExtension(fi.Name);
                    string num       = Regex.Match(shortName, @"(\d+(\.\d+)?)|(\.\d+)").Value;
                    pages.Add(new Page(num, fi));
                }

                Chapter c = new Chapter(dir.Name, dir, SortPages((Page[])pages.ToArray(typeof(Page))));
                if (dir.Name == m.currentChapter)
                {
                    curChapter = c;
                }
                chapters.Add(c);
            }

            UpdateChapters();
            UpdatePages(curChapter);
            cmboPage.SelectedItem = m.currentPage;
        }
예제 #2
0
        public FrmMangaSettings(Manga m)
        {
            InitializeComponent();
            this.m = m;
            dynamic contents = JsonConvert.DeserializeObject(File.ReadAllText(m.mangaDirectory.FullName + "\\manga.json"));

            Setup(contents);
        }
예제 #3
0
 public Download(string chapterNumber, string chapterID, Manga manga, string url, DownloadType type, DownloadManager downloadManager)
 {
     this.chapterNumber   = chapterNumber;
     this.chapterID       = chapterID;
     this.manga           = manga;
     this.url             = url;
     this.type            = type;
     this.downloadManager = downloadManager;
     clients = new ArrayList();
     dlCount = 0;
 }
예제 #4
0
        /// <summary>
        /// Add a nHentai entry to the download queue
        /// </summary>
        /// <param name="m">Manga associated with this entry</param>
        /// <param name="chapterID">Chapter ID, e.g 843254</param>
        public void AddNHToQueue(Manga m, string chapterID)
        {
            string   dlUrl = "https://nhentai.net/g/" + chapterID + "/1";
            Download dl    = CreateNHDownload(chapterID, m, dlUrl);

            Logger.Log("Adding NH to queue '" + m.name + " chapter " + dl.chapterNumber + "'");
            downloadQueue.Push(dl);
            downloads.Add(dl);
            downloadCount++;

            DownloadNextFromQueue();
        }
예제 #5
0
 /// <summary>
 /// Determine if the chapter in question already exists in the queue
 /// </summary>
 /// <param name="m">Manga associated with this entry</param>
 /// <param name="chapterNum">The chapter number, e.g 7</param>
 /// <returns>True if the chapter exists in the queue already</returns>
 private bool IsQueueDuplicate(Manga m, string chapterNum)
 {
     foreach (Download d in downloadQueue)
     {
         if (d.manga.name == m.name && d.chapterNumber == chapterNum)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     return(false);
 }
예제 #6
0
        /// <summary>
        /// Adds a manga to the database, doubles as a full check of all the files
        /// </summary>
        /// <param name="api">API link</param>
        /// <param name="num">Chapter Number</param>
        public void AddManga(string api, string num, bool isUpdate)
        {
            string json;

            if (api != null)
            {
                using (var wc = new System.Net.WebClient())
                {
                    json = wc.DownloadString(api);
                }
            }
            else
            {
                json = File.ReadAllText(homeFolder + "\\" + num + "\\manga.json");
            }

            // Deserialize the JSON file
            dynamic contents       = JsonConvert.DeserializeObject(json);
            string  mangaName      = contents.manga.title;
            string  mangaDirectory = homeFolder + "\\" + num;

            if (!Directory.Exists(mangaDirectory))
            {
                Logger.Log("Creating directory '" + mangaDirectory + "' and related files");
                Directory.CreateDirectory(mangaDirectory);
                File.WriteAllText(mangaDirectory + "\\manga.json", json); // Write the JSON to a file
                File.WriteAllText(mangaDirectory + "\\tracker", "1|1");   // Write initial tracking info to a file
            }
            File.WriteAllText(mangaDirectory + "\\downloading", "");      // Create "Downloading" file

            Manga m = new Manga(mangaName, new DirectoryInfo(mangaDirectory), "1", "1");

            if (!isUpdate)
            {
                DialogResult result = new FrmMangaSettings(m).ShowDialog();
                MessageBox.Show("Downloading data...\nYou may close the Browser as you desire.");
            }
            m.LoadSettings();
            downloadManager.AddMDToQueue(m, contents.chapter, isUpdate);
            RefreshContents();
        }
예제 #7
0
        /// <summary>
        /// Add a Hentai to the database
        /// </summary>
        /// <param name="chapterID">le numbers</param>
        public void AddHentai(string chapterID, string title)
        {
            string hentaiDirectory = homeFolder + "\\h" + chapterID;

            if (!Directory.Exists(hentaiDirectory))
            {
                Logger.Log("Creating directory '" + hentaiDirectory + "' and related files");
                Directory.CreateDirectory(hentaiDirectory);
                File.WriteAllText(hentaiDirectory + "\\tracker", "1|1"); // Write initial tracking info to a file
                File.WriteAllText(hentaiDirectory + "\\title", title);   // Write the title to a file
            }
            File.WriteAllText(hentaiDirectory + "\\downloading", "");    // Create "Downloading" file

            Manga        m = new Manga("", new DirectoryInfo(hentaiDirectory), "1", "1");
            DialogResult r = new FrmHentaiSettings(m).ShowDialog();

            MessageBox.Show("Downloading data...\nYou may close the Browser as you desire.");

            downloadManager.AddNHToQueue(m, chapterID);
            RefreshContents();
        }
예제 #8
0
 /// <summary>
 /// Handles opening the reader
 /// </summary>
 /// <param name="m"></param>
 private void Read(Manga m)
 {
     if (!File.Exists(m.mangaDirectory.FullName + "\\downloading"))
     {
         if ((bool)Properties.Settings.Default["doublePageReader"] == false)
         {
             Logger.Log("Opening Reader to " + m.name);
             FrmReader reader = new FrmReader();
             reader.Show();
             reader.StartUp(m, this);
         }
         else
         {
             Logger.Log("Opening DPReader to " + m.name);
             FrmDoublePageReader reader = new FrmDoublePageReader();
             reader.Show();
             reader.StartUp(m, this);
         }
     }
     else
     {
         MessageBox.Show("Cannot read '" + m.name + "' because it is currently being downloaded");
     }
 }
예제 #9
0
 /// <summary>
 /// Creates a nHentai download container
 /// </summary>
 /// <param name="chapterID">Chapter ID, e.g 843254</param>
 /// <param name="m">Manga associated with this entry</param>
 /// <param name="downloadUrl">Where to download from</param>
 /// <returns>A Download container</returns>
 private Download CreateNHDownload(string chapterID, Manga m, string downloadUrl)
 {
     return(new Download("1", chapterID, m, downloadUrl, DownloadType.HENTAI, this));
 }
예제 #10
0
 /// <summary>
 /// Creates a MangaDex download container
 /// </summary>
 /// <param name="chapterNumber">Chapter Number, e.g 7</param>
 /// <param name="chapterID">Chapter ID, e.g 98634</param>
 /// <param name="m">Manga associated with this entry</param>
 /// <param name="downloadUrl">Where to download from</param>
 /// <returns>A Download container</returns>
 private Download CreateMDDownload(string chapterNumber, string chapterID, Manga m, string downloadUrl)
 {
     return(new Download(chapterNumber, chapterID, m, downloadUrl, DownloadType.MANGA, this));
 }
 public FrmHentaiSettings(Manga m)
 {
     this.m = m;
     InitializeComponent();
 }
예제 #12
0
        /// <summary>
        /// Refreshes the UI and its contents
        /// </summary>
        public void RefreshContents()
        {
            Logger.Log("Refreshing");
            lstManga.Items.Clear();
            lstHentai.Items.Clear();
            mangas.Clear();
            DirectoryInfo root = new DirectoryInfo(homeFolder);

            DirectoryInfo[] dirs = root.GetDirectories("*", SearchOption.TopDirectoryOnly);

            foreach (DirectoryInfo dir in dirs)
            {
                // Logger.Log("Refreshing data for directory '" + dir.Name + "'");
                if (dir.Name == "update")
                {
                    continue;
                }
                else if (!dir.Name.StartsWith("h"))
                {
                    var      json        = File.ReadAllText(dir.FullName + "\\manga.json");
                    var      tracker     = File.ReadAllText(dir.FullName + "\\tracker");
                    string[] trackerData = tracker.Split('|');
                    // Deserialize the JSON file
                    dynamic contents  = JsonConvert.DeserializeObject(json);
                    string  mangaName = contents.manga.title;
                    Manga   m         = new Manga(mangaName, dir, trackerData[0], trackerData[1]);
                    m.LoadSettings();
                    if (m.settings.name == "" || m.settings.name == null)
                    {
                        m.SaveSettings(m.settings.lang, m.settings.group, mangaName);
                        m.LoadSettings();
                    }

                    mangas.Add(m);
                    string name = m.settings.name;
                    if (name.Length > 21)
                    {
                        name = name.Substring(0, 21);
                    }
                    else
                    {
                        name = name.PadRight(21);
                    }
                    lstManga.Items.Add(name + "  »  c" + trackerData[0] + ",p" + trackerData[1]);
                }
                else // Hentai
                {
                    string   title       = File.ReadAllText(dir.FullName + "\\title");
                    var      tracker     = File.ReadAllText(dir.FullName + "\\tracker");
                    string[] trackerData = tracker.Split('|');

                    Manga m = new Manga(title, dir, trackerData[0], trackerData[1]);
                    mangas.Add(m);
                    string name = m.name;
                    if (name.Length > 21)
                    {
                        name = name.Substring(0, 21);
                    }
                    else
                    {
                        name = name.PadRight(21);
                    }
                    lstHentai.Items.Add(name + "  »  p" + trackerData[1]);
                }
            }
            if (lstManga.Items.Count > 0)
            {
                lstManga.SelectedIndex = 0;
            }
            if (lstHentai.Items.Count > 0)
            {
                lstHentai.SelectedIndex = 0;
            }
        }