Skip to content

Commit

Permalink
126.1
Browse files Browse the repository at this point in the history
  • Loading branch information
immisterio committed Nov 29, 2024
1 parent 03d2ab7 commit a037437
Show file tree
Hide file tree
Showing 14 changed files with 113 additions and 59 deletions.
8 changes: 6 additions & 2 deletions DLNA/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,16 @@ static DLNAController()
#region dlna.js
[HttpGet]
[Route("dlna.js")]
public ActionResult Plugin()
[Route("dlna/js/{token}")]
public ActionResult Plugin(string token)
{
if (!AppInit.conf.dlna.enable)
return Content(string.Empty);

return Content(FileCache.ReadAllText("plugins/dlna.js").Replace("{localhost}", host), contentType: "application/javascript; charset=utf-8");
string file = FileCache.ReadAllText("plugins/dlna.js").Replace("{localhost}", host);
file = file.Replace("{token}", HttpUtility.UrlEncode(token));

return Content(file, contentType: "application/javascript; charset=utf-8");
}
#endregion

Expand Down
14 changes: 5 additions & 9 deletions Lampac/Controllers/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -316,25 +316,21 @@ public ActionResult LamOnInit(string token, bool adult = true)
{
void send(string name, bool worktoken)
{
if (worktoken)
if (worktoken && !string.IsNullOrEmpty(token))
{
if (!string.IsNullOrEmpty(token))
plugins.Add($"\"{{localhost}}/{name}/js/{HttpUtility.UrlEncode(token)}\"");
else
plugins.Add($"\"{{localhost}}/{name}.js\"");
plugins.Add($"\"{{localhost}}/{name}/js/{HttpUtility.UrlEncode(token)}\"");
}
else
{
if (string.IsNullOrEmpty(token))
plugins.Add($"\"{{localhost}}/{name}.js\"");
plugins.Add($"\"{{localhost}}/{name}.js\"");
}
}

if (AppInit.conf.LampaWeb.initPlugins.dlna && AppInit.modules.FirstOrDefault(i => i.dll == "DLNA.dll" && i.enable) != null)
send("dlna", false);
send("dlna", true);

if (AppInit.conf.LampaWeb.initPlugins.tracks && AppInit.modules.FirstOrDefault(i => i.dll == "Tracks.dll" && i.enable) != null)
send("tracks", false);
send("tracks", true);

if (AppInit.conf.LampaWeb.initPlugins.tmdbProxy)
send("tmdbproxy", true);
Expand Down
2 changes: 1 addition & 1 deletion Lampac/Engine/Middlewares/Accsdb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public Task Invoke(HttpContext httpContext)
if (httpContext.Request.Path.Value.EndsWith("/personal.lampa"))
return _next(httpContext);

if (httpContext.Request.Path.Value != "/" && !Regex.IsMatch(httpContext.Request.Path.Value, "^/((proxy-dash|ts|ws|headers|myip|geo|version|weblog|rch/result|merchant/payconfirm)(/|$)|(extensions|kit)$|on/|(online|sisi|timecode|tmdbproxy|ts)/js/|(streampay|b2pay|cryptocloud|freekassa|litecoin)/|lite/(filmixpro|fxapi/lowlevel/|kinopubpro|vokinotk|rhs/bind)|lampa-(main|lite)/app\\.min\\.js|[a-zA-Z]+\\.js|msx/start\\.json|samsung\\.wgt)"))
if (httpContext.Request.Path.Value != "/" && !Regex.IsMatch(httpContext.Request.Path.Value, "^/((proxy-dash|ts|ws|headers|myip|geo|version|weblog|rch/result|merchant/payconfirm)(/|$)|(extensions|kit)$|on/|(online|sisi|timecode|tmdbproxy|dlna|ts|tracks)/js/|(streampay|b2pay|cryptocloud|freekassa|litecoin)/|lite/(filmixpro|fxapi/lowlevel/|kinopubpro|vokinotk|rhs/bind)|lampa-(main|lite)/app\\.min\\.js|[a-zA-Z]+\\.js|msx/start\\.json|samsung\\.wgt)"))
{
bool limitip = false;
var requestInfo = httpContext.Features.Get<RequestModel>();
Expand Down
22 changes: 22 additions & 0 deletions Lampac/Engine/Middlewares/RequestInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,31 @@ public Task Invoke(HttpContext httpContext)

if (string.IsNullOrEmpty(AppInit.conf.accsdb.domainId_pattern))
{
#region getuid
string getuid()
{
if (!string.IsNullOrEmpty(httpContext.Request.Query["token"].ToString()))
return httpContext.Request.Query["token"].ToString();

if (!string.IsNullOrEmpty(httpContext.Request.Query["account_email"].ToString()))
return httpContext.Request.Query["account_email"].ToString();

if (!string.IsNullOrEmpty(httpContext.Request.Query["uid"].ToString()))
return httpContext.Request.Query["uid"].ToString();

if (!string.IsNullOrEmpty(httpContext.Request.Query["box_mac"].ToString()))
return httpContext.Request.Query["box_mac"].ToString();

return null;
}
#endregion

req.user = AppInit.conf.accsdb.findUser(httpContext, out string uid);
req.user_uid = uid;

if (string.IsNullOrEmpty(req.user_uid))
req.user_uid = getuid();

httpContext.Features.Set(req);
return _next(httpContext);
}
Expand Down
6 changes: 4 additions & 2 deletions Lampac/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,13 @@ public static void Main(string[] args)
HttpClient.onlog += (e, log) => soks.SendLog(log, "http");
RchClient.hub += (e, req) => soks.hubClients?.Client(req.connectionId)?.SendAsync("RchClient", req.rchId, req.url, req.data, req.headers);

Console.WriteLine(JsonConvert.SerializeObject(AppInit.conf, Formatting.Indented, new JsonSerializerSettings()
string init = JsonConvert.SerializeObject(AppInit.conf, Formatting.Indented, new JsonSerializerSettings()
{
NullValueHandling = NullValueHandling.Ignore
}) + "\n");
});

Console.WriteLine(init + "\n");
File.WriteAllText("current.conf", init);

if (!AppInit.conf.mikrotik)
{
Expand Down
8 changes: 6 additions & 2 deletions Online/Controllers/FilmixPartner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class FilmixPartner : BaseOnlineController
{
[HttpGet]
[Route("lite/fxapi")]
async public Task<ActionResult> Index(string account_email, long kinopoisk_id, bool checksearch, string title, string original_title, int year, int postid, int t, int s = -1, bool rjson = false)
async public Task<ActionResult> Index(string account_email, long kinopoisk_id, bool checksearch, string title, string original_title, int year, int postid, int t = -1, int s = -1, bool rjson = false)
{
var init = AppInit.conf.FilmixPartner;

Expand Down Expand Up @@ -143,11 +143,15 @@ async public Task<ActionResult> Index(string account_email, long kinopoisk_id, b
string link = $"{host}/lite/fxapi?rjson={rjson}&postid={postid}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&s={s}&t={indexTranslate}";
bool active = t == indexTranslate;

indexTranslate++;
if (t == -1)
t = indexTranslate;

vtpl.Append(translation.Value<string>("name"), active, link);
break;
}
}

indexTranslate++;
}
#endregion

Expand Down
2 changes: 1 addition & 1 deletion Online/Controllers/FilmixTV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class FilmixTV : BaseOnlineController
{
[HttpGet]
[Route("lite/filmixtv")]
async public Task<ActionResult> Index(string title, string original_title, int clarification, int year, int postid, int t, int? s = null, bool origsource = false, bool rjson = false)
async public Task<ActionResult> Index(string title, string original_title, int clarification, int year, int postid, int t = -1, int? s = null, bool origsource = false, bool rjson = false)
{
var init = AppInit.conf.FilmixTV.Clone();

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ curl -L -k -s https://lampac.sh/home | bash
* corseu - Использовать прокси cors.bwa.workers.dev

# Пример init.conf
* Список всех параметров, а так же значения по умолчанию смотреть в example.conf
* Список всех параметров, а так же значения по умолчанию смотреть в current.conf и example.conf
* В init.conf нужно указывать только те параметры, которые хотите изменить
* Редактировать init.conf можно так же через ip:9118/admin/init

Expand Down
67 changes: 42 additions & 25 deletions Shared.Engine/Online/FilmixTV.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
using Shared.Model.Online.Filmix;
using Shared.Model.Online.FilmixTV;
using Shared.Model.Templates;
using System.Linq;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Web;

namespace Shared.Engine.Online
Expand Down Expand Up @@ -197,49 +199,64 @@ public string Html(RootObject? root, bool pro, int postid, string? title, string
string? enc_title = HttpUtility.UrlEncode(title);
string? enc_original_title = HttpUtility.UrlEncode(original_title);

int indexTranslate = 0;
var vtpl = new VoiceTpl();

foreach (var voiceover in root.SerialVoice)
{
string link = host + $"lite/filmixtv?rjson={rjson}&postid={postid}&title={enc_title}&original_title={enc_original_title}&t={indexTranslate}";
bool active = t == indexTranslate;

indexTranslate++;
vtpl.Append(voiceover.Key, active, link);
}

var selectedVoiceOverIndex = t != null ? t : 0;
var selectedVoiceOver = root.SerialVoice.ElementAt(selectedVoiceOverIndex).Value;

if (s == null)
{
#region Сезоны
var maxQuality = selectedVoiceOver
var maxQuality = root.SerialVoice.SelectMany(i => i.Value)
.SelectMany(season => season.Value.episodes)
.SelectMany(episode => episode.Value.files)
.Max(file => file.quality);

var quality = $"{maxQuality}p";
var tpl = new SeasonTpl(quality);
var tpl = new SeasonTpl($"{maxQuality}p");
var temp = new HashSet<int>();

foreach (var season in selectedVoiceOver)
foreach (var translation in root.SerialVoice)
{
var link = $"{host}lite/filmixtv?rjson={rjson}&postid={postid}&title={enc_title}&original_title={enc_original_title}&s={season.Value.season}&t={selectedVoiceOverIndex}";
tpl.Append($"{season.Value.season} сезон", link, season.Value.season);
foreach (var season in translation.Value)
{
if (temp.Contains(season.Value.season))
continue;

temp.Add(season.Value.season);

var link = $"{host}lite/filmixtv?rjson={rjson}&postid={postid}&title={enc_title}&original_title={enc_original_title}&s={season.Value.season}";
tpl.Append($"{season.Value.season} сезон", link, season.Value.season);
}
}

return rjson ? tpl.ToJson(vtpl) : tpl.ToHtml(vtpl);
return rjson ? tpl.ToJson() : tpl.ToHtml();
#endregion
}
else
{
var selectedSeason = selectedVoiceOver.FirstOrDefault(x => x.Value.season == s);
#region Перевод
int indexTranslate = 0;
var vtpl = new VoiceTpl();

if (selectedSeason.Value == null)
foreach (var translation in root.SerialVoice)
{
return "<div>Сезон не найден</div>";
foreach (var season in translation.Value)
{
if (season.Value.season == s)
{
string link = host + $"lite/filmixtv?rjson={rjson}&postid={postid}&title={enc_title}&original_title={enc_original_title}&s={s}&t={indexTranslate}";
bool active = t == indexTranslate;

if (t == -1)
t = indexTranslate;

vtpl.Append(translation.Key, active, link);
}
}

indexTranslate++;
}
#endregion

var selectedSeason = root.SerialVoice.ElementAt(t).Value.FirstOrDefault(x => x.Value.season == s);

if (selectedSeason.Value == null)
return string.Empty;

var etpl = new EpisodeTpl();

Expand Down
5 changes: 4 additions & 1 deletion Shared.Engine/Online/Kodik.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ public KodikInvoke(string? host, string apihost, string token, bool hls, string
#endregion

#region Embed
public async ValueTask<List<Result>?> Embed(string? imdb_id, long kinopoisk_id, int s)
async public ValueTask<List<Result>?> Embed(string? imdb_id, long kinopoisk_id, int s)
{
if (string.IsNullOrEmpty(imdb_id) && kinopoisk_id == 0)
return null;

string url = $"{apihost}/search?token={token}&limit=100&with_episodes=true";
if (kinopoisk_id > 0)
url += $"&kinopoisk_id={kinopoisk_id}";
Expand Down
2 changes: 1 addition & 1 deletion Shared.Model/AppInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ public class AppInit

public OnlinesSettings Animevost { get; set; } = new OnlinesSettings("kwwsv=22dqlphyrvw1ruj", streamproxy: true);

public OnlinesSettings MoonAnime { get; set; } = new OnlinesSettings("kwwsv=22dsl1prrqdqlph1duw", token: ";98iHI0H5h4Ef05fd7640h9D4830:;3GIG0:6:F9E");
public OnlinesSettings MoonAnime { get; set; } = new OnlinesSettings("kwwsv=22dsl1prrqdqlph1duw", token: ";98iHI0H5h4Ef05fd7640h9D4830:;3GIG0:6:F9E") { geo_hide = new string[] { "RU", "BY" } };

public OnlinesSettings Animebesst { get; set; } = new OnlinesSettings("kwwsv=22dqlph41ehvw");

Expand Down
6 changes: 4 additions & 2 deletions Shared.Model/Templates/SimilarTpl.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public SimilarTpl() { }
public SimilarTpl(int capacity) { data.Capacity = capacity; }


public string OnlineSplit => "<span class=\\\"online-prestige-split\\\">●</span>";
public string OnlineSplit => "{prestige-split}";


public void Append(string? title, string year, string details, string link)
Expand Down Expand Up @@ -44,6 +44,8 @@ public string ToHtml()

}, new JsonSerializerOptions { DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingDefault });

datajson = datajson.Replace("{prestige-split}", "<span class=\\\"online-prestige-split\\\">●</span>");

html.Append($"<div class=\"videos__item videos__season selector {(firstjson ? "focused" : "")}\" data-json='{datajson}'><div class=\"videos__season-layers\"></div><div class=\"videos__item-imgbox videos__season-imgbox\"><div class=\"videos__item-title videos__season-title\">{HttpUtility.HtmlEncode(i.title)}</div></div></div>");
firstjson = false;
}
Expand All @@ -63,7 +65,7 @@ public string ToJson()
data = data.Select(i => new
{
url = i.link,
i.details,
details = i.details?.Replace("{prestige-split}", "<span class=\"online-prestige-split\">●</span>"),
i.title,
year = int.TryParse(i.year, out int _year) ? _year : 0
})
Expand Down
2 changes: 1 addition & 1 deletion Shared/Engine/CORE/RchClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ async ValueTask<string> SendHub(string url, string data = null, Dictionary<strin

hub.Invoke(null, (connectionId, rchId, url, data, send_headers));

string result = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(20));
string result = await tcs.Task.WaitAsync(TimeSpan.FromSeconds(rhub_fallback ? 5 : 8));
rchIds.TryRemove(rchId, out _);

if (string.IsNullOrWhiteSpace(result))
Expand Down
26 changes: 15 additions & 11 deletions Tracks/ApiController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,21 @@ namespace Lampac.Controllers
{
public class TracksController : BaseController
{
[HttpGet]
[Route("tracks.js")]
[Route("tracks/js/{token}")]
public ActionResult Tracks(string token)
{
if (!AppInit.conf.ffprobe.enable)
return Content(string.Empty);

string file = FileCache.ReadAllText("plugins/tracks.js").Replace("{localhost}", host);
file = file.Replace("{token}", HttpUtility.UrlEncode(token));

return Content(file, contentType: "application/javascript; charset=utf-8");
}


[Route("ffprobe")]
async public Task<ActionResult> Ffprobe(string media)
{
Expand Down Expand Up @@ -99,16 +114,5 @@ static string getFolder(string magnethash)

return Content(outPut, contentType: "application/json; charset=utf-8");
}


[HttpGet]
[Route("tracks.js")]
public ActionResult Tracks()
{
if (!AppInit.conf.ffprobe.enable)
return Content(string.Empty);

return Content(FileCache.ReadAllText("plugins/tracks.js").Replace("{localhost}", host), contentType: "application/javascript; charset=utf-8");
}
}
}

0 comments on commit a037437

Please sign in to comment.