Skip to content

Commit

Permalink
dev
Browse files Browse the repository at this point in the history
  • Loading branch information
immisterio committed Feb 10, 2023
1 parent d77979f commit c66ae61
Show file tree
Hide file tree
Showing 13 changed files with 108 additions and 67 deletions.
2 changes: 2 additions & 0 deletions AppInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ public static AppInit conf

public MerchantsModel Merchant = new MerchantsModel();

public HashSet<Known> KnownProxies { get; set; }

public JacConf jac = new JacConf();


Expand Down
128 changes: 65 additions & 63 deletions Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -347,110 +347,112 @@ async public Task<ActionResult> Events(long id, string imdb_id, long kinopoisk_i
string online = string.Empty;
bool isanime = original_language == "ja";

if (!life && AppInit.conf.jac.litejac)
var conf = AppInit.conf;

if (!life && conf.jac.litejac)
online += "{\"name\":\"Jackett\",\"url\":\"{localhost}/jac\"},";

if (!string.IsNullOrWhiteSpace(AppInit.conf.VoKino.token) && (serial == -1 || serial == 0))
online += "{\"name\":\"VoKino\",\"url\":\"{localhost}/vokino\"},";
if (!string.IsNullOrWhiteSpace(conf.VoKino.token) && (serial == -1 || serial == 0))
online += "{\"name\":\"" + (conf.VoKino.displayname ?? "VoKino") + "\",\"url\":\"{localhost}/vokino\"},";

if (!string.IsNullOrWhiteSpace(AppInit.conf.KinoPub.token))
online += "{\"name\":\"KinoPub\",\"url\":\"{localhost}/kinopub\"},";
if (!string.IsNullOrWhiteSpace(conf.KinoPub.token))
online += "{\"name\":\"" + (conf.KinoPub.displayname ?? "KinoPub") + "\",\"url\":\"{localhost}/kinopub\"},";

if (AppInit.conf.Filmix.enable)
online += "{\"name\":\"Filmix\",\"url\":\"{localhost}/filmix\"},";
if (conf.Filmix.enable)
online += "{\"name\":\"" + (conf.Filmix.displayname ?? "Filmix") + "\",\"url\":\"{localhost}/filmix\"},";

if (!string.IsNullOrWhiteSpace(AppInit.conf.Bazon.token))
online += "{\"name\":\"Bazon\",\"url\":\"{localhost}/bazon\"},";
if (!string.IsNullOrWhiteSpace(conf.Bazon.token))
online += "{\"name\":\"" + (conf.Bazon.displayname ?? "Bazon") + "\",\"url\":\"{localhost}/bazon\"},";

if (!string.IsNullOrWhiteSpace(AppInit.conf.Alloha.token))
online += "{\"name\":\"Alloha\",\"url\":\"{localhost}/alloha\"},";
if (!string.IsNullOrWhiteSpace(conf.Alloha.token))
online += "{\"name\":\"" + (conf.Alloha.displayname ?? "Alloha") + "\",\"url\":\"{localhost}/alloha\"},";

if (AppInit.conf.Rezka.enable)
online += "{\"name\":\"Rezka\",\"url\":\"{localhost}/rezka\"},";
if (conf.Rezka.enable)
online += "{\"name\":\"" + (conf.Rezka.displayname ?? "Rezka") + "\",\"url\":\"{localhost}/rezka\"},";

if (AppInit.conf.VideoDB.enable)
online += "{\"name\":\"VideoDB\",\"url\":\"{localhost}/videodb\"},";
if (conf.VideoDB.enable)
online += "{\"name\":\"" + (conf.VideoDB.displayname ?? "VideoDB") + "\",\"url\":\"{localhost}/videodb\"},";

if (AppInit.conf.Kinobase.enable)
online += "{\"name\":\"Kinobase\",\"url\":\"{localhost}/kinobase\"},";
if (conf.Kinobase.enable)
online += "{\"name\":\"" + (conf.Kinobase.displayname ?? "Kinobase") + "\",\"url\":\"{localhost}/kinobase\"},";

if (AppInit.conf.Zetflix.enable)
online += "{\"name\":\"Zetflix\",\"url\":\"{localhost}/zetflix\"},";
if (conf.Zetflix.enable)
online += "{\"name\":\"" + (conf.Zetflix.displayname ?? "Zetflix") + "\",\"url\":\"{localhost}/zetflix\"},";

if (AppInit.conf.Voidboost.enable)
online += "{\"name\":\"Voidboost\",\"url\":\"{localhost}/voidboost\"},";
if (conf.Voidboost.enable)
online += "{\"name\":\"" + (conf.Voidboost.displayname ?? "Voidboost") + "\",\"url\":\"{localhost}/voidboost\"},";

if (AppInit.conf.VCDN.enable)
online += "{\"name\":\"VideoCDN\",\"url\":\"{localhost}/vcdn\"},";
if (conf.VCDN.enable)
online += "{\"name\":\"" + (conf.VCDN.displayname ?? "VideoCDN") + "\",\"url\":\"{localhost}/vcdn\"},";

if (AppInit.conf.Ashdi.enable)
online += "{\"name\":\"Ashdi (UKR)\",\"url\":\"{localhost}/ashdi\"},";
if (conf.Ashdi.enable)
online += "{\"name\":\"" + (conf.Ashdi.displayname ?? "Ashdi (UKR)") + "\",\"url\":\"{localhost}/ashdi\"},";

if (AppInit.conf.Eneyida.enable)
online += "{\"name\":\"Eneyida (UKR)\",\"url\":\"{localhost}/eneyida\"},";
if (conf.Eneyida.enable)
online += "{\"name\":\"" + (conf.Eneyida.displayname ?? "Eneyida (UKR)") + "\",\"url\":\"{localhost}/eneyida\"},";

if (!string.IsNullOrWhiteSpace(AppInit.conf.Kodik.token))
online += "{\"name\":\"Kodik\",\"url\":\"{localhost}/kodik\"},";
if (!string.IsNullOrWhiteSpace(conf.Kodik.token))
online += "{\"name\":\"" + (conf.Kodik.displayname ?? "Kodik") + "\",\"url\":\"{localhost}/kodik\"},";

if (!string.IsNullOrWhiteSpace(AppInit.conf.Seasonvar.token) && (serial == -1 || serial == 1))
online += "{\"name\":\"Seasonvar\",\"url\":\"{localhost}/seasonvar\"},";
if (!string.IsNullOrWhiteSpace(conf.Seasonvar.token) && (serial == -1 || serial == 1))
online += "{\"name\":\"" + (conf.Seasonvar.displayname ?? "Seasonvar") + "\",\"url\":\"{localhost}/seasonvar\"},";

if (AppInit.conf.Lostfilmhd.enable && (serial == -1 || serial == 1))
online += "{\"name\":\"LostfilmHD\",\"url\":\"{localhost}/lostfilmhd\"},";
if (conf.Lostfilmhd.enable && (serial == -1 || serial == 1))
online += "{\"name\":\"" + (conf.Lostfilmhd.displayname ?? "LostfilmHD") + "\",\"url\":\"{localhost}/lostfilmhd\"},";

if (AppInit.conf.Collaps.enable)
online += "{\"name\":\"Collaps\",\"url\":\"{localhost}/collaps\"},";
if (conf.Collaps.enable)
online += "{\"name\":\"" + (conf.Collaps.displayname ?? "Collaps") + "\",\"url\":\"{localhost}/collaps\"},";

if (!string.IsNullOrWhiteSpace(AppInit.conf.HDVB.token))
online += "{\"name\":\"HDVB\",\"url\":\"{localhost}/hdvb\"},";
if (!string.IsNullOrWhiteSpace(conf.HDVB.token))
online += "{\"name\":\"" + (conf.HDVB.displayname ?? "HDVB") + "\",\"url\":\"{localhost}/hdvb\"},";

if (AppInit.conf.CDNmovies.enable && (serial == -1 || (serial == 1 && !isanime)))
online += "{\"name\":\"CDNmovies\",\"url\":\"{localhost}/cdnmovies\"},";
if (conf.CDNmovies.enable && (serial == -1 || (serial == 1 && !isanime)))
online += "{\"name\":\"" + (conf.CDNmovies.displayname ?? "CDNmovies") + "\",\"url\":\"{localhost}/cdnmovies\"},";

if (serial == -1 || isanime)
{
if (AppInit.conf.AnilibriaOnline.enable)
online += "{\"name\":\"Anilibria\",\"url\":\"{localhost}/anilibria\"},";
if (conf.AnilibriaOnline.enable)
online += "{\"name\":\"" + (conf.AnilibriaOnline.displayname ?? "Anilibria") + "\",\"url\":\"{localhost}/anilibria\"},";

if (AppInit.conf.Animevost.enable)
online += "{\"name\":\"Animevost\",\"url\":\"{localhost}/animevost\"},";
if (conf.Animevost.enable)
online += "{\"name\":\"" + (conf.Animevost.displayname ?? "Animevost") + "\",\"url\":\"{localhost}/animevost\"},";

if (AppInit.conf.Animebesst.enable)
online += "{\"name\":\"Animebesst\",\"url\":\"{localhost}/animebesst\"},";
if (conf.Animebesst.enable)
online += "{\"name\":\"" + (conf.Animebesst.displayname ?? "Animebesst") + "\",\"url\":\"{localhost}/animebesst\"},";

if (AppInit.conf.AnimeGo.enable)
online += "{\"name\":\"AnimeGo\",\"url\":\"{localhost}/animego\"},";
if (conf.AnimeGo.enable)
online += "{\"name\":\"" + (conf.AnimeGo.displayname ?? "AnimeGo") + "\",\"url\":\"{localhost}/animego\"},";

if (AppInit.conf.AniMedia.enable)
online += "{\"name\":\"AniMedia\",\"url\":\"{localhost}/animedia\"},";
if (conf.AniMedia.enable)
online += "{\"name\":\"" + (conf.AniMedia.displayname ?? "AniMedia") + "\",\"url\":\"{localhost}/animedia\"},";
}

if (AppInit.conf.Kinotochka.enable)
online += "{\"name\":\"Kinotochka\",\"url\":\"{localhost}/kinotochka\"},";
if (conf.Kinotochka.enable)
online += "{\"name\":\"" + (conf.Kinotochka.displayname ?? "Kinotochka") + "\",\"url\":\"{localhost}/kinotochka\"},";

if (serial == -1 || serial == 0 || (serial == 1 && !isanime))
{
if (AppInit.conf.Kinokrad.enable)
online += "{\"name\":\"Kinokrad\",\"url\":\"{localhost}/kinokrad\"},";
if (conf.Kinokrad.enable)
online += "{\"name\":\"" + (conf.Kinokrad.displayname ?? "Kinokrad") + "\",\"url\":\"{localhost}/kinokrad\"},";

if (AppInit.conf.Kinoprofi.enable)
online += "{\"name\":\"Kinoprofi\",\"url\":\"{localhost}/kinoprofi\"},";
if (conf.Kinoprofi.enable)
online += "{\"name\":\"" + (conf.Kinoprofi.displayname ?? "Kinoprofi") + "\",\"url\":\"{localhost}/kinoprofi\"},";

if (AppInit.conf.Redheadsound.enable && (serial == -1 || serial == 0))
online += "{\"name\":\"Redheadsound\",\"url\":\"{localhost}/redheadsound\"},";
if (conf.Redheadsound.enable && (serial == -1 || serial == 0))
online += "{\"name\":\"" + (conf.Redheadsound.displayname ?? "Redheadsound") + "\",\"url\":\"{localhost}/redheadsound\"},";

if (!string.IsNullOrWhiteSpace(AppInit.conf.VideoAPI.token) && (serial == -1 || serial == 0))
online += "{\"name\":\"VideoAPI (ENG)\",\"url\":\"{localhost}/videoapi\"},";
if (!string.IsNullOrWhiteSpace(conf.VideoAPI.token) && (serial == -1 || serial == 0))
online += "{\"name\":\"" + (conf.VideoAPI.displayname ?? "VideoAPI (ENG)") + "\",\"url\":\"{localhost}/videoapi\"},";
}

if (AppInit.conf.IframeVideo.enable && (serial == -1 || serial == 0))
online += "{\"name\":\"IframeVideo\",\"url\":\"{localhost}/iframevideo\"},";
if (conf.IframeVideo.enable && (serial == -1 || serial == 0))
online += "{\"name\":\"" + (conf.IframeVideo.displayname ?? "IframeVideo") + "\",\"url\":\"{localhost}/iframevideo\"},";

#region checkOnlineSearch
if (AppInit.conf.online.checkOnlineSearch && id > 0)
if (conf.online.checkOnlineSearch && id > 0)
{
string memkey = $"ApiController:checkOnlineSearch:{id}";
if (!memoryCache.TryGetValue(memkey, out (bool ready, int tasks, string online) cache) || !AppInit.conf.multiaccess)
if (!memoryCache.TryGetValue(memkey, out (bool ready, int tasks, string online) cache) || !conf.multiaccess)
{
memoryCache.Set(memkey, string.Empty, DateTime.Now.AddSeconds(15));

Expand Down
2 changes: 1 addition & 1 deletion Controllers/LITE/IframeVideo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ async public Task<ActionResult> Video(string type, int cid, string token, string
res.cid = item.Value<int>("cid");
res.path = item.Value<string>("path");
res.type = item.Value<string>("type");
res.content = await HttpClient.Get(res.path, timeoutSeconds: 8);

res.content = await HttpClient.Get(res.path, referer: "https://kinoplayer.online/", timeoutSeconds: 8);
if (res.content == null)
return (null, null, 0, null);

Expand Down
9 changes: 9 additions & 0 deletions Models/AppConf/Known.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace Lampac.Models.AppConf
{
public class Known
{
public string ip { get; set; }

public int prefixLength { get; set; }
}
}
2 changes: 2 additions & 0 deletions Models/LITE/AllohaSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public AllohaSettings(string apihost, string linkhost, string token, string secr
}


public string displayname { get; set; }

public string apihost { get; set; }

public string linkhost { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Models/LITE/BazonSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ public BazonSettings(string apihost, string token, bool localip)
}


public string displayname { get; set; }

public string apihost { get; set; }

public string token { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Models/LITE/Filmix/FilmixSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public FilmixSettings(string host, bool enable = true)
}


public string displayname { get; set; }

public string host { get; set; }

public bool enable { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Models/LITE/HDVB/HDVBSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public HDVBSettings(string apihost, string token)
}


public string displayname { get; set; }

public string apihost { get; set; }

public string token { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Models/LITE/IframeVideoSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ public IframeVideoSettings(string host, string cdnhost)
}


public string displayname { get; set; }

public string apihost { get; set; }

public string cdnhost { get; set; }
Expand Down
1 change: 1 addition & 0 deletions Models/LITE/KinoPubSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ public KinoPubSettings(string apihost = null)
this.apihost = apihost;
}

public string displayname { get; set; }

public string apihost { get; set; }

Expand Down
2 changes: 2 additions & 0 deletions Models/LITE/Kodik/KodikSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public KodikSettings(string apihost, string linkhost, string token, string secre
}


public string displayname { get; set; }

public string apihost { get; set; }

public string linkhost { get; set; }
Expand Down
2 changes: 2 additions & 0 deletions Models/LITE/OnlinesSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public OnlinesSettings(string host, string apihost = null, bool useproxy = false
}


public string displayname { get; set; }

public string host { get; set; }

public string apihost { get; set; }
Expand Down
19 changes: 16 additions & 3 deletions Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using Lampac.Engine.CORE;
using Newtonsoft.Json.Linq;
using System.Text;
using System.Net;

namespace Lampac
{
Expand Down Expand Up @@ -60,11 +61,22 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IMemoryC
ApplicationServices = app.ApplicationServices;
app.UseDeveloperExceptionPage();

app.UseForwardedHeaders(new ForwardedHeadersOptions
#region UseForwardedHeaders
var forwarded = new ForwardedHeadersOptions
{
ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
});
};

if (AppInit.conf.KnownProxies != null && AppInit.conf.KnownProxies.Count > 0)
{
foreach (var k in AppInit.conf.KnownProxies)
forwarded.KnownNetworks.Add(new IPNetwork(IPAddress.Parse(k.ip), k.prefixLength));
}

app.UseForwardedHeaders(forwarded);
#endregion

#region Update KinoPub device
if (!string.IsNullOrWhiteSpace(AppInit.conf.KinoPub.token))
{
try
Expand All @@ -81,7 +93,8 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IMemoryC
}
}
catch { }
}
}
#endregion

//AppInit.conf.Toloka.login = new Models.JAC.LoginSettings() { u = "user", p = "passwd" };
//System.IO.File.WriteAllText("example.conf", Newtonsoft.Json.JsonConvert.SerializeObject(AppInit.conf, Newtonsoft.Json.Formatting.Indented));
Expand Down

0 comments on commit c66ae61

Please sign in to comment.