Compare commits
No commits in common. "ed19dcb5c32b8936dc0e2da217f823f1f10c4b5c" and "61712d053791f52687b56fd4549505b86d033bc8" have entirely different histories.
ed19dcb5c3
...
61712d0537
@ -1,6 +1,5 @@
|
|||||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Komga/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Komga/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Manganato/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Manganato/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Mangasee/@EntryIndexedValue">True</s:Boolean>
|
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Taskmanager/@EntryIndexedValue">True</s:Boolean>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Taskmanager/@EntryIndexedValue">True</s:Boolean>
|
||||||
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tranga/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
<s:Boolean x:Key="/Default/UserDictionary/Words/=Tranga/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
@ -27,7 +27,7 @@ public struct Chapter
|
|||||||
{
|
{
|
||||||
NumberDecimalSeparator = "."
|
NumberDecimalSeparator = "."
|
||||||
};
|
};
|
||||||
sortNumber = decimal.Round(Convert.ToDecimal(this.volumeNumber ?? "1") * Convert.ToDecimal(this.chapterNumber, nfi), 1)
|
sortNumber = decimal.Round(Convert.ToDecimal(this.volumeNumber) * Convert.ToDecimal(this.chapterNumber, nfi), 1)
|
||||||
.ToString(nfi);
|
.ToString(nfi);
|
||||||
|
|
||||||
string chapterName = string.Concat(LegalCharacters.Matches(name ?? ""));
|
string chapterName = string.Concat(LegalCharacters.Matches(name ?? ""));
|
||||||
|
@ -23,6 +23,7 @@ public class Manganato : Connector
|
|||||||
{
|
{
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
|
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
|
||||||
string sanitizedTitle = string.Concat(Regex.Matches(publicationTitle, "[A-z]* *")).ToLower().Replace(' ', '_');
|
string sanitizedTitle = string.Concat(Regex.Matches(publicationTitle, "[A-z]* *")).ToLower().Replace(' ', '_');
|
||||||
|
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={sanitizedTitle})");
|
||||||
string requestUrl = $"https://manganato.com/search/story/{sanitizedTitle}";
|
string requestUrl = $"https://manganato.com/search/story/{sanitizedTitle}";
|
||||||
DownloadClient.RequestResult requestResult =
|
DownloadClient.RequestResult requestResult =
|
||||||
downloadClient.MakeRequest(requestUrl, (byte)1);
|
downloadClient.MakeRequest(requestUrl, (byte)1);
|
||||||
|
@ -1,219 +0,0 @@
|
|||||||
using System.Net;
|
|
||||||
using System.Text.RegularExpressions;
|
|
||||||
using System.Xml.Linq;
|
|
||||||
using HtmlAgilityPack;
|
|
||||||
using Logging;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using PuppeteerSharp;
|
|
||||||
using Tranga.TrangaTasks;
|
|
||||||
|
|
||||||
namespace Tranga.Connectors;
|
|
||||||
|
|
||||||
public class Mangasee : Connector
|
|
||||||
{
|
|
||||||
public override string name { get; }
|
|
||||||
private IBrowser? browser = null;
|
|
||||||
|
|
||||||
public Mangasee(string downloadLocation, string imageCachePath, Logger? logger) : base(downloadLocation,
|
|
||||||
imageCachePath, logger)
|
|
||||||
{
|
|
||||||
this.name = "Mangasee";
|
|
||||||
this.downloadClient = new DownloadClient(new Dictionary<byte, int>()
|
|
||||||
{
|
|
||||||
{ (byte)1, 60 }
|
|
||||||
}, logger);
|
|
||||||
|
|
||||||
Task d = new Task(DownloadBrowser);
|
|
||||||
d.Start();
|
|
||||||
}
|
|
||||||
|
|
||||||
private async void DownloadBrowser()
|
|
||||||
{
|
|
||||||
logger?.WriteLine(this.GetType().ToString(), "Downloading headless browser");
|
|
||||||
BrowserFetcher browserFetcher = new BrowserFetcher();
|
|
||||||
double last = 0;
|
|
||||||
browserFetcher.DownloadProgressChanged += async (sender, args) =>
|
|
||||||
{
|
|
||||||
double current = Convert.ToDouble(args.BytesReceived) / Convert.ToDouble(args.TotalBytesToReceive);
|
|
||||||
if (args.TotalBytesToReceive == args.BytesReceived)
|
|
||||||
{
|
|
||||||
logger?.WriteLine(this.GetType().ToString(), "Browser downloaded. Launching...");
|
|
||||||
}
|
|
||||||
else if (current > last + 0.01)
|
|
||||||
{
|
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Browser progress: {current:P2}");
|
|
||||||
last = current;
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
|
||||||
if (!browserFetcher.CanDownloadAsync(BrowserFetcher.DefaultChromiumRevision).Result)
|
|
||||||
{
|
|
||||||
logger?.WriteLine(this.GetType().ToString(), "Can't download");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await browserFetcher.DownloadAsync(BrowserFetcher.DefaultChromiumRevision);
|
|
||||||
this.browser = await Puppeteer.LaunchAsync(new LaunchOptions
|
|
||||||
{
|
|
||||||
Headless = true,
|
|
||||||
ExecutablePath = browserFetcher.GetExecutablePath(BrowserFetcher.DefaultChromiumRevision)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Publication[] GetPublications(string publicationTitle = "")
|
|
||||||
{
|
|
||||||
logger?.WriteLine(this.GetType().ToString(), $"Getting Publications (title={publicationTitle})");
|
|
||||||
string sanitizedTitle = string.Concat(Regex.Matches(publicationTitle, "[A-z]* *")).ToLower().Replace(' ', '+');
|
|
||||||
string requestUrl = $"https://mangasee123.com/_search.php";
|
|
||||||
DownloadClient.RequestResult requestResult =
|
|
||||||
downloadClient.MakeRequest(requestUrl, (byte)1);
|
|
||||||
if (requestResult.statusCode != HttpStatusCode.OK)
|
|
||||||
return Array.Empty<Publication>();
|
|
||||||
|
|
||||||
return ParsePublicationsFromHtml(requestResult.result, publicationTitle);
|
|
||||||
}
|
|
||||||
|
|
||||||
private Publication[] ParsePublicationsFromHtml(Stream html, string publicationTitle)
|
|
||||||
{
|
|
||||||
string jsonString = new StreamReader(html).ReadToEnd();
|
|
||||||
List<SearchResultItem> result = JsonConvert.DeserializeObject<List<SearchResultItem>>(jsonString)!;
|
|
||||||
Dictionary<SearchResultItem, int> queryFiltered = new();
|
|
||||||
foreach (SearchResultItem resultItem in result)
|
|
||||||
{
|
|
||||||
foreach (string term in publicationTitle.Split(' '))
|
|
||||||
if (resultItem.i.Contains(term, StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
if (!queryFiltered.TryAdd(resultItem, 0))
|
|
||||||
queryFiltered[resultItem]++;
|
|
||||||
}
|
|
||||||
|
|
||||||
queryFiltered = queryFiltered.Where(item => item.Value >= publicationTitle.Split(' ').Length - 1)
|
|
||||||
.ToDictionary(item => item.Key, item => item.Value);
|
|
||||||
|
|
||||||
HashSet<Publication> ret = new();
|
|
||||||
List<SearchResultItem> orderedFiltered =
|
|
||||||
queryFiltered.OrderBy(item => item.Value).ToDictionary(item => item.Key, item => item.Value).Keys.ToList();
|
|
||||||
|
|
||||||
foreach (SearchResultItem orderedItem in orderedFiltered)
|
|
||||||
{
|
|
||||||
DownloadClient.RequestResult requestResult =
|
|
||||||
downloadClient.MakeRequest($"https://mangasee123.com/manga/{orderedItem.i}", (byte)1);
|
|
||||||
if (requestResult.statusCode != HttpStatusCode.OK)
|
|
||||||
return Array.Empty<Publication>();
|
|
||||||
ret.Add(ParseSinglePublicationFromHtml(requestResult.result, orderedItem.s, orderedItem.i, orderedItem.a));
|
|
||||||
}
|
|
||||||
return ret.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private Publication ParseSinglePublicationFromHtml(Stream html, string sortName, string publicationId, string[] a)
|
|
||||||
{
|
|
||||||
StreamReader reader = new (html);
|
|
||||||
string htmlString = reader.ReadToEnd();
|
|
||||||
HtmlDocument document = new ();
|
|
||||||
document.LoadHtml(htmlString);
|
|
||||||
|
|
||||||
string originalLanguage = "", status = "";
|
|
||||||
Dictionary<string, string> altTitles = new(), links = new();
|
|
||||||
HashSet<string> tags = new();
|
|
||||||
|
|
||||||
HtmlNode posterNode =
|
|
||||||
document.DocumentNode.Descendants("img").First(img => img.HasClass("img-fluid") && img.HasClass("bottom-5"));
|
|
||||||
string posterUrl = posterNode.GetAttributeValue("src", "");
|
|
||||||
string coverFileNameInCache = SaveCoverImageToCache(posterUrl, 1);
|
|
||||||
|
|
||||||
HtmlNode attributes = document.DocumentNode.Descendants("div")
|
|
||||||
.First(div => div.HasClass("col-md-9") && div.HasClass("col-sm-8") && div.HasClass("top-5"))
|
|
||||||
.Descendants("ul").First();
|
|
||||||
|
|
||||||
HtmlNode[] authorsNodes = attributes.Descendants("li")
|
|
||||||
.First(node => node.InnerText.Contains("author(s):", StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
.Descendants("a").ToArray();
|
|
||||||
string[] authors = new string[authorsNodes.Length];
|
|
||||||
for (int j = 0; j < authors.Length; j++)
|
|
||||||
authors[j] = authorsNodes[j].InnerText;
|
|
||||||
string author = string.Join(" - ", authors);
|
|
||||||
|
|
||||||
HtmlNode[] genreNodes = attributes.Descendants("li")
|
|
||||||
.First(node => node.InnerText.Contains("genre(s):", StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
.Descendants("a").ToArray();
|
|
||||||
foreach (HtmlNode genreNode in genreNodes)
|
|
||||||
tags.Add(genreNode.InnerText);
|
|
||||||
|
|
||||||
HtmlNode yearNode = attributes.Descendants("li")
|
|
||||||
.First(node => node.InnerText.Contains("released:", StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
.Descendants("a").First();
|
|
||||||
int year = Convert.ToInt32(yearNode.InnerText);
|
|
||||||
|
|
||||||
HtmlNode[] statusNodes = attributes.Descendants("li")
|
|
||||||
.First(node => node.InnerText.Contains("status:", StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
.Descendants("a").ToArray();
|
|
||||||
foreach(HtmlNode statusNode in statusNodes)
|
|
||||||
if (statusNode.InnerText.Contains("publish", StringComparison.CurrentCultureIgnoreCase))
|
|
||||||
status = statusNode.InnerText.Split(' ')[0];
|
|
||||||
|
|
||||||
HtmlNode descriptionNode = attributes.Descendants("li").First(node => node.InnerText.Contains("description:", StringComparison.CurrentCultureIgnoreCase)).Descendants("div").First();
|
|
||||||
string description = descriptionNode.InnerText;
|
|
||||||
|
|
||||||
int i = 0;
|
|
||||||
foreach(string at in a)
|
|
||||||
altTitles.Add((i++).ToString(), at);
|
|
||||||
|
|
||||||
return new Publication(sortName, author, description, altTitles, tags.ToArray(), posterUrl, coverFileNameInCache, links,
|
|
||||||
year, originalLanguage, status, publicationId);
|
|
||||||
}
|
|
||||||
|
|
||||||
private class SearchResultItem
|
|
||||||
{
|
|
||||||
public string i { get; set; }
|
|
||||||
public string s { get; set; }
|
|
||||||
public string[] a { get; set; }
|
|
||||||
}
|
|
||||||
|
|
||||||
public override Chapter[] GetChapters(Publication publication, string language = "")
|
|
||||||
{
|
|
||||||
XDocument doc = XDocument.Load($"https://mangasee123.com/rss/{publication.publicationId}.xml");
|
|
||||||
XElement[] chapterItems = doc.Descendants("item").ToArray();
|
|
||||||
List<Chapter> ret = new();
|
|
||||||
foreach (XElement chapter in chapterItems)
|
|
||||||
{
|
|
||||||
string? volumeNumber = null;
|
|
||||||
string chapterName = chapter.Descendants("title").First().Value;
|
|
||||||
string parseFrom = name.Replace(publication.sortName, "", StringComparison.InvariantCultureIgnoreCase);
|
|
||||||
string chapterNumber = Regex.Matches(chapterName, "[0-9]+")[^1].ToString();
|
|
||||||
|
|
||||||
string url = chapter.Descendants("link").First().Value;
|
|
||||||
url = url.Replace(Regex.Matches(url,"(-page-[0-9])")[0].ToString(),"");
|
|
||||||
ret.Add(new Chapter(chapterName, volumeNumber, chapterNumber, url));
|
|
||||||
}
|
|
||||||
|
|
||||||
ret.Reverse();
|
|
||||||
return ret.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void DownloadChapter(Publication publication, Chapter chapter, DownloadChapterTask parentTask)
|
|
||||||
{
|
|
||||||
while (this.browser is null)
|
|
||||||
{
|
|
||||||
logger?.WriteLine(this.GetType().ToString(), "Waiting for headless browser to download...");
|
|
||||||
Thread.Sleep(1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
IPage page = browser.NewPageAsync().Result;
|
|
||||||
IResponse response = page.GoToAsync(chapter.url).Result;
|
|
||||||
if (response.Ok)
|
|
||||||
{
|
|
||||||
HtmlDocument document = new ();
|
|
||||||
document.LoadHtml(page.GetContentAsync().Result);
|
|
||||||
|
|
||||||
HtmlNode gallery = document.DocumentNode.Descendants("div").First(div => div.HasClass("ImageGallery"));
|
|
||||||
HtmlNode[] images = gallery.Descendants("img").Where(img => img.HasClass("img-fluid")).ToArray();
|
|
||||||
List<string> urls = new();
|
|
||||||
foreach(HtmlNode galleryImage in images)
|
|
||||||
urls.Add(galleryImage.GetAttributeValue("src", ""));
|
|
||||||
|
|
||||||
string comicInfoPath = Path.GetTempFileName();
|
|
||||||
File.WriteAllText(comicInfoPath, GetComicInfoXmlString(publication, chapter, logger));
|
|
||||||
|
|
||||||
DownloadChapterImages(urls.ToArray(), GetArchiveFilePath(publication, chapter), (byte)1, parentTask, comicInfoPath);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -109,7 +109,7 @@ public readonly struct Publication
|
|||||||
this.year = year;
|
this.year = year;
|
||||||
if(status.ToLower() == "ongoing" || status.ToLower() == "hiatus")
|
if(status.ToLower() == "ongoing" || status.ToLower() == "hiatus")
|
||||||
this.status = "Continuing";
|
this.status = "Continuing";
|
||||||
else if (status.ToLower() == "completed" || status.ToLower() == "cancelled" || status.ToLower() == "discontinued")
|
else if (status.ToLower() == "completed" || status.ToLower() == "cancelled")
|
||||||
this.status = "Ended";
|
this.status = "Ended";
|
||||||
else
|
else
|
||||||
this.status = status;
|
this.status = status;
|
||||||
|
@ -34,8 +34,7 @@ public class TaskManager
|
|||||||
this._connectors = new Connector[]
|
this._connectors = new Connector[]
|
||||||
{
|
{
|
||||||
new MangaDex(downloadFolderPath, imageCachePath, logger),
|
new MangaDex(downloadFolderPath, imageCachePath, logger),
|
||||||
new Manganato(downloadFolderPath, imageCachePath, logger),
|
new Manganato(downloadFolderPath, imageCachePath, logger)
|
||||||
new Mangasee(downloadFolderPath, imageCachePath, logger)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Thread taskChecker = new(TaskCheckerThread);
|
Thread taskChecker = new(TaskCheckerThread);
|
||||||
@ -65,8 +64,7 @@ public class TaskManager
|
|||||||
this._connectors = new Connector[]
|
this._connectors = new Connector[]
|
||||||
{
|
{
|
||||||
new MangaDex(settings.downloadLocation, settings.coverImageCache, logger),
|
new MangaDex(settings.downloadLocation, settings.coverImageCache, logger),
|
||||||
new Manganato(settings.downloadLocation, settings.coverImageCache, logger),
|
new Manganato(settings.downloadLocation, settings.coverImageCache, logger)
|
||||||
new Mangasee(settings.downloadLocation, settings.coverImageCache, logger)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
|
@ -9,7 +9,6 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
|
||||||
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
<PackageReference Include="PuppeteerSharp" Version="10.0.0" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user