Skip to content

Commit

Permalink
Fix bugs on grouple sites and henchan, release 1.51.9.39
Browse files Browse the repository at this point in the history
  • Loading branch information
MonkAlex committed Jun 3, 2023
1 parent 44bb5fc commit c6b1b09
Show file tree
Hide file tree
Showing 17 changed files with 134 additions and 59 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
# История версий
***
## 1.51.9.39 — 2023-06-03

### Исправлено
* Актуализирована поддержка https://readmanga.live/, https://mintmanga.live
* Актуализирован адрес https://x.henchan.pro/

***
## 1.51.8.38 — 2022-10-27

Expand Down
1 change: 1 addition & 0 deletions MangaReader.Core/Account/SiteHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ public SiteHttpClient(Uri mainUri, IWebProxy proxy, CookieContainer cookieContai
BaseAddress = mainUri
};
this.httpClient.DefaultRequestHeaders.UserAgent.TryParseAdd("Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:57.0) Gecko/20100101 Firefox/57.0");
this.httpClient.DefaultRequestHeaders.Accept.TryParseAdd("text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
}
}
}
4 changes: 3 additions & 1 deletion MangaReader.Core/Account/SiteWebClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,13 @@ public async Task<Page> GetPage(Uri uri)

private CookieClient GetCookieClient()
{
return new CookieClient(this.cookieContainer)
var client = new CookieClient(this.cookieContainer)
{
BaseAddress = mainUri.OriginalString,
Proxy = proxy,
};
client.Headers.Add(HttpRequestHeader.Accept, "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8");
return client;
}

private static async Task<Page> GetPageImpl(Uri uri, CookieClient client)
Expand Down
8 changes: 5 additions & 3 deletions MangaReader.Core/Manga/MangaPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,11 @@ public async Task Download(string chapterFolder)
var plugin = ConfigStorage.Plugins.Single(p => p.MangaType == manga.GetType());
var cache = MangaSettingCache.Get(plugin.GetType());

var file = await DownloadManager.DownloadImage(this.ImageLink, cache).ConfigureAwait(false);
var file = await DownloadManager.DownloadImage(this.ImageLink, cache, this.Uri.Host).ConfigureAwait(false);
if (!file.Exist)
OnDownloadFailed();
{
ThrowException();
}
var fileName = this.Number.ToString(CultureInfo.InvariantCulture).PadLeft(4, '0') + "." + file.Extension;
await file.Save(Path.Combine(chapterFolder, fileName)).ConfigureAwait(false);
this.IsDownloaded = true;
Expand All @@ -115,7 +117,7 @@ public async Task Download(string chapterFolder)
}
}

protected virtual void OnDownloadFailed()
protected virtual void ThrowException()
{
throw new System.Exception("Restart download, downloaded file is corrupted, link = " + this.ImageLink);
}
Expand Down
10 changes: 8 additions & 2 deletions MangaReader.Core/Services/DownloadManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,15 @@ public static async Task CheckPause()
/// <param name="uri">Ссылка на страницу манги.</param>
/// <param name="settingCache">Настройки сети.</param>
/// <returns>Содержимое файла.</returns>
public static async Task<ImageFile> DownloadImage(Uri uri, MangaSettingCache settingCache)
public static async Task<ImageFile> DownloadImage(Uri uri, MangaSettingCache settingCache, string referer)
{
byte[] result;
WebResponse response;
var file = new ImageFile();
var request = (HttpWebRequest)WebRequest.Create(uri);
request.Referer = uri.Host;
request.Referer = referer;
request.Proxy = settingCache.Proxy;
request.Accept = "image/webp,*/*";

try
{
Expand All @@ -47,6 +48,11 @@ public static async Task<ImageFile> DownloadImage(Uri uri, MangaSettingCache set
}
catch (System.Exception ex)
{
if (!string.IsNullOrEmpty(uri.Query))
{
uri = new Uri(uri.GetLeftPart(UriPartial.Path));
return await DownloadImage(uri, settingCache, referer);
}
Log.Exception(ex, string.Format($"Загрузка {uri} не завершена. Использованы настройки прокси {settingCache.SettingType}"));
return file;
}
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
На текущий момент поддерживаются:
1. [ReadManga](https://readmanga.live/)
2. [MintManga](https://mintmanga.live)
3. [Hentaichan](https://y.hentaichan.live/)
3. [Hentaichan](https://x.henchan.pro/)
4. [Acomics](https://acomics.ru)
5. [Mangachan](https://manga-chan.me/)
6. [Hentai2Read](https://hentai2read.com//)
Expand Down
2 changes: 0 additions & 2 deletions Sites/Grouple.ru/GroupleMangaPage.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using MangaReader.Core.Manga;

namespace Grouple
Expand Down
4 changes: 2 additions & 2 deletions Sites/Grouple.ru/GroupleParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public override async Task UpdatePages(Chapter groupleChapter)
if (node == null)
return;

var initBlock = Regex.Match(node.OuterHtml, @"rm_h\.initReader\(.*?(\[\[.*?\]\])", RegexOptions.IgnoreCase);
var initBlock = Regex.Match(node.OuterHtml, @"rm_h\.readerInit\(.*?(\[\[.*?\]\])", RegexOptions.IgnoreCase);
var jsonParsed = JToken.Parse(initBlock.Groups[1].Value).Children().ToList();
for (var i = 0; i < jsonParsed.Count; i++)
{
Expand Down Expand Up @@ -175,7 +175,7 @@ public override async Task UpdateContent(IManga manga)
document.LoadHtml(page.Content);
hasCopyrightNotice = Copyrights.Any(c => document.DocumentNode.InnerText.Contains(c));
var linkNodes = document.DocumentNode
.SelectNodes("//div[@class=\"expandable chapters-link\"]//a[contains(@class, 'chapter-link')]")
.SelectNodes("//div[@class=\"chapters-link chapters\"]//a[contains(@class, 'chapter-link')]")
.Reverse()
.ToList();
links = linkNodes
Expand Down
6 changes: 5 additions & 1 deletion Sites/Hentai2Read.com/Hentai2ReadParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ public override async Task UpdateNameAndStatus(IManga manga)
var client = await Hentai2ReadPlugin.Instance.GetCookieClient(true).ConfigureAwait(false);
var document = new HtmlDocument();
document.LoadHtml((await client.GetPage(manga.Uri).ConfigureAwait(false)).Content);
var nameNode = document.DocumentNode.SelectSingleNode("//span[@itemprop=\"name\"]");
var nameNode = document.DocumentNode
.SelectNodes("//div[@itemtype=\"http://schema.org/Book\"]")
.Single()
.SelectNodes(".//span[@itemprop=\"name\"]")
.Single();
if (nameNode != null)
{
var name = WebUtility.HtmlDecode(nameNode.InnerText);
Expand Down
2 changes: 1 addition & 1 deletion Sites/Hentaichan.me/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ namespace Hentaichan
{
public static class Constants
{
public const string HentaichanHost = "https://y.hentaichan.live/";
public const string HentaichanHost = "https://x.henchan.pro/";
}
}
36 changes: 36 additions & 0 deletions Sites/Hentaichan.me/Convertation/HentaichanFrom51_8To51_9.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MangaReader.Core.Convertation;
using MangaReader.Core.Convertation.Primitives;
using MangaReader.Core.NHibernate;
using MangaReader.Core.Services.Config;

namespace Hentaichan.me.Convertation
{
internal class HentaichanFrom51_8To51_9 : ConfigConverter
{
protected override async Task ProtectedConvert(IProcess process)
{
using (var context = Repository.GetEntityContext())
{
var setting = ConfigStorage.GetPlugin<Hentaichan>().GetSettings();
var mainUri = new Uri("https://x.henchan.pro/");
if (setting != null)
{
setting.MainUri = mainUri;
await context.Save(setting).ConfigureAwait(false);
}
}
}

public HentaichanFrom51_8To51_9()
{
this.Version = new Version(1, 51, 9, 39);
this.CanReportProcess = false;
this.Name = "Обновляем ссылки на x.henchan.pro...";
}
}
}
1 change: 1 addition & 0 deletions Tests/Tests.Entities/Builder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public static async Task<MangaInfo> Generate(InfoCacheAttribute cacheAttribute)

info.Status = manga.Status;
info.Description = manga.Description;
info.Name = manga.Name;

return info;
}
Expand Down
Loading

0 comments on commit c6b1b09

Please sign in to comment.