Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
immisterio committed Nov 20, 2023
1 parent 7c9a564 commit b9b870b
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 24 deletions.
14 changes: 12 additions & 2 deletions JacRed/ModInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,26 @@ public static ModInit conf

if (cacheconf.Item2 != lastWriteTime)
{
var jss = new JsonSerializerSettings { Error = (se, ev) =>
{
ev.ErrorContext.Handled = true;
Console.WriteLine("module/JacRed.conf - " + ev.ErrorContext.Error + "\n\n");
}};

string json = File.ReadAllText("module/JacRed.conf");

if (json.Contains("\"version\""))
{
cacheconf.Item1 = JsonConvert.DeserializeObject<ModInit>(json);
cacheconf.Item1 = JsonConvert.DeserializeObject<ModInit>(json, jss);
}
else
{
cacheconf.Item1 = new ModInit() { Red = JsonConvert.DeserializeObject<RedConf>(json) };
cacheconf.Item1 = new ModInit() { Red = JsonConvert.DeserializeObject<RedConf>(json, jss) };
}

if (cacheconf.Item1 == null)
cacheconf.Item1 = new ModInit();

cacheconf.Item2 = lastWriteTime;
}

Expand Down
2 changes: 1 addition & 1 deletion Online/OnlineApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ async Task checkSearch(ConcurrentBag<(string code, int index, bool work)> links,

string res = await HttpClient.Get($"http://{AppInit.conf.localhost}:{AppInit.conf.listenport}/lite/{uri}{(uri.Contains("?") ? "&" : "?")}id={id}&imdb_id={imdb_id}&kinopoisk_id={kinopoisk_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&original_language={original_language}&source={source}&year={year}&serial={serial}&account_email={HttpUtility.UrlEncode(account_email)}&checksearch=true", timeoutSeconds: 10, addHeaders: new List<(string name, string val)>()
{
("Host", host)
("xhost", host)
});

bool work = !string.IsNullOrWhiteSpace(res) && res.Contains("data-json=");
Expand Down
4 changes: 3 additions & 1 deletion SISI/BookmarkController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,15 @@ string getvideLink(PlaylistItem pl)
return $"{host}/{pl.bookmark.site}/vidosik?uri={HttpUtility.UrlEncode(pl.bookmark.href)}";
}

string localhost = $"http://{AppInit.conf.localhost}:{AppInit.conf.listenport}";

return new JsonResult(new
{
list = bookmarks.Skip((pg * pageSize) - pageSize).Take(pageSize).Select(pl => new
{
pl.name,
video = getvideLink(pl),
picture = HostImgProxy(0, AppInit.conf.sisi.heightPicture, pl.bookmark.image.StartsWith("bookmarks/") ? $"{host}/{pl.bookmark.image}" : pl.bookmark.image),
picture = HostImgProxy(0, AppInit.conf.sisi.heightPicture, pl.bookmark.image.StartsWith("bookmarks/") ? $"{localhost}/{pl.bookmark.image}" : pl.bookmark.image),
pl.time,
pl.json,
pl.quality,
Expand Down
35 changes: 31 additions & 4 deletions Shared/AppInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,16 @@ public static AppInit conf

if (cacheconf.Item2 != lastWriteTime)
{
cacheconf.Item1 = JsonConvert.DeserializeObject<AppInit>(File.ReadAllText("init.conf"));
var jss = new JsonSerializerSettings { Error = (se, ev) =>
{
ev.ErrorContext.Handled = true;
Console.WriteLine("init.conf - " + ev.ErrorContext.Error + "\n\n");
}};

cacheconf.Item1 = JsonConvert.DeserializeObject<AppInit>(File.ReadAllText("init.conf"), jss);
if (cacheconf.Item1 == null)
cacheconf.Item1 = new AppInit();

cacheconf.Item2 = lastWriteTime;

if (cacheconf.Item1 != null)
Expand Down Expand Up @@ -71,7 +80,16 @@ public static AppInit conf
}
}

public static string Host(HttpContext httpContext) => $"{httpContext.Request.Scheme}://{(string.IsNullOrWhiteSpace(conf.listenhost) ? httpContext.Request.Host.Value : conf.listenhost)}";
public static string Host(HttpContext httpContext)
{
if (!string.IsNullOrWhiteSpace(conf.listenhost))
return $"{httpContext.Request.Scheme}://{conf.listenhost}";

if (httpContext.Request.Headers.TryGetValue("xhost", out var xhost))
return $"{httpContext.Request.Scheme}://{xhost}";

return $"{httpContext.Request.Scheme}://{httpContext.Request.Host.Value}";
}
#endregion

#region modules
Expand All @@ -81,9 +99,18 @@ static AppInit()
{
if (File.Exists("module/manifest.json"))
{
modules = new List<RootModule>();
var jss = new JsonSerializerSettings { Error = (se, ev) =>
{
ev.ErrorContext.Handled = true;
Console.WriteLine("module/manifest.json - " + ev.ErrorContext.Error + "\n\n");
}};

foreach (var mod in JsonConvert.DeserializeObject<List<RootModule>>(File.ReadAllText("module/manifest.json")))
var mods = JsonConvert.DeserializeObject<List<RootModule>>(File.ReadAllText("module/manifest.json"), jss);
if (mods == null)
return;

modules = new List<RootModule>();
foreach (var mod in mods)
{
if (!mod.enable || mod.dll == "Jackett.dll")
continue;
Expand Down
2 changes: 1 addition & 1 deletion Shared/Engine/BaseController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public class BaseController : Controller, IDisposable
{
IServiceScope serviceScope;

public static string appversion => "86";
public static string appversion => "87";

public IMemoryCache memoryCache { get; private set; }

Expand Down
29 changes: 14 additions & 15 deletions TorrServer/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,28 +149,27 @@ async public Task TorAPI()
return;
}

using (HttpClient client = new HttpClient())
{
client.Timeout = TimeSpan.FromSeconds(15);
MemoryStream mem = new MemoryStream();
await HttpContext.Request.Body.CopyToAsync(mem);
string requestJson = Encoding.UTF8.GetString(mem.ToArray());

#region Данные запроса
MemoryStream mem = new MemoryStream();
await HttpContext.Request.Body.CopyToAsync(mem);
string requestJson = Encoding.UTF8.GetString(mem.ToArray());
#endregion
if (requestJson.Contains("\"get\""))
{
using (HttpClient client = new HttpClient())
{
client.Timeout = TimeSpan.FromSeconds(15);
client.DefaultRequestHeaders.Add("Authorization", $"Basic {Engine.CORE.CrypTo.Base64($"ts:{ModInit.tspass}")}");

var response = await client.PostAsync($"http://127.0.0.1:{ModInit.tsport}/settings", new StringContent("{\"action\":\"get\"}", Encoding.UTF8, "application/json"));
string settingsJson = await response.Content.ReadAsStringAsync();
var response = await client.PostAsync($"http://127.0.0.1:{ModInit.tsport}/settings", new StringContent("{\"action\":\"get\"}", Encoding.UTF8, "application/json"));
string settingsJson = await response.Content.ReadAsStringAsync();

if (requestJson.Trim() == "{\"action\":\"get\"}")
{
await HttpContext.Response.WriteAsync(settingsJson);
return;
}

await HttpContext.Response.WriteAsync(string.Empty);
return;
}

await HttpContext.Response.WriteAsync(string.Empty);
return;
}
#endregion

Expand Down

0 comments on commit b9b870b

Please sign in to comment.