Skip to content

Commit b3d96de

Browse files
author
0rga-n1ce
committed
Mirror Fix / Removed Newtonsoft
* The mirror libgen.gs has been removed for now, since it doesn't allow API calls without a key * Switched from Newtonsoft.Json to System.Text.Json
1 parent 13af840 commit b3d96de

File tree

5 files changed

+5
-21
lines changed

5 files changed

+5
-21
lines changed

LibHandler/LibHandler.cs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using LibHandler.Models;
22
using LibHandler.Util;
3-
using Newtonsoft.Json;
3+
using System.Text.Json;
44

55
namespace LibHandler
66
{
@@ -49,9 +49,8 @@ public static List<Book> GetBooks(string request)
4949
{
5050
List<string> ids = GetIDs(request);
5151
string jsonData = GetJSONData(ids);
52-
return JsonConvert.DeserializeObject<List<Book>>(jsonData) ?? new List<Book>();
52+
return JsonSerializer.Deserialize<List<Book>>(jsonData) ?? new List<Book>();
5353
}
54-
5554
/// <summary>
5655
/// Returns the current mirror.
5756
/// </summary>

LibHandler/LibHandler.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
<ItemGroup>
3434
<PackageReference Include="HtmlAgilityPack" Version="1.11.46" />
35-
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
3635
</ItemGroup>
3736

3837
</Project>

LibHandler/Resources/mirrors.json

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,6 @@
44
"FullUrl": "https://libgen.is",
55
"DownloadUrl": "http://library.lol/"
66
},
7-
{
8-
"Url": "libgen.gs",
9-
"FullUrl": "https://libgen.gs",
10-
"DownloadUrl": "http://library.lol/"
11-
},
127
{
138
"Url": "libgen.rs",
149
"FullUrl": "https://libgen.rs",

LibHandler/Util/DataHandler.cs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Reflection;
5-
using System.Text;
6-
using System.Threading.Tasks;
7-
8-
namespace LibHandler.Util
1+
namespace LibHandler.Util
92
{
103
internal static class DataHandler
114
{

LibHandler/Util/MirrorHandler.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using Newtonsoft.Json;
2-
using System.Linq;
3-
using System.Text.Json;
1+
using System.Text.Json;
42
using System.Net.NetworkInformation;
53
using System.Reflection;
64

@@ -35,7 +33,7 @@ static MirrorHandler()
3533

3634
//string config = File.ReadAllText(DataHandler.MIRROR_CONFIG_PATH);
3735
string config = reader.ReadToEnd();
38-
Mirrors = JsonConvert.DeserializeObject<List<Mirror>>(config) ?? new List<Mirror>();
36+
Mirrors = JsonSerializer.Deserialize<List<Mirror>>(config) ?? new List<Mirror>();
3937

4038
MainMirror = new Mirror();
4139
MainMirror = GetMainMirror();

0 commit comments

Comments
 (0)