Compare commits
No commits in common. "0b9948e3671f978613165eec3de6333c5ea5b6f2" and "a94186455b44071a6c005548b02e1c2dd622db85" have entirely different histories.
0b9948e367
...
a94186455b
@ -67,7 +67,7 @@ public struct Manga
|
||||
while (this.folderName.EndsWith('.'))
|
||||
this.folderName = this.folderName.Substring(0, this.folderName.Length - 1);
|
||||
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.latestChapterDownloaded = 0;
|
||||
this.latestChapterAvailable = 0;
|
||||
|
@ -1,6 +1,4 @@
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Tranga.MangaConnectors;
|
||||
@ -24,22 +22,29 @@ public class MangaConnectorJsonConverter : JsonConverter
|
||||
public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
|
||||
{
|
||||
JObject jo = JObject.Load(reader);
|
||||
string? connectorName = jo.Value<string>("name");
|
||||
if (connectorName is null)
|
||||
throw new ConstraintException("Name can not be null.");
|
||||
return connectorName switch
|
||||
switch (jo.GetValue("name")!.Value<string>()!)
|
||||
{
|
||||
"MangaDex" => this._connectors.First(c => c is MangaDex),
|
||||
"Manganato" => this._connectors.First(c => c is Manganato),
|
||||
"MangaKatana" => this._connectors.First(c => c is MangaKatana),
|
||||
"Mangasee" => this._connectors.First(c => c is Mangasee),
|
||||
"Mangaworld" => this._connectors.First(c => c is Mangaworld),
|
||||
"Bato" => this._connectors.First(c => c is Bato),
|
||||
"Manga4Life" => this._connectors.First(c => c is MangaLife),
|
||||
"ManhuaPlus" => this._connectors.First(c => c is ManhuaPlus),
|
||||
"MangaHere" => this._connectors.First(c => c is MangaHere),
|
||||
_ => throw new UnreachableException($"Could not find Connector with name {connectorName}")
|
||||
};
|
||||
case "MangaDex":
|
||||
return this._connectors.First(c => c is MangaDex);
|
||||
case "Manganato":
|
||||
return this._connectors.First(c => c is Manganato);
|
||||
case "MangaKatana":
|
||||
return this._connectors.First(c => c is MangaKatana);
|
||||
case "Mangasee":
|
||||
return this._connectors.First(c => c is Mangasee);
|
||||
case "Mangaworld":
|
||||
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;
|
||||
|
@ -243,7 +243,7 @@ public class MangaDex : MangaConnector
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -63,11 +63,10 @@ public class Server : GlobalBase
|
||||
{
|
||||
HttpListenerRequest request = context.Request;
|
||||
HttpListenerResponse response = context.Response;
|
||||
if(request.HttpMethod == "OPTIONS")
|
||||
SendResponse(HttpStatusCode.OK, context.Response);
|
||||
if(request.Url!.LocalPath.Contains("favicon"))
|
||||
{
|
||||
SendResponse(HttpStatusCode.NoContent, response);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (request.HttpMethod)
|
||||
{
|
||||
@ -80,9 +79,6 @@ public class Server : GlobalBase
|
||||
case "DELETE":
|
||||
HandleDelete(request, response);
|
||||
break;
|
||||
case "OPTIONS":
|
||||
SendResponse(HttpStatusCode.OK, context.Response);
|
||||
break;
|
||||
default:
|
||||
SendResponse(HttpStatusCode.BadRequest, response);
|
||||
break;
|
||||
@ -711,15 +707,14 @@ public class Server : GlobalBase
|
||||
private void SendResponse(HttpStatusCode statusCode, HttpListenerResponse response, object? content = null)
|
||||
{
|
||||
//Log($"Response: {statusCode} {content}");
|
||||
|
||||
response.StatusCode = (int)statusCode;
|
||||
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-Max-Age", "1728000");
|
||||
response.AppendHeader("Access-Control-Allow-Origin", "*");
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (content is not Stream)
|
||||
{
|
||||
response.ContentType = "application/json";
|
||||
@ -755,7 +750,7 @@ public class Server : GlobalBase
|
||||
stream.Close();
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
catch (HttpListenerException e)
|
||||
{
|
||||
Log(e.ToString());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user