-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Add polymorphism to Manga and Hentai to allow for easier addition of sources - Several things have been renamed - Beginnings of KissManga integration Note: Need to make many more changes to fully polymorphize. May require changes to manga.txt
- Loading branch information
Showing
30 changed files
with
749 additions
and
91 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
using HtmlAgilityPack; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.ComponentModel; | ||
using System.IO; | ||
using System.Net; | ||
using System.Text; | ||
using System.Threading; | ||
|
||
namespace MikuReader.Core | ||
{ | ||
public class KissMangaDownload : IDownload | ||
{ | ||
private Chapter chapter; | ||
private ArrayList clients; | ||
private float total; | ||
|
||
public event DownloadCompletedEventHandler DownloadCompleted; | ||
|
||
public KissMangaDownload(Chapter chapter) | ||
{ | ||
this.chapter = chapter; | ||
clients = new ArrayList(); | ||
total = 0; | ||
} | ||
|
||
public void StartDownloading() | ||
{ | ||
File.Create(Path.Combine(chapter.GetChapterRoot().Parent.FullName, "dl" + chapter.GetID())).Close(); | ||
|
||
string mName = chapter.GetChapterRoot().Parent.Name; | ||
string cUrl = "https://kissmanga.org/chapter/" + mName + "/" + chapter.GetID(); | ||
string[] pageUrls = KissMangaHelper.GetPageUrls(cUrl); | ||
|
||
foreach (string url in pageUrls) | ||
{ | ||
string imgFile = Path.Combine(chapter.GetChapterRoot().FullName, KissMangaHelper.GetPageFileName(url)); | ||
DownloadAsync(new Uri(url), imgFile); | ||
} | ||
} | ||
|
||
public void DownloadAsync(Uri imgUrl, string imgFile) | ||
{ | ||
using (WebClient wc = new WebClient()) | ||
{ | ||
total++; | ||
clients.Add(wc); | ||
wc.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadCompletedCallback); | ||
wc.DownloadFileAsync(imgUrl, imgFile); | ||
} | ||
} | ||
|
||
public bool CheckStartNext() | ||
{ | ||
if (clients.Count == 0) | ||
{ | ||
DownloadCompleted.Invoke(this); | ||
File.Delete(Path.Combine(chapter.GetChapterRoot().Parent.FullName, "dl" + chapter.GetID())); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
public void DownloadCompletedCallback(object sender, AsyncCompletedEventArgs e) | ||
{ | ||
clients.Remove((WebClient)sender); | ||
CheckStartNext(); | ||
} | ||
|
||
public int GetProgress() | ||
{ | ||
return total != 0 ? (int)(((total - clients.Count) / total) * 100) : 0; | ||
} | ||
|
||
public string GetChapterName() | ||
{ | ||
return chapter.GetChapterRoot().ToString(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml; | ||
|
||
namespace MikuReader.Core | ||
{ | ||
/// <summary> | ||
/// Representation of a Manga | ||
/// </summary> | ||
public abstract class Hentai : Title | ||
{ | ||
/// <summary> | ||
/// Loads Manga info from manga.txt | ||
/// </summary> | ||
public abstract void _Load(); | ||
|
||
/// <summary> | ||
/// Creates manga.txt, then calls Load() | ||
/// </summary> | ||
/// <param name="mangaUrl"></param> | ||
public abstract void _Create(string mangaUrl); | ||
|
||
/// <summary> | ||
/// Create a Chapter for each chapter and add it to the chapter list | ||
/// </summary> | ||
public abstract void _PopulateChapters(); | ||
|
||
public abstract override void UpdateLocation(string chapter, string page); | ||
|
||
public abstract override void Save(string chapter, string page); | ||
|
||
public abstract override void UpdateProperties(string title, string lang, string group); | ||
|
||
public abstract override string GetTitle(); | ||
|
||
public abstract override string GetUserTitle(); | ||
|
||
public abstract override List<Chapter> GetChapters(); | ||
|
||
public abstract override string GetCurrentChapter(); | ||
|
||
public abstract override string GetCurrentPage(); | ||
|
||
public abstract override string GetID(); | ||
|
||
public abstract override bool IsDownloading(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
using Newtonsoft.Json; | ||
using Newtonsoft.Json.Linq; | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml; | ||
|
||
namespace MikuReader.Core | ||
{ | ||
/// <summary> | ||
/// Representation of a Manga | ||
/// </summary> | ||
public abstract class Manga : Title | ||
{ | ||
|
||
/// <summary> | ||
/// Loads Manga info from manga.txt | ||
/// </summary> | ||
public abstract void _Load(bool doChapters); | ||
|
||
/// <summary> | ||
/// Creates manga.txt, then calls Load() | ||
/// </summary> | ||
/// <param name="mangaUrl"></param> | ||
public abstract void _Create(string mangaUrl); | ||
|
||
public abstract Chapter[] GetSetPrunedChapters(bool overrideDlc); | ||
|
||
public abstract Chapter[] GetUpdates(); | ||
|
||
/// <summary> | ||
/// Get the groups associated with this manga | ||
/// </summary> | ||
/// <param name="langCode">Language to select group from</param> | ||
/// <returns>List of groups associated with the language</returns> | ||
public abstract string[] GetGroups(string langCode); | ||
|
||
public abstract string[] GetLangs(); | ||
|
||
/// <summary> | ||
/// Get the user's specified language | ||
/// </summary> | ||
public abstract string GetUserLang(); | ||
|
||
/// <summary> | ||
/// Get the user's specified Group | ||
/// </summary> | ||
public abstract string GetUserGroup(); | ||
|
||
/// <summary> | ||
/// Create a Chapter for each chapter and add it to the chapter list | ||
/// </summary> | ||
public abstract void _PopulateChapters(); | ||
|
||
public abstract override void UpdateLocation(string chapter, string page); | ||
|
||
public abstract override void Save(string chapter, string page); | ||
|
||
public abstract override void UpdateProperties(string title, string lang, string group); | ||
|
||
public abstract override string GetTitle(); | ||
|
||
public abstract override string GetUserTitle(); | ||
|
||
public abstract override List<Chapter> GetChapters(); | ||
|
||
public abstract override string GetCurrentChapter(); | ||
|
||
public abstract override string GetCurrentPage(); | ||
|
||
public abstract override string GetID(); | ||
|
||
public abstract override bool IsDownloading(); | ||
|
||
public abstract void UpdateDLChapters(String[] chapterNums); | ||
|
||
public abstract String[] GetDLChapters(); | ||
|
||
} | ||
} |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
|
||
namespace MikuReader.Core | ||
{ | ||
public enum HentaiType | ||
{ | ||
NHENTAI | ||
} | ||
} |
Oops, something went wrong.