Compare commits
No commits in common. "172650e64448130919b28cd7398cbdb38342254a" and "8316ed08a78d87099ac3d5cf30fece8cf0e68925" have entirely different histories.
172650e644
...
8316ed08a7
@ -2,10 +2,9 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>12</LangVersion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
10
Dockerfile
10
Dockerfile
@ -1,7 +1,7 @@
|
|||||||
# syntax=docker/dockerfile:1
|
# syntax=docker/dockerfile:1
|
||||||
ARG DOTNET=8.0
|
ARG DOTNET=7.0
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/runtime:$DOTNET AS base
|
FROM mcr.microsoft.com/dotnet/runtime:$DOTNET AS base
|
||||||
WORKDIR /publish
|
WORKDIR /publish
|
||||||
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
ENV PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=true
|
||||||
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
ENV PUPPETEER_EXECUTABLE_PATH=/usr/bin/chromium
|
||||||
@ -10,7 +10,7 @@ RUN apt-get update \
|
|||||||
&& apt-get autopurge -y \
|
&& apt-get autopurge -y \
|
||||||
&& apt-get autoclean -y
|
&& apt-get autoclean -y
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM mcr.microsoft.com/dotnet/sdk:$DOTNET AS build-env
|
FROM mcr.microsoft.com/dotnet/sdk:$DOTNET AS build-env
|
||||||
WORKDIR /src
|
WORKDIR /src
|
||||||
|
|
||||||
COPY Tranga.sln /src
|
COPY Tranga.sln /src
|
||||||
@ -20,9 +20,9 @@ COPY Tranga/Tranga.csproj /src/Tranga/Tranga.csproj
|
|||||||
RUN dotnet restore /src/Tranga.sln
|
RUN dotnet restore /src/Tranga.sln
|
||||||
|
|
||||||
COPY . /src/
|
COPY . /src/
|
||||||
RUN dotnet publish -c Release --property:OutputPath=/publish -maxcpucount:1
|
RUN dotnet publish -c Release -o /publish -maxcpucount:1
|
||||||
|
|
||||||
FROM --platform=$BUILDPLATFORM base AS runtime
|
FROM base AS runtime
|
||||||
EXPOSE 6531
|
EXPOSE 6531
|
||||||
ARG UNAME=tranga
|
ARG UNAME=tranga
|
||||||
ARG UID=1000
|
ARG UID=1000
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<LangVersion>12</LangVersion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -58,24 +58,29 @@ public readonly struct Chapter : IComparable
|
|||||||
|
|
||||||
public int CompareTo(object? obj)
|
public int CompareTo(object? obj)
|
||||||
{
|
{
|
||||||
if(obj is not Chapter otherChapter)
|
if (obj is Chapter otherChapter)
|
||||||
throw new ArgumentException($"{obj} can not be compared to {this}");
|
|
||||||
|
|
||||||
if (float.TryParse(volumeNumber, GlobalBase.numberFormatDecimalPoint, out float volumeNumberFloat) &&
|
|
||||||
float.TryParse(chapterNumber, GlobalBase.numberFormatDecimalPoint, out float chapterNumberFloat) &&
|
|
||||||
float.TryParse(otherChapter.volumeNumber, GlobalBase.numberFormatDecimalPoint,
|
|
||||||
out float otherVolumeNumberFloat) &&
|
|
||||||
float.TryParse(otherChapter.chapterNumber, GlobalBase.numberFormatDecimalPoint,
|
|
||||||
out float otherChapterNumberFloat))
|
|
||||||
{
|
{
|
||||||
return volumeNumberFloat.CompareTo(otherVolumeNumberFloat) switch
|
if (float.TryParse(volumeNumber, GlobalBase.numberFormatDecimalPoint, out float volumeNumberFloat) &&
|
||||||
|
float.TryParse(chapterNumber, GlobalBase.numberFormatDecimalPoint, out float chapterNumberFloat) &&
|
||||||
|
float.TryParse(otherChapter.volumeNumber, GlobalBase.numberFormatDecimalPoint,
|
||||||
|
out float otherVolumeNumberFloat) &&
|
||||||
|
float.TryParse(otherChapter.chapterNumber, GlobalBase.numberFormatDecimalPoint,
|
||||||
|
out float otherChapterNumberFloat))
|
||||||
{
|
{
|
||||||
<0 => -1,
|
|
||||||
>0 => 1,
|
switch (volumeNumberFloat.CompareTo(otherVolumeNumberFloat))
|
||||||
_ => chapterNumberFloat.CompareTo(otherChapterNumberFloat)
|
{
|
||||||
};
|
case < 0:
|
||||||
|
return -1;
|
||||||
|
case > 0:
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
return chapterNumberFloat.CompareTo(otherChapterNumberFloat);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else throw new FormatException($"Value could not be parsed");
|
||||||
}
|
}
|
||||||
else throw new FormatException($"Value could not be parsed");
|
throw new ArgumentException($"{obj} can not be compared to {this}");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -148,7 +148,7 @@ public class JobBoss : GlobalBase
|
|||||||
Regex idRex = new (@"(.*)\.json");
|
Regex idRex = new (@"(.*)\.json");
|
||||||
|
|
||||||
//Load json-job-files
|
//Load json-job-files
|
||||||
foreach (FileInfo file in new DirectoryInfo(TrangaSettings.jobsFolderPath).EnumerateFiles().Where(fileInfo => idRex.IsMatch(fileInfo.Name)))
|
foreach (FileInfo file in new DirectoryInfo(TrangaSettings.jobsFolderPath).EnumerateFiles().Where(fileInfo => idRex.IsMatch(fileInfo.Name)))
|
||||||
{
|
{
|
||||||
Log($"Adding {file.Name}");
|
Log($"Adding {file.Name}");
|
||||||
Job? job = JsonConvert.DeserializeObject<Job>(File.ReadAllText(file.FullName),
|
Job? job = JsonConvert.DeserializeObject<Job>(File.ReadAllText(file.FullName),
|
||||||
@ -163,7 +163,6 @@ public class JobBoss : GlobalBase
|
|||||||
{
|
{
|
||||||
Log($"Adding Job {job}");
|
Log($"Adding Job {job}");
|
||||||
this.jobs.Add(job);
|
this.jobs.Add(job);
|
||||||
UpdateJobFile(job, file.Name);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -189,26 +188,22 @@ public class JobBoss : GlobalBase
|
|||||||
internal void UpdateJobFile(Job job, string? oldFile = null)
|
internal void UpdateJobFile(Job job, string? oldFile = null)
|
||||||
{
|
{
|
||||||
string newJobFilePath = Path.Join(TrangaSettings.jobsFolderPath, $"{job.id}.json");
|
string newJobFilePath = Path.Join(TrangaSettings.jobsFolderPath, $"{job.id}.json");
|
||||||
string oldFilePath = Path.Join(TrangaSettings.jobsFolderPath, oldFile??$"{job.id}.json");
|
|
||||||
|
if (!this.jobs.Any(jjob => jjob.id == job.id))
|
||||||
//Delete old file
|
|
||||||
if (File.Exists(oldFilePath))
|
|
||||||
{
|
{
|
||||||
Log($"Deleting Job-file {oldFilePath}");
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
while(IsFileInUse(oldFilePath))
|
Log($"Deleting Job-file {newJobFilePath}");
|
||||||
|
while(IsFileInUse(newJobFilePath))
|
||||||
Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
File.Delete(oldFilePath);
|
File.Delete(newJobFilePath);
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log(e.ToString());
|
Log(e.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
//Export job (in new file) if it is still in our jobs list
|
|
||||||
if (GetJobById(job.id) is not null)
|
|
||||||
{
|
{
|
||||||
Log($"Exporting Job {newJobFilePath}");
|
Log($"Exporting Job {newJobFilePath}");
|
||||||
string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented);
|
string jobStr = JsonConvert.SerializeObject(job, Formatting.Indented);
|
||||||
@ -216,6 +211,19 @@ public class JobBoss : GlobalBase
|
|||||||
Thread.Sleep(10);
|
Thread.Sleep(10);
|
||||||
File.WriteAllText(newJobFilePath, jobStr);
|
File.WriteAllText(newJobFilePath, jobStr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(oldFile is not null)
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Log($"Deleting old Job-file {oldFile}");
|
||||||
|
while(IsFileInUse(oldFile))
|
||||||
|
Thread.Sleep(10);
|
||||||
|
File.Delete(oldFile);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Log(e.ToString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateAllJobFiles()
|
private void UpdateAllJobFiles()
|
||||||
|
@ -67,7 +67,7 @@ public struct Manga
|
|||||||
while (this.folderName.EndsWith('.'))
|
while (this.folderName.EndsWith('.'))
|
||||||
this.folderName = this.folderName.Substring(0, this.folderName.Length - 1);
|
this.folderName = this.folderName.Substring(0, this.folderName.Length - 1);
|
||||||
string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter));
|
string onlyLowerLetters = string.Concat(this.sortName.ToLower().Where(Char.IsLetter));
|
||||||
this.internalId = DateTime.Now.Ticks.ToString();
|
this.internalId = Convert.ToBase64String(Encoding.ASCII.GetBytes($"{onlyLowerLetters}{this.year}"));
|
||||||
this.ignoreChaptersBelow = ignoreChaptersBelow ?? 0f;
|
this.ignoreChaptersBelow = ignoreChaptersBelow ?? 0f;
|
||||||
this.latestChapterDownloaded = 0;
|
this.latestChapterDownloaded = 0;
|
||||||
this.latestChapterAvailable = 0;
|
this.latestChapterAvailable = 0;
|
||||||
|
@ -8,7 +8,7 @@ namespace Tranga.MangaConnectors;
|
|||||||
public class Bato : MangaConnector
|
public class Bato : MangaConnector
|
||||||
{
|
{
|
||||||
|
|
||||||
public Bato(GlobalBase clone) : base(clone, "Bato", ["en"])
|
public Bato(GlobalBase clone) : base(clone, "Bato")
|
||||||
{
|
{
|
||||||
this.downloadClient = new HttpDownloadClient(clone);
|
this.downloadClient = new HttpDownloadClient(clone);
|
||||||
}
|
}
|
||||||
|
@ -8,12 +8,14 @@ namespace Tranga.MangaConnectors;
|
|||||||
|
|
||||||
internal class ChromiumDownloadClient : DownloadClient
|
internal class ChromiumDownloadClient : DownloadClient
|
||||||
{
|
{
|
||||||
private static readonly IBrowser Browser = StartBrowser().Result;
|
private IBrowser browser { get; set; }
|
||||||
private const int StartTimeoutMs = 10000;
|
private const string ChromiumVersion = "1154303";
|
||||||
|
private const int StartTimeoutMs = 30000;
|
||||||
private readonly HttpDownloadClient _httpDownloadClient;
|
private readonly HttpDownloadClient _httpDownloadClient;
|
||||||
|
|
||||||
private static async Task<IBrowser> StartBrowser()
|
private async Task<IBrowser> StartBrowser()
|
||||||
{
|
{
|
||||||
|
Log($"Starting Browser. ({StartTimeoutMs}ms timeout)");
|
||||||
return await Puppeteer.LaunchAsync(new LaunchOptions
|
return await Puppeteer.LaunchAsync(new LaunchOptions
|
||||||
{
|
{
|
||||||
Headless = true,
|
Headless = true,
|
||||||
@ -28,6 +30,7 @@ internal class ChromiumDownloadClient : DownloadClient
|
|||||||
|
|
||||||
public ChromiumDownloadClient(GlobalBase clone) : base(clone)
|
public ChromiumDownloadClient(GlobalBase clone) : base(clone)
|
||||||
{
|
{
|
||||||
|
this.browser = StartBrowser().Result;
|
||||||
_httpDownloadClient = new(this);
|
_httpDownloadClient = new(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -41,7 +44,7 @@ internal class ChromiumDownloadClient : DownloadClient
|
|||||||
|
|
||||||
private RequestResult MakeRequestBrowser(string url, string? referrer = null, string? clickButton = null)
|
private RequestResult MakeRequestBrowser(string url, string? referrer = null, string? clickButton = null)
|
||||||
{
|
{
|
||||||
IPage page = Browser.NewPageAsync().Result;
|
IPage page = this.browser.NewPageAsync().Result;
|
||||||
page.DefaultTimeout = 10000;
|
page.DefaultTimeout = 10000;
|
||||||
IResponse response;
|
IResponse response;
|
||||||
try
|
try
|
||||||
@ -52,7 +55,6 @@ internal class ChromiumDownloadClient : DownloadClient
|
|||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
Log($"Could not load Page:\n{e.Message}");
|
Log($"Could not load Page:\n{e.Message}");
|
||||||
page.CloseAsync();
|
|
||||||
return new RequestResult(HttpStatusCode.InternalServerError, null, Stream.Null);
|
return new RequestResult(HttpStatusCode.InternalServerError, null, Stream.Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -83,4 +85,9 @@ internal class ChromiumDownloadClient : DownloadClient
|
|||||||
page.CloseAsync();
|
page.CloseAsync();
|
||||||
return new RequestResult(response.Status, document, stream, false, "");
|
return new RequestResult(response.Status, document, stream, false, "");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Close()
|
||||||
|
{
|
||||||
|
this.browser.CloseAsync();
|
||||||
|
}
|
||||||
}
|
}
|
@ -41,4 +41,5 @@ internal abstract class DownloadClient : GlobalBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal abstract RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null);
|
internal abstract RequestResult MakeRequestInternal(string url, string? referrer = null, string? clickButton = null);
|
||||||
|
public abstract void Close();
|
||||||
}
|
}
|
@ -72,4 +72,9 @@ internal class HttpDownloadClient : DownloadClient
|
|||||||
|
|
||||||
return new RequestResult(response.StatusCode, document, stream);
|
return new RequestResult(response.StatusCode, document, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void Close()
|
||||||
|
{
|
||||||
|
Log("Closing.");
|
||||||
|
}
|
||||||
}
|
}
|
@ -14,12 +14,15 @@ namespace Tranga.MangaConnectors;
|
|||||||
public abstract class MangaConnector : GlobalBase
|
public abstract class MangaConnector : GlobalBase
|
||||||
{
|
{
|
||||||
internal DownloadClient downloadClient { get; init; } = null!;
|
internal DownloadClient downloadClient { get; init; } = null!;
|
||||||
public string[] SupportedLanguages;
|
|
||||||
|
|
||||||
protected MangaConnector(GlobalBase clone, string name, string[] supportedLanguages) : base(clone)
|
public void StopDownloadClient()
|
||||||
|
{
|
||||||
|
downloadClient.Close();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected MangaConnector(GlobalBase clone, string name) : base(clone)
|
||||||
{
|
{
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.SupportedLanguages = supportedLanguages;
|
|
||||||
Directory.CreateDirectory(TrangaSettings.coverImageCache);
|
Directory.CreateDirectory(TrangaSettings.coverImageCache);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,10 +234,7 @@ public abstract class MangaConnector : GlobalBase
|
|||||||
Directory.CreateDirectory(directoryPath);
|
Directory.CreateDirectory(directoryPath);
|
||||||
|
|
||||||
if (File.Exists(saveArchiveFilePath)) //Don't download twice.
|
if (File.Exists(saveArchiveFilePath)) //Don't download twice.
|
||||||
{
|
|
||||||
progressToken?.Complete();
|
|
||||||
return HttpStatusCode.Created;
|
return HttpStatusCode.Created;
|
||||||
}
|
|
||||||
|
|
||||||
//Create a temporary folder to store images
|
//Create a temporary folder to store images
|
||||||
string tempFolder = Directory.CreateTempSubdirectory("trangatemp").FullName;
|
string tempFolder = Directory.CreateTempSubdirectory("trangatemp").FullName;
|
||||||
|
@ -1,6 +1,4 @@
|
|||||||
using System.Data;
|
using Newtonsoft.Json;
|
||||||
using System.Diagnostics;
|
|
||||||
using Newtonsoft.Json;
|
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
namespace Tranga.MangaConnectors;
|
namespace Tranga.MangaConnectors;
|
||||||
@ -24,22 +22,29 @@ public class MangaConnectorJsonConverter : JsonConverter
|
|||||||
public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
|
public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
|
||||||
{
|
{
|
||||||
JObject jo = JObject.Load(reader);
|
JObject jo = JObject.Load(reader);
|
||||||
string? connectorName = jo.Value<string>("name");
|
switch (jo.GetValue("name")!.Value<string>()!)
|
||||||
if (connectorName is null)
|
|
||||||
throw new ConstraintException("Name can not be null.");
|
|
||||||
return connectorName switch
|
|
||||||
{
|
{
|
||||||
"MangaDex" => this._connectors.First(c => c is MangaDex),
|
case "MangaDex":
|
||||||
"Manganato" => this._connectors.First(c => c is Manganato),
|
return this._connectors.First(c => c is MangaDex);
|
||||||
"MangaKatana" => this._connectors.First(c => c is MangaKatana),
|
case "Manganato":
|
||||||
"Mangasee" => this._connectors.First(c => c is Mangasee),
|
return this._connectors.First(c => c is Manganato);
|
||||||
"Mangaworld" => this._connectors.First(c => c is Mangaworld),
|
case "MangaKatana":
|
||||||
"Bato" => this._connectors.First(c => c is Bato),
|
return this._connectors.First(c => c is MangaKatana);
|
||||||
"Manga4Life" => this._connectors.First(c => c is MangaLife),
|
case "Mangasee":
|
||||||
"ManhuaPlus" => this._connectors.First(c => c is ManhuaPlus),
|
return this._connectors.First(c => c is Mangasee);
|
||||||
"MangaHere" => this._connectors.First(c => c is MangaHere),
|
case "Mangaworld":
|
||||||
_ => throw new UnreachableException($"Could not find Connector with name {connectorName}")
|
return this._connectors.First(c => c is Mangaworld);
|
||||||
};
|
case "Bato":
|
||||||
|
return this._connectors.First(c => c is Bato);
|
||||||
|
case "Manga4Life":
|
||||||
|
return this._connectors.First(c => c is MangaLife);
|
||||||
|
case "ManhuaPlus":
|
||||||
|
return this._connectors.First(c => c is ManhuaPlus);
|
||||||
|
case "MangaHere":
|
||||||
|
return this._connectors.First(c => c is MangaHere);
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new Exception();
|
||||||
}
|
}
|
||||||
|
|
||||||
public override bool CanWrite => false;
|
public override bool CanWrite => false;
|
||||||
|
@ -7,17 +7,14 @@ using JsonSerializer = System.Text.Json.JsonSerializer;
|
|||||||
namespace Tranga.MangaConnectors;
|
namespace Tranga.MangaConnectors;
|
||||||
public class MangaDex : MangaConnector
|
public class MangaDex : MangaConnector
|
||||||
{
|
{
|
||||||
//https://api.mangadex.org/docs/3-enumerations/#language-codes--localization
|
public MangaDex(GlobalBase clone) : base(clone, "MangaDex")
|
||||||
//https://en.wikipedia.org/wiki/List_of_ISO_639_language_codes
|
|
||||||
//https://gist.github.com/Josantonius/b455e315bc7f790d14b136d61d9ae469
|
|
||||||
public MangaDex(GlobalBase clone) : base(clone, "MangaDex", ["en","pt","pt-br","it","de","ru","aa","ab","ae","af","ak","am","an","ar-ae","ar-bh","ar-dz","ar-eg","ar-iq","ar-jo","ar-kw","ar-lb","ar-ly","ar-ma","ar-om","ar-qa","ar-sa","ar-sy","ar-tn","ar-ye","ar","as","av","ay","az","ba","be","bg","bh","bi","bm","bn","bo","br","bs","ca","ce","ch","co","cr","cs","cu","cv","cy","da","de-at","de-ch","de-de","de-li","de-lu","div","dv","dz","ee","el","en-au","en-bz","en-ca","en-cb","en-gb","en-ie","en-jm","en-nz","en-ph","en-tt","en-us","en-za","en-zw","eo","es-ar","es-bo","es-cl","es-co","es-cr","es-do","es-ec","es-es","es-gt","es-hn","es-la","es-mx","es-ni","es-pa","es-pe","es-pr","es-py","es-sv","es-us","es-uy","es-ve","es","et","eu","fa","ff","fi","fj","fo","fr-be","fr-ca","fr-ch","fr-fr","fr-lu","fr-mc","fr","fy","ga","gd","gl","gn","gu","gv","ha","he","hi","ho","hr-ba","hr-hr","hr","ht","hu","hy","hz","ia","id","ie","ig","ii","ik","in","io","is","it-ch","it-it","iu","iw","ja","ja-ro","ji","jv","jw","ka","kg","ki","kj","kk","kl","km","kn","ko","ko-ro","kr","ks","ku","kv","kw","ky","kz","la","lb","lg","li","ln","lo","ls","lt","lu","lv","mg","mh","mi","mk","ml","mn","mo","mr","ms-bn","ms-my","ms","mt","my","na","nb","nd","ne","ng","nl-be","nl-nl","nl","nn","no","nr","ns","nv","ny","oc","oj","om","or","os","pa","pi","pl","ps","pt-pt","qu-bo","qu-ec","qu-pe","qu","rm","rn","ro","rw","sa","sb","sc","sd","se-fi","se-no","se-se","se","sg","sh","si","sk","sl","sm","sn","so","sq","sr-ba","sr-sp","sr","ss","st","su","sv-fi","sv-se","sv","sw","sx","syr","ta","te","tg","th","ti","tk","tl","tn","to","tr","ts","tt","tw","ty","ug","uk","ur","us","uz","ve","vi","vo","wa","wo","xh","yi","yo","za","zh-cn","zh-hk","zh-mo","zh-ro","zh-sg","zh-tw","zh","zu"])
|
|
||||||
{
|
{
|
||||||
this.downloadClient = new HttpDownloadClient(clone);
|
this.downloadClient = new HttpDownloadClient(clone);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Manga[] GetManga(string publicationTitle = "")
|
public override Manga[] GetManga(string publicationTitle = "")
|
||||||
{
|
{
|
||||||
Log($"Searching Publications. Term={publicationTitle}");
|
Log($"Searching Publications. Term=\"{publicationTitle}\"");
|
||||||
const int limit = 100; //How many values we want returned at once
|
const int limit = 100; //How many values we want returned at once
|
||||||
int offset = 0; //"Page"
|
int offset = 0; //"Page"
|
||||||
int total = int.MaxValue; //How many total results are there, is updated on first request
|
int total = int.MaxValue; //How many total results are there, is updated on first request
|
||||||
@ -57,7 +54,7 @@ public class MangaDex : MangaConnector
|
|||||||
if(MangaFromJsonObject(mangaNode.AsObject()) is { } manga)
|
if(MangaFromJsonObject(mangaNode.AsObject()) is { } manga)
|
||||||
retManga.Add(manga); //Add Publication (Manga) to result
|
retManga.Add(manga); //Add Publication (Manga) to result
|
||||||
}
|
}
|
||||||
Log($"Retrieved {retManga.Count} publications. Term={publicationTitle}");
|
Log($"Retrieved {retManga.Count} publications. Term=\"{publicationTitle}\"");
|
||||||
return retManga.ToArray();
|
return retManga.ToArray();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +243,7 @@ public class MangaDex : MangaConnector
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(chapterNum is not "null" && !chapters.Any(chp => chp.volumeNumber.Equals(volume) && chp.chapterNumber.Equals(chapterNum)))
|
if(chapterNum is not "null")
|
||||||
chapters.Add(new Chapter(manga, title, volume, chapterNum, chapterId));
|
chapters.Add(new Chapter(manga, title, volume, chapterNum, chapterId));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace Tranga.MangaConnectors;
|
|||||||
|
|
||||||
public class MangaHere : MangaConnector
|
public class MangaHere : MangaConnector
|
||||||
{
|
{
|
||||||
public MangaHere(GlobalBase clone) : base(clone, "MangaHere", ["en"])
|
public MangaHere(GlobalBase clone) : base(clone, "MangaHere")
|
||||||
{
|
{
|
||||||
this.downloadClient = new ChromiumDownloadClient(clone);
|
this.downloadClient = new ChromiumDownloadClient(clone);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace Tranga.MangaConnectors;
|
|||||||
|
|
||||||
public class MangaKatana : MangaConnector
|
public class MangaKatana : MangaConnector
|
||||||
{
|
{
|
||||||
public MangaKatana(GlobalBase clone) : base(clone, "MangaKatana", ["en"])
|
public MangaKatana(GlobalBase clone) : base(clone, "MangaKatana")
|
||||||
{
|
{
|
||||||
this.downloadClient = new HttpDownloadClient(clone);
|
this.downloadClient = new HttpDownloadClient(clone);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace Tranga.MangaConnectors;
|
|||||||
|
|
||||||
public class MangaLife : MangaConnector
|
public class MangaLife : MangaConnector
|
||||||
{
|
{
|
||||||
public MangaLife(GlobalBase clone) : base(clone, "Manga4Life", ["en"])
|
public MangaLife(GlobalBase clone) : base(clone, "Manga4Life")
|
||||||
{
|
{
|
||||||
this.downloadClient = new ChromiumDownloadClient(clone);
|
this.downloadClient = new ChromiumDownloadClient(clone);
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ namespace Tranga.MangaConnectors;
|
|||||||
|
|
||||||
public class Manganato : MangaConnector
|
public class Manganato : MangaConnector
|
||||||
{
|
{
|
||||||
public Manganato(GlobalBase clone) : base(clone, "Manganato", ["en"])
|
public Manganato(GlobalBase clone) : base(clone, "Manganato")
|
||||||
{
|
{
|
||||||
this.downloadClient = new HttpDownloadClient(clone);
|
this.downloadClient = new HttpDownloadClient(clone);
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ namespace Tranga.MangaConnectors;
|
|||||||
|
|
||||||
public class Mangasee : MangaConnector
|
public class Mangasee : MangaConnector
|
||||||
{
|
{
|
||||||
public Mangasee(GlobalBase clone) : base(clone, "Mangasee", ["en"])
|
public Mangasee(GlobalBase clone) : base(clone, "Mangasee")
|
||||||
{
|
{
|
||||||
this.downloadClient = new ChromiumDownloadClient(clone);
|
this.downloadClient = new ChromiumDownloadClient(clone);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace Tranga.MangaConnectors;
|
|||||||
|
|
||||||
public class Mangaworld: MangaConnector
|
public class Mangaworld: MangaConnector
|
||||||
{
|
{
|
||||||
public Mangaworld(GlobalBase clone) : base(clone, "Mangaworld", ["it"])
|
public Mangaworld(GlobalBase clone) : base(clone, "Mangaworld")
|
||||||
{
|
{
|
||||||
this.downloadClient = new HttpDownloadClient(clone);
|
this.downloadClient = new HttpDownloadClient(clone);
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ namespace Tranga.MangaConnectors;
|
|||||||
|
|
||||||
public class ManhuaPlus : MangaConnector
|
public class ManhuaPlus : MangaConnector
|
||||||
{
|
{
|
||||||
public ManhuaPlus(GlobalBase clone) : base(clone, "ManhuaPlus", ["en"])
|
public ManhuaPlus(GlobalBase clone) : base(clone, "ManhuaPlus")
|
||||||
{
|
{
|
||||||
this.downloadClient = new ChromiumDownloadClient(clone);
|
this.downloadClient = new ChromiumDownloadClient(clone);
|
||||||
}
|
}
|
||||||
@ -82,31 +82,17 @@ public class ManhuaPlus : MangaConnector
|
|||||||
HtmlNode titleNode = document.DocumentNode.SelectSingleNode("//h1");
|
HtmlNode titleNode = document.DocumentNode.SelectSingleNode("//h1");
|
||||||
string sortName = titleNode.InnerText.Replace("\n", "");
|
string sortName = titleNode.InnerText.Replace("\n", "");
|
||||||
|
|
||||||
|
HtmlNode[] authorsNodes = document.DocumentNode
|
||||||
|
.SelectNodes("//a[contains(@href, 'https://manhuaplus.org/authors/')]")
|
||||||
|
.ToArray();
|
||||||
List<string> authors = new();
|
List<string> authors = new();
|
||||||
try
|
foreach (HtmlNode authorNode in authorsNodes)
|
||||||
{
|
authors.Add(authorNode.InnerText);
|
||||||
HtmlNode[] authorsNodes = document.DocumentNode
|
|
||||||
.SelectNodes("//a[contains(@href, 'https://manhuaplus.org/authors/')]")
|
|
||||||
.ToArray();
|
|
||||||
foreach (HtmlNode authorNode in authorsNodes)
|
|
||||||
authors.Add(authorNode.InnerText);
|
|
||||||
}
|
|
||||||
catch (ArgumentNullException e)
|
|
||||||
{
|
|
||||||
Log("No authors found.");
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
HtmlNode[] genreNodes = document.DocumentNode
|
||||||
{
|
.SelectNodes("//a[contains(@href, 'https://manhuaplus.org/genres/')]").ToArray();
|
||||||
HtmlNode[] genreNodes = document.DocumentNode
|
foreach (HtmlNode genreNode in genreNodes)
|
||||||
.SelectNodes("//a[contains(@href, 'https://manhuaplus.org/genres/')]").ToArray();
|
tags.Add(genreNode.InnerText.Replace("\n", ""));
|
||||||
foreach (HtmlNode genreNode in genreNodes)
|
|
||||||
tags.Add(genreNode.InnerText.Replace("\n", ""));
|
|
||||||
}
|
|
||||||
catch (ArgumentNullException e)
|
|
||||||
{
|
|
||||||
Log("No genres found");
|
|
||||||
}
|
|
||||||
|
|
||||||
string yearNodeStr = document.DocumentNode
|
string yearNodeStr = document.DocumentNode
|
||||||
.SelectSingleNode("//aside//i[contains(concat(' ',normalize-space(@class),' '),' fa-clock ')]/../span").InnerText.Replace("\n", "");
|
.SelectSingleNode("//aside//i[contains(concat(' ',normalize-space(@class),' '),' fa-clock ')]/../span").InnerText.Replace("\n", "");
|
||||||
|
@ -63,11 +63,10 @@ public class Server : GlobalBase
|
|||||||
{
|
{
|
||||||
HttpListenerRequest request = context.Request;
|
HttpListenerRequest request = context.Request;
|
||||||
HttpListenerResponse response = context.Response;
|
HttpListenerResponse response = context.Response;
|
||||||
if (request.Url!.LocalPath.Contains("favicon"))
|
if(request.HttpMethod == "OPTIONS")
|
||||||
{
|
SendResponse(HttpStatusCode.OK, context.Response);
|
||||||
|
if(request.Url!.LocalPath.Contains("favicon"))
|
||||||
SendResponse(HttpStatusCode.NoContent, response);
|
SendResponse(HttpStatusCode.NoContent, response);
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (request.HttpMethod)
|
switch (request.HttpMethod)
|
||||||
{
|
{
|
||||||
@ -80,10 +79,7 @@ public class Server : GlobalBase
|
|||||||
case "DELETE":
|
case "DELETE":
|
||||||
HandleDelete(request, response);
|
HandleDelete(request, response);
|
||||||
break;
|
break;
|
||||||
case "OPTIONS":
|
default:
|
||||||
SendResponse(HttpStatusCode.OK, context.Response);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
SendResponse(HttpStatusCode.BadRequest, response);
|
SendResponse(HttpStatusCode.BadRequest, response);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -711,15 +707,14 @@ public class Server : GlobalBase
|
|||||||
private void SendResponse(HttpStatusCode statusCode, HttpListenerResponse response, object? content = null)
|
private void SendResponse(HttpStatusCode statusCode, HttpListenerResponse response, object? content = null)
|
||||||
{
|
{
|
||||||
//Log($"Response: {statusCode} {content}");
|
//Log($"Response: {statusCode} {content}");
|
||||||
|
|
||||||
response.StatusCode = (int)statusCode;
|
response.StatusCode = (int)statusCode;
|
||||||
response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With");
|
response.AddHeader("Access-Control-Allow-Headers", "Content-Type, Accept, X-Requested-With");
|
||||||
response.AddHeader("Access-Control-Allow-Methods", "GET, POST, DELETE");
|
response.AddHeader("Access-Control-Allow-Methods", "GET, POST, DELETE");
|
||||||
response.AddHeader("Access-Control-Max-Age", "1728000");
|
response.AddHeader("Access-Control-Max-Age", "1728000");
|
||||||
response.AppendHeader("Access-Control-Allow-Origin", "*");
|
response.AppendHeader("Access-Control-Allow-Origin", "*");
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
if (content is not Stream)
|
if (content is not Stream)
|
||||||
{
|
{
|
||||||
response.ContentType = "application/json";
|
response.ContentType = "application/json";
|
||||||
@ -755,7 +750,7 @@ public class Server : GlobalBase
|
|||||||
stream.Close();
|
stream.Close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (HttpListenerException e)
|
||||||
{
|
{
|
||||||
Log(e.ToString());
|
Log(e.ToString());
|
||||||
}
|
}
|
||||||
|
@ -1,11 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net7.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<LangVersion>12</LangVersion>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
Loading…
Reference in New Issue
Block a user