mirror of
https://github.com/lampame/lampac-ukraine.git
synced 2026-04-16 09:22:21 +00:00
Move to Graveyard
This commit is contained in:
parent
85849c78d2
commit
669c178501
@ -1,86 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Shared.Models.Base;
|
||||
using System;
|
||||
using System.Web;
|
||||
|
||||
namespace Shared.Engine
|
||||
{
|
||||
public static class ApnHelper
|
||||
{
|
||||
public const string DefaultHost = "https://tut.im/proxy.php?url={encodeurl}";
|
||||
|
||||
public static bool TryGetInitConf(JObject conf, out bool enabled, out string host)
|
||||
{
|
||||
enabled = false;
|
||||
host = null;
|
||||
|
||||
if (conf == null)
|
||||
return false;
|
||||
|
||||
if (!conf.TryGetValue("apn", out var apnToken) || apnToken?.Type != JTokenType.Boolean)
|
||||
return false;
|
||||
|
||||
enabled = apnToken.Value<bool>();
|
||||
host = conf.Value<string>("apn_host");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void ApplyInitConf(bool enabled, string host, BaseSettings init)
|
||||
{
|
||||
if (init == null)
|
||||
return;
|
||||
|
||||
if (!enabled)
|
||||
{
|
||||
init.apnstream = false;
|
||||
init.apn = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(host))
|
||||
host = DefaultHost;
|
||||
|
||||
if (init.apn == null)
|
||||
init.apn = new ApnConf();
|
||||
|
||||
init.apn.host = host;
|
||||
init.apnstream = true;
|
||||
}
|
||||
|
||||
public static bool IsEnabled(BaseSettings init)
|
||||
{
|
||||
return init?.apnstream == true && !string.IsNullOrWhiteSpace(init?.apn?.host);
|
||||
}
|
||||
|
||||
public static bool IsAshdiUrl(string url)
|
||||
{
|
||||
return !string.IsNullOrEmpty(url) &&
|
||||
url.IndexOf("ashdi.vip", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
}
|
||||
|
||||
public static string WrapUrl(BaseSettings init, string url)
|
||||
{
|
||||
if (!IsEnabled(init))
|
||||
return url;
|
||||
|
||||
return BuildUrl(init.apn.host, url);
|
||||
}
|
||||
|
||||
public static string BuildUrl(string host, string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(host) || string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
if (host.Contains("{encodeurl}"))
|
||||
return host.Replace("{encodeurl}", HttpUtility.UrlEncode(url));
|
||||
|
||||
if (host.Contains("{encode_uri}"))
|
||||
return host.Replace("{encode_uri}", HttpUtility.UrlEncode(url));
|
||||
|
||||
if (host.Contains("{uri}"))
|
||||
return host.Replace("{uri}", url);
|
||||
|
||||
return $"{host.TrimEnd('/')}/{url}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<OutputType>library</OutputType>
|
||||
<IsPackable>true</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Shared">
|
||||
<HintPath>..\..\Shared.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,371 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using Shared;
|
||||
using Shared.Models.Online.Settings;
|
||||
using Shared.Models;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text;
|
||||
using HtmlAgilityPack;
|
||||
using CikavaIdeya.Models;
|
||||
using Shared.Engine;
|
||||
using System.Linq;
|
||||
|
||||
namespace CikavaIdeya
|
||||
{
|
||||
public class CikavaIdeyaInvoke
|
||||
{
|
||||
private OnlinesSettings _init;
|
||||
private IHybridCache _hybridCache;
|
||||
private Action<string> _onLog;
|
||||
private ProxyManager _proxyManager;
|
||||
|
||||
public CikavaIdeyaInvoke(OnlinesSettings init, IHybridCache hybridCache, Action<string> onLog, ProxyManager proxyManager)
|
||||
{
|
||||
_init = init;
|
||||
_hybridCache = hybridCache;
|
||||
_onLog = onLog;
|
||||
_proxyManager = proxyManager;
|
||||
}
|
||||
|
||||
string AshdiRequestUrl(string url)
|
||||
{
|
||||
if (!ApnHelper.IsAshdiUrl(url))
|
||||
return url;
|
||||
|
||||
return ApnHelper.WrapUrl(_init, url);
|
||||
}
|
||||
|
||||
public async Task<List<CikavaIdeya.Models.EpisodeLinkInfo>> Search(string imdb_id, long kinopoisk_id, string title, string original_title, int year, bool isfilm = false)
|
||||
{
|
||||
string filmTitle = !string.IsNullOrEmpty(title) ? title : original_title;
|
||||
string memKey = $"CikavaIdeya:search:{filmTitle}:{year}:{isfilm}";
|
||||
if (_hybridCache.TryGetValue(memKey, out List<CikavaIdeya.Models.EpisodeLinkInfo> res))
|
||||
return res;
|
||||
|
||||
try
|
||||
{
|
||||
// Спочатку шукаємо по title
|
||||
res = await PerformSearch(title, year);
|
||||
|
||||
// Якщо нічого не знайдено і є original_title, шукаємо по ньому
|
||||
if ((res == null || res.Count == 0) && !string.IsNullOrEmpty(original_title) && original_title != title)
|
||||
{
|
||||
_onLog($"No results for '{title}', trying search by original title '{original_title}'");
|
||||
res = await PerformSearch(original_title, year);
|
||||
// Оновлюємо ключ кешу для original_title
|
||||
if (res != null && res.Count > 0)
|
||||
{
|
||||
memKey = $"CikavaIdeya:search:{original_title}:{year}:{isfilm}";
|
||||
}
|
||||
}
|
||||
|
||||
if (res != null && res.Count > 0)
|
||||
{
|
||||
_hybridCache.Set(memKey, res, cacheTime(20));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_onLog($"CikavaIdeya search error: {ex.Message}");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async Task<List<EpisodeLinkInfo>> PerformSearch(string searchTitle, int year)
|
||||
{
|
||||
try
|
||||
{
|
||||
string searchUrl = $"{_init.host}/index.php?do=search&subaction=search&story={System.Web.HttpUtility.UrlEncode(searchTitle)}";
|
||||
var headers = new List<HeadersModel>() { new HeadersModel("User-Agent", "Mozilla/5.0"), new HeadersModel("Referer", _init.host) };
|
||||
|
||||
var searchHtml = await Http.Get(searchUrl, headers: headers, proxy: _proxyManager.Get());
|
||||
// Перевіряємо, чи є результати пошуку
|
||||
if (searchHtml.Contains("На жаль, пошук на сайті не дав жодних результатів"))
|
||||
{
|
||||
_onLog($"No search results for '{searchTitle}'");
|
||||
return new List<CikavaIdeya.Models.EpisodeLinkInfo>();
|
||||
}
|
||||
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(searchHtml);
|
||||
|
||||
var filmNodes = doc.DocumentNode.SelectNodes("//div[@class='th-item']");
|
||||
if (filmNodes == null)
|
||||
{
|
||||
_onLog($"No film nodes found for '{searchTitle}'");
|
||||
return new List<CikavaIdeya.Models.EpisodeLinkInfo>();
|
||||
}
|
||||
|
||||
string filmUrl = null;
|
||||
foreach (var filmNode in filmNodes)
|
||||
{
|
||||
var titleNode = filmNode.SelectSingleNode(".//div[@class='th-title']");
|
||||
if (titleNode == null || !titleNode.InnerText.Trim().ToLower().Contains(searchTitle.ToLower())) continue;
|
||||
|
||||
var descNode = filmNode.SelectSingleNode(".//div[@class='th-subtitle']");
|
||||
if (year > 0 && (descNode?.InnerText ?? "").Contains(year.ToString()))
|
||||
{
|
||||
var linkNode = filmNode.SelectSingleNode(".//a[@class='th-in']");
|
||||
if (linkNode != null)
|
||||
{
|
||||
filmUrl = linkNode.GetAttributeValue("href", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filmUrl == null)
|
||||
{
|
||||
var firstNode = filmNodes.FirstOrDefault()?.SelectSingleNode(".//a[@class='th-in']");
|
||||
if (firstNode != null)
|
||||
filmUrl = firstNode.GetAttributeValue("href", "");
|
||||
}
|
||||
|
||||
if (filmUrl == null)
|
||||
{
|
||||
_onLog($"No film URL found for '{searchTitle}'");
|
||||
return new List<CikavaIdeya.Models.EpisodeLinkInfo>();
|
||||
}
|
||||
|
||||
if (!filmUrl.StartsWith("http"))
|
||||
filmUrl = _init.host + filmUrl;
|
||||
|
||||
// Отримуємо список епізодів (для фільмів - один епізод, для серіалів - всі епізоди)
|
||||
var filmHtml = await Http.Get(filmUrl, headers: headers, proxy: _proxyManager.Get());
|
||||
// Перевіряємо, чи не видалено контент
|
||||
if (filmHtml.Contains("Видалено на прохання правовласника"))
|
||||
{
|
||||
_onLog($"Content removed on copyright holder request: {filmUrl}");
|
||||
return new List<CikavaIdeya.Models.EpisodeLinkInfo>();
|
||||
}
|
||||
|
||||
doc.LoadHtml(filmHtml);
|
||||
|
||||
// Знаходимо JavaScript з даними про епізоди
|
||||
var scriptNodes = doc.DocumentNode.SelectNodes("//script");
|
||||
if (scriptNodes != null)
|
||||
{
|
||||
foreach (var scriptNode in scriptNodes)
|
||||
{
|
||||
var scriptContent = scriptNode.InnerText;
|
||||
if (scriptContent.Contains("switches = Object"))
|
||||
{
|
||||
_onLog($"Found switches script: {scriptContent}");
|
||||
// Парсимо структуру switches
|
||||
var match = Regex.Match(scriptContent, @"switches = Object\((\{.*\})\);", RegexOptions.Singleline);
|
||||
if (match.Success)
|
||||
{
|
||||
string switchesJson = match.Groups[1].Value;
|
||||
_onLog($"Parsed switches JSON: {switchesJson}");
|
||||
// Спрощений парсинг JSON-подібної структури
|
||||
var res = ParseSwitchesJson(switchesJson, _init.host, filmUrl);
|
||||
_onLog($"Parsed episodes count: {res.Count}");
|
||||
foreach (var ep in res)
|
||||
{
|
||||
_onLog($"Episode: season={ep.season}, episode={ep.episode}, title={ep.title}, url={ep.url}");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_onLog($"PerformSearch error for '{searchTitle}': {ex.Message}");
|
||||
}
|
||||
return new List<EpisodeLinkInfo>();
|
||||
}
|
||||
|
||||
List<CikavaIdeya.Models.EpisodeLinkInfo> ParseSwitchesJson(string json, string host, string baseUrl)
|
||||
{
|
||||
var result = new List<CikavaIdeya.Models.EpisodeLinkInfo>();
|
||||
|
||||
try
|
||||
{
|
||||
_onLog($"Parsing switches JSON: {json}");
|
||||
// Спрощений парсинг JSON-подібної структури
|
||||
// Приклад для серіалу: {"Player1":{"1 сезон":{"1 серія":"https://ashdi.vip/vod/57364",...},"2 сезон":{"1 серія":"https://ashdi.vip/vod/118170",...}}}
|
||||
// Приклад для фільму: {"Player1":"https://ashdi.vip/vod/162246"}
|
||||
|
||||
// Знаходимо плеєр Player1
|
||||
// Спочатку спробуємо знайти об'єкт Player1
|
||||
var playerObjectMatch = Regex.Match(json, @"""Player1""\s*:\s*(\{(?:[^{}]|(?<open>\{)|(?<-open>\}))+(?(open)(?!)))", RegexOptions.Singleline);
|
||||
if (playerObjectMatch.Success)
|
||||
{
|
||||
string playerContent = playerObjectMatch.Groups[1].Value;
|
||||
_onLog($"Player1 object content: {playerContent}");
|
||||
|
||||
// Це серіал, парсимо сезони
|
||||
var seasonMatches = Regex.Matches(playerContent, @"""([^""]+?сезон[^""]*?)""\s*:\s*\{((?:[^{}]|(?<open>\{)|(?<-open>\}))+(?(open)(?!)))\}", RegexOptions.Singleline);
|
||||
_onLog($"Found {seasonMatches.Count} seasons");
|
||||
foreach (Match seasonMatch in seasonMatches)
|
||||
{
|
||||
string seasonName = seasonMatch.Groups[1].Value;
|
||||
string seasonContent = seasonMatch.Groups[2].Value;
|
||||
_onLog($"Season: {seasonName}, Content: {seasonContent}");
|
||||
|
||||
// Витягуємо номер сезону
|
||||
var seasonNumMatch = Regex.Match(seasonName, @"(\d+)");
|
||||
int seasonNum = seasonNumMatch.Success ? int.Parse(seasonNumMatch.Groups[1].Value) : 1;
|
||||
_onLog($"Season number: {seasonNum}");
|
||||
|
||||
// Парсимо епізоди
|
||||
var episodeMatches = Regex.Matches(seasonContent, @"""([^""]+?)""\s*:\s*""([^""]+?)""", RegexOptions.Singleline);
|
||||
_onLog($"Found {episodeMatches.Count} episodes in season {seasonNum}");
|
||||
foreach (Match episodeMatch in episodeMatches)
|
||||
{
|
||||
string episodeName = episodeMatch.Groups[1].Value;
|
||||
string episodeUrl = episodeMatch.Groups[2].Value;
|
||||
_onLog($"Episode: {episodeName}, URL: {episodeUrl}");
|
||||
|
||||
// Витягуємо номер епізоду
|
||||
var episodeNumMatch = Regex.Match(episodeName, @"(\d+)");
|
||||
int episodeNum = episodeNumMatch.Success ? int.Parse(episodeNumMatch.Groups[1].Value) : 1;
|
||||
|
||||
result.Add(new CikavaIdeya.Models.EpisodeLinkInfo
|
||||
{
|
||||
url = episodeUrl,
|
||||
title = episodeName,
|
||||
season = seasonNum,
|
||||
episode = episodeNum
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Якщо не знайшли об'єкт, спробуємо знайти просте значення
|
||||
var playerStringMatch = Regex.Match(json, @"""Player1""\s*:\s*(""([^""]+)"")", RegexOptions.Singleline);
|
||||
if (playerStringMatch.Success)
|
||||
{
|
||||
string playerContent = playerStringMatch.Groups[1].Value;
|
||||
_onLog($"Player1 string content: {playerContent}");
|
||||
|
||||
// Якщо це фільм (просте значення)
|
||||
if (playerContent.StartsWith("\"") && playerContent.EndsWith("\""))
|
||||
{
|
||||
string filmUrl = playerContent.Trim('"');
|
||||
result.Add(new CikavaIdeya.Models.EpisodeLinkInfo
|
||||
{
|
||||
url = filmUrl,
|
||||
title = "Фільм",
|
||||
season = 1,
|
||||
episode = 1
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_onLog("Player1 not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_onLog($"ParseSwitchesJson error: {ex.Message}");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<CikavaIdeya.Models.PlayResult> ParseEpisode(string url)
|
||||
{
|
||||
var result = new CikavaIdeya.Models.PlayResult() { streams = new List<(string, string)>() };
|
||||
try
|
||||
{
|
||||
// Якщо це вже iframe URL (наприклад, з switches), повертаємо його
|
||||
if (url.Contains("ashdi.vip"))
|
||||
{
|
||||
_onLog($"ParseEpisode: URL contains ashdi.vip, calling GetStreamUrlFromAshdi");
|
||||
string streamUrl = await GetStreamUrlFromAshdi(url);
|
||||
_onLog($"ParseEpisode: GetStreamUrlFromAshdi returned {streamUrl}");
|
||||
if (!string.IsNullOrEmpty(streamUrl))
|
||||
{
|
||||
result.streams.Add((streamUrl, "hls"));
|
||||
_onLog($"ParseEpisode: added stream URL to result.streams");
|
||||
return result;
|
||||
}
|
||||
// Якщо не вдалося отримати посилання на поток, повертаємо iframe URL
|
||||
_onLog($"ParseEpisode: stream URL is null or empty, setting iframe_url");
|
||||
result.iframe_url = url;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Інакше парсимо сторінку
|
||||
string html = await Http.Get(url, headers: new List<HeadersModel>() { new HeadersModel("User-Agent", "Mozilla/5.0"), new HeadersModel("Referer", _init.host) }, proxy: _proxyManager.Get());
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(html);
|
||||
|
||||
var iframe = doc.DocumentNode.SelectSingleNode("//div[@class='video-box']//iframe");
|
||||
if (iframe != null)
|
||||
{
|
||||
string iframeUrl = iframe.GetAttributeValue("src", "").Replace("&", "&");
|
||||
if (iframeUrl.StartsWith("//"))
|
||||
iframeUrl = "https:" + iframeUrl;
|
||||
|
||||
result.iframe_url = iframeUrl;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_onLog($"ParseEpisode error: {ex.Message}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
public async Task<string> GetStreamUrlFromAshdi(string url)
|
||||
{
|
||||
try
|
||||
{
|
||||
_onLog($"GetStreamUrlFromAshdi: trying to get stream URL from {url}");
|
||||
var headers = new List<HeadersModel>() { new HeadersModel("User-Agent", "Mozilla/5.0"), new HeadersModel("Referer", "https://ashdi.vip/") };
|
||||
string html = await Http.Get(AshdiRequestUrl(url), headers: headers, proxy: _proxyManager.Get());
|
||||
_onLog($"GetStreamUrlFromAshdi: received HTML, length={html.Length}");
|
||||
|
||||
// Знаходимо JavaScript код з об'єктом player
|
||||
var match = Regex.Match(html, @"var\s+player\s*=\s*new\s+Playerjs[\s\S]*?\(\s*({[\s\S]*?})\s*\)", RegexOptions.Multiline | RegexOptions.IgnoreCase);
|
||||
if (match.Success)
|
||||
{
|
||||
_onLog($"GetStreamUrlFromAshdi: found player object");
|
||||
string playerJson = match.Groups[1].Value;
|
||||
_onLog($"GetStreamUrlFromAshdi: playerJson={playerJson}");
|
||||
// Знаходимо поле file
|
||||
var fileMatch = Regex.Match(playerJson, @"file\s*:\s*['""]([^'""]+)['""]", RegexOptions.Multiline | RegexOptions.IgnoreCase);
|
||||
if (fileMatch.Success)
|
||||
{
|
||||
_onLog($"GetStreamUrlFromAshdi: found file URL: {fileMatch.Groups[1].Value}");
|
||||
return fileMatch.Groups[1].Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
_onLog($"GetStreamUrlFromAshdi: file URL not found in playerJson");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
_onLog($"GetStreamUrlFromAshdi: player object not found in HTML");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_onLog($"GetStreamUrlFromAshdi error: {ex.Message}");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static TimeSpan cacheTime(int multiaccess, int home = 5, int mikrotik = 2, OnlinesSettings init = null, int rhub = -1)
|
||||
{
|
||||
if (init != null && init.rhub && rhub != -1)
|
||||
return TimeSpan.FromMinutes(rhub);
|
||||
|
||||
int ctime = AppInit.conf.mikrotik ? mikrotik : AppInit.conf.multiaccess ? init != null && init.cache_time > 0 ? init.cache_time : multiaccess : home;
|
||||
if (ctime > multiaccess)
|
||||
ctime = multiaccess;
|
||||
|
||||
return TimeSpan.FromMinutes(ctime);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,437 +0,0 @@
|
||||
using Shared.Engine;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System.Collections.Generic;
|
||||
using System.Web;
|
||||
using System.Linq;
|
||||
using HtmlAgilityPack;
|
||||
using Shared;
|
||||
using Shared.Models.Templates;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Text;
|
||||
using Shared.Models.Online.Settings;
|
||||
using Shared.Models;
|
||||
using CikavaIdeya.Models;
|
||||
|
||||
namespace CikavaIdeya.Controllers
|
||||
{
|
||||
public class Controller : BaseOnlineController
|
||||
{
|
||||
ProxyManager proxyManager;
|
||||
|
||||
public Controller() : base(ModInit.Settings)
|
||||
{
|
||||
proxyManager = new ProxyManager(ModInit.CikavaIdeya);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("cikavaideya")]
|
||||
async public Task<ActionResult> Index(long id, string imdb_id, long kinopoisk_id, string title, string original_title, string original_language, int year, string source, int serial, string account_email, string t, int s = -1, int e = -1, bool play = false, bool rjson = false, bool checksearch = false)
|
||||
{
|
||||
await UpdateService.ConnectAsync(host);
|
||||
|
||||
var init = await loadKit(ModInit.CikavaIdeya);
|
||||
if (!init.enable)
|
||||
return Forbid();
|
||||
|
||||
var invoke = new CikavaIdeyaInvoke(init, hybridCache, OnLog, proxyManager);
|
||||
|
||||
if (checksearch)
|
||||
{
|
||||
if (AppInit.conf?.online?.checkOnlineSearch != true)
|
||||
return OnError("cikavaideya", proxyManager);
|
||||
|
||||
var checkEpisodes = await invoke.Search(imdb_id, kinopoisk_id, title, original_title, year, serial == 0);
|
||||
if (checkEpisodes != null && checkEpisodes.Count > 0)
|
||||
return Content("data-json=", "text/plain; charset=utf-8");
|
||||
|
||||
return OnError("cikavaideya", proxyManager);
|
||||
}
|
||||
|
||||
var episodesInfo = await invoke.Search(imdb_id, kinopoisk_id, title, original_title, year, serial == 0);
|
||||
if (episodesInfo == null)
|
||||
return Content("CikavaIdeya", "text/html; charset=utf-8");
|
||||
|
||||
if (play)
|
||||
{
|
||||
var episode = episodesInfo.FirstOrDefault(ep => ep.season == s && ep.episode == e);
|
||||
if (serial == 0) // для фильма берем первый
|
||||
episode = episodesInfo.FirstOrDefault();
|
||||
|
||||
if (episode == null)
|
||||
return UpdateService.Validate(Content("CikavaIdeya", "text/html; charset=utf-8"));
|
||||
|
||||
OnLog($"Controller: calling invoke.ParseEpisode with URL: {episode.url}");
|
||||
var playResult = await invoke.ParseEpisode(episode.url);
|
||||
OnLog($"Controller: invoke.ParseEpisode returned playResult with streams.Count={playResult.streams?.Count ?? 0}, iframe_url={playResult.iframe_url}");
|
||||
|
||||
if (playResult.streams != null && playResult.streams.Count > 0)
|
||||
{
|
||||
string streamLink = playResult.streams.First().link;
|
||||
string streamUrl = BuildStreamUrl(init, streamLink);
|
||||
OnLog($"Controller: redirecting to stream URL: {streamUrl}");
|
||||
return UpdateService.Validate(Redirect(streamUrl));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(playResult.iframe_url))
|
||||
{
|
||||
OnLog($"Controller: redirecting to iframe URL: {playResult.iframe_url}");
|
||||
// Для CikavaIdeya ми просто повертаємо iframe URL
|
||||
return UpdateService.Validate(Redirect(playResult.iframe_url));
|
||||
}
|
||||
|
||||
if (playResult.streams != null && playResult.streams.Count > 0)
|
||||
return UpdateService.Validate(Redirect(BuildStreamUrl(init, playResult.streams.First().link)));
|
||||
|
||||
return UpdateService.Validate(Content("CikavaIdeya", "text/html; charset=utf-8"));
|
||||
}
|
||||
|
||||
if (serial == 1)
|
||||
{
|
||||
if (s == -1) // Выбор сезона
|
||||
{
|
||||
var seasons = episodesInfo.GroupBy(ep => ep.season).ToDictionary(k => k.Key, v => v.ToList());
|
||||
OnLog($"Grouped seasons count: {seasons.Count}");
|
||||
foreach (var season in seasons)
|
||||
{
|
||||
OnLog($"Season {season.Key}: {season.Value.Count} episodes");
|
||||
}
|
||||
var season_tpl = new SeasonTpl(seasons.Count);
|
||||
foreach (var season in seasons.OrderBy(i => i.Key))
|
||||
{
|
||||
string link = $"{host}/cikavaideya?imdb_id={imdb_id}&kinopoisk_id={kinopoisk_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&s={season.Key}";
|
||||
season_tpl.Append($"Сезон {season.Key}", link, $"{season.Key}");
|
||||
}
|
||||
OnLog("Before generating season template HTML");
|
||||
string htmlContent = season_tpl.ToHtml();
|
||||
OnLog($"Season template HTML: {htmlContent}");
|
||||
return rjson ? Content(season_tpl.ToJson(), "application/json; charset=utf-8") : Content(htmlContent, "text/html; charset=utf-8");
|
||||
}
|
||||
|
||||
// Выбор эпизода
|
||||
var episodes = episodesInfo.Where(ep => ep.season == s).OrderBy(ep => ep.episode).ToList();
|
||||
var movie_tpl = new MovieTpl(title, original_title, episodes.Count);
|
||||
foreach(var ep in episodes)
|
||||
{
|
||||
string link = $"{host}/cikavaideya?imdb_id={imdb_id}&kinopoisk_id={kinopoisk_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&s={s}&e={ep.episode}&play=true";
|
||||
movie_tpl.Append(ep.title, accsArgs(link), method: "play");
|
||||
}
|
||||
return rjson ? Content(movie_tpl.ToJson(), "application/json; charset=utf-8") : Content(movie_tpl.ToHtml(), "text/html; charset=utf-8");
|
||||
}
|
||||
else // Фильм
|
||||
{
|
||||
string link = $"{host}/cikavaideya?imdb_id={imdb_id}&kinopoisk_id={kinopoisk_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&play=true";
|
||||
var tpl = new MovieTpl(title, original_title, 1);
|
||||
tpl.Append(title, accsArgs(link), method: "play");
|
||||
return rjson ? Content(tpl.ToJson(), "application/json; charset=utf-8") : Content(tpl.ToHtml(), "text/html; charset=utf-8");
|
||||
}
|
||||
}
|
||||
|
||||
async ValueTask<List<EpisodeLinkInfo>> search(OnlinesSettings init, string imdb_id, long kinopoisk_id, string title, string original_title, int year, bool isfilm = false)
|
||||
{
|
||||
string filmTitle = !string.IsNullOrEmpty(title) ? title : original_title;
|
||||
string memKey = $"CikavaIdeya:search:{filmTitle}:{year}:{isfilm}";
|
||||
if (hybridCache.TryGetValue(memKey, out List<EpisodeLinkInfo> res))
|
||||
return res;
|
||||
|
||||
try
|
||||
{
|
||||
// Спочатку шукаємо по title
|
||||
res = await PerformSearch(init, title, year);
|
||||
|
||||
// Якщо нічого не знайдено і є original_title, шукаємо по ньому
|
||||
if ((res == null || res.Count == 0) && !string.IsNullOrEmpty(original_title) && original_title != title)
|
||||
{
|
||||
OnLog($"No results for '{title}', trying search by original title '{original_title}'");
|
||||
res = await PerformSearch(init, original_title, year);
|
||||
// Оновлюємо ключ кешу для original_title
|
||||
if (res != null && res.Count > 0)
|
||||
{
|
||||
memKey = $"CikavaIdeya:search:{original_title}:{year}:{isfilm}";
|
||||
}
|
||||
}
|
||||
|
||||
if (res != null && res.Count > 0)
|
||||
{
|
||||
hybridCache.Set(memKey, res, cacheTime(20));
|
||||
return res;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnLog($"CikavaIdeya search error: {ex.Message}");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
async Task<List<EpisodeLinkInfo>> PerformSearch(OnlinesSettings init, string searchTitle, int year)
|
||||
{
|
||||
try
|
||||
{
|
||||
string searchUrl = $"{init.host}/index.php?do=search&subaction=search&story={HttpUtility.UrlEncode(searchTitle)}";
|
||||
var headers = new List<HeadersModel>() { new HeadersModel("User-Agent", "Mozilla/5.0"), new HeadersModel("Referer", init.host) };
|
||||
|
||||
var searchHtml = await Http.Get(searchUrl, headers: headers);
|
||||
// Перевіряємо, чи є результати пошуку
|
||||
if (searchHtml.Contains("На жаль, пошук на сайті не дав жодних результатів"))
|
||||
{
|
||||
OnLog($"No search results for '{searchTitle}'");
|
||||
return new List<EpisodeLinkInfo>();
|
||||
}
|
||||
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(searchHtml);
|
||||
|
||||
var filmNodes = doc.DocumentNode.SelectNodes("//div[@class='th-item']");
|
||||
if (filmNodes == null)
|
||||
{
|
||||
OnLog($"No film nodes found for '{searchTitle}'");
|
||||
return new List<EpisodeLinkInfo>();
|
||||
}
|
||||
|
||||
string filmUrl = null;
|
||||
foreach (var filmNode in filmNodes)
|
||||
{
|
||||
var titleNode = filmNode.SelectSingleNode(".//div[@class='th-title']");
|
||||
if (titleNode == null || !titleNode.InnerText.Trim().ToLower().Contains(searchTitle.ToLower())) continue;
|
||||
|
||||
var descNode = filmNode.SelectSingleNode(".//div[@class='th-subtitle']");
|
||||
if (year > 0 && (descNode?.InnerText ?? "").Contains(year.ToString()))
|
||||
{
|
||||
var linkNode = filmNode.SelectSingleNode(".//a[@class='th-in']");
|
||||
if (linkNode != null)
|
||||
{
|
||||
filmUrl = linkNode.GetAttributeValue("href", "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (filmUrl == null)
|
||||
{
|
||||
var firstNode = filmNodes.FirstOrDefault()?.SelectSingleNode(".//a[@class='th-in']");
|
||||
if (firstNode != null)
|
||||
filmUrl = firstNode.GetAttributeValue("href", "");
|
||||
}
|
||||
|
||||
if (filmUrl == null)
|
||||
{
|
||||
OnLog($"No film URL found for '{searchTitle}'");
|
||||
return new List<EpisodeLinkInfo>();
|
||||
}
|
||||
|
||||
if (!filmUrl.StartsWith("http"))
|
||||
filmUrl = init.host + filmUrl;
|
||||
|
||||
// Отримуємо список епізодів (для фільмів - один епізод, для серіалів - всі епізоди)
|
||||
var filmHtml = await Http.Get(filmUrl, headers: headers);
|
||||
// Перевіряємо, чи не видалено контент
|
||||
if (filmHtml.Contains("Видалено на прохання правовласника"))
|
||||
{
|
||||
OnLog($"Content removed on copyright holder request: {filmUrl}");
|
||||
return new List<EpisodeLinkInfo>();
|
||||
}
|
||||
|
||||
doc.LoadHtml(filmHtml);
|
||||
|
||||
// Знаходимо JavaScript з даними про епізоди
|
||||
var scriptNodes = doc.DocumentNode.SelectNodes("//script");
|
||||
if (scriptNodes != null)
|
||||
{
|
||||
foreach (var scriptNode in scriptNodes)
|
||||
{
|
||||
var scriptContent = scriptNode.InnerText;
|
||||
if (scriptContent.Contains("switches = Object"))
|
||||
{
|
||||
OnLog($"Found switches script: {scriptContent}");
|
||||
// Парсимо структуру switches
|
||||
var match = Regex.Match(scriptContent, @"switches = Object\((\{.*\})\);", RegexOptions.Singleline);
|
||||
if (match.Success)
|
||||
{
|
||||
string switchesJson = match.Groups[1].Value;
|
||||
OnLog($"Parsed switches JSON: {switchesJson}");
|
||||
// Спрощений парсинг JSON-подібної структури
|
||||
var res = ParseSwitchesJson(switchesJson, init.host, filmUrl);
|
||||
OnLog($"Parsed episodes count: {res.Count}");
|
||||
foreach (var ep in res)
|
||||
{
|
||||
OnLog($"Episode: season={ep.season}, episode={ep.episode}, title={ep.title}, url={ep.url}");
|
||||
}
|
||||
return res;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnLog($"PerformSearch error for '{searchTitle}': {ex.Message}");
|
||||
}
|
||||
return new List<EpisodeLinkInfo>();
|
||||
}
|
||||
|
||||
List<EpisodeLinkInfo> ParseSwitchesJson(string json, string host, string baseUrl)
|
||||
{
|
||||
var result = new List<EpisodeLinkInfo>();
|
||||
|
||||
try
|
||||
{
|
||||
OnLog($"Parsing switches JSON: {json}");
|
||||
// Спрощений парсинг JSON-подібної структури
|
||||
// Приклад для серіалу: {"Player1":{"1 сезон":{"1 серія":"https://ashdi.vip/vod/57364",...},"2 сезон":{"1 серія":"https://ashdi.vip/vod/118170",...}}}
|
||||
// Приклад для фільму: {"Player1":"https://ashdi.vip/vod/162246"}
|
||||
|
||||
// Знаходимо плеєр Player1
|
||||
// Спочатку спробуємо знайти об'єкт Player1
|
||||
var playerObjectMatch = Regex.Match(json, @"""Player1""\s*:\s*(\{(?:[^{}]|(?<open>\{)|(?<-open>\}))+(?(open)(?!)))", RegexOptions.Singleline);
|
||||
if (playerObjectMatch.Success)
|
||||
{
|
||||
string playerContent = playerObjectMatch.Groups[1].Value;
|
||||
OnLog($"Player1 object content: {playerContent}");
|
||||
|
||||
// Це серіал, парсимо сезони
|
||||
var seasonMatches = Regex.Matches(playerContent, @"""([^""]+?сезон[^""]*?)""\s*:\s*\{((?:[^{}]|(?<open>\{)|(?<-open>\}))+(?(open)(?!)))\}", RegexOptions.Singleline);
|
||||
OnLog($"Found {seasonMatches.Count} seasons");
|
||||
foreach (Match seasonMatch in seasonMatches)
|
||||
{
|
||||
string seasonName = seasonMatch.Groups[1].Value;
|
||||
string seasonContent = seasonMatch.Groups[2].Value;
|
||||
OnLog($"Season: {seasonName}, Content: {seasonContent}");
|
||||
|
||||
// Витягуємо номер сезону
|
||||
var seasonNumMatch = Regex.Match(seasonName, @"(\d+)");
|
||||
int seasonNum = seasonNumMatch.Success ? int.Parse(seasonNumMatch.Groups[1].Value) : 1;
|
||||
OnLog($"Season number: {seasonNum}");
|
||||
|
||||
// Парсимо епізоди
|
||||
var episodeMatches = Regex.Matches(seasonContent, @"""([^""]+?)""\s*:\s*""([^""]+?)""", RegexOptions.Singleline);
|
||||
OnLog($"Found {episodeMatches.Count} episodes in season {seasonNum}");
|
||||
foreach (Match episodeMatch in episodeMatches)
|
||||
{
|
||||
string episodeName = episodeMatch.Groups[1].Value;
|
||||
string episodeUrl = episodeMatch.Groups[2].Value;
|
||||
OnLog($"Episode: {episodeName}, URL: {episodeUrl}");
|
||||
|
||||
// Витягуємо номер епізоду
|
||||
var episodeNumMatch = Regex.Match(episodeName, @"(\d+)");
|
||||
int episodeNum = episodeNumMatch.Success ? int.Parse(episodeNumMatch.Groups[1].Value) : 1;
|
||||
|
||||
result.Add(new EpisodeLinkInfo
|
||||
{
|
||||
url = episodeUrl,
|
||||
title = episodeName,
|
||||
season = seasonNum,
|
||||
episode = episodeNum
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Якщо не знайшли об'єкт, спробуємо знайти просте значення
|
||||
var playerStringMatch = Regex.Match(json, @"""Player1""\s*:\s*(""([^""]+)"")", RegexOptions.Singleline);
|
||||
if (playerStringMatch.Success)
|
||||
{
|
||||
string playerContent = playerStringMatch.Groups[1].Value;
|
||||
OnLog($"Player1 string content: {playerContent}");
|
||||
|
||||
// Якщо це фільм (просте значення)
|
||||
if (playerContent.StartsWith("\"") && playerContent.EndsWith("\""))
|
||||
{
|
||||
string filmUrl = playerContent.Trim('"');
|
||||
result.Add(new EpisodeLinkInfo
|
||||
{
|
||||
url = filmUrl,
|
||||
title = "Фільм",
|
||||
season = 1,
|
||||
episode = 1
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
OnLog("Player1 not found");
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnLog($"ParseSwitchesJson error: {ex.Message}");
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
async Task<PlayResult> ParseEpisode(OnlinesSettings init, string url)
|
||||
{
|
||||
var result = new PlayResult() { streams = new List<(string, string)>() };
|
||||
try
|
||||
{
|
||||
// Якщо це вже iframe URL (наприклад, з switches), повертаємо його
|
||||
if (url.Contains("ashdi.vip"))
|
||||
{
|
||||
result.iframe_url = url;
|
||||
return result;
|
||||
}
|
||||
|
||||
// Інакше парсимо сторінку
|
||||
string html = await Http.Get(url, headers: new List<HeadersModel>() { new HeadersModel("User-Agent", "Mozilla/5.0"), new HeadersModel("Referer", init.host) });
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(html);
|
||||
|
||||
var iframe = doc.DocumentNode.SelectSingleNode("//div[@class='video-box']//iframe");
|
||||
if (iframe != null)
|
||||
{
|
||||
string iframeUrl = iframe.GetAttributeValue("src", "").Replace("&", "&");
|
||||
if (iframeUrl.StartsWith("//"))
|
||||
iframeUrl = "https:" + iframeUrl;
|
||||
|
||||
result.iframe_url = iframeUrl;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
OnLog($"ParseEpisode error: {ex.Message}");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
string BuildStreamUrl(OnlinesSettings init, string streamLink)
|
||||
{
|
||||
string link = StripLampacArgs(streamLink?.Trim());
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
return ApnHelper.WrapUrl(init, link);
|
||||
|
||||
var noApn = (OnlinesSettings)init.Clone();
|
||||
noApn.apnstream = false;
|
||||
noApn.apn = null;
|
||||
return HostStreamProxy(noApn, link);
|
||||
}
|
||||
|
||||
return HostStreamProxy(init, link);
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,204 +0,0 @@
|
||||
using Newtonsoft.Json;
|
||||
using Shared;
|
||||
using Shared.Engine;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Shared;
|
||||
using Shared.Models.Online.Settings;
|
||||
using Shared.Models.Module;
|
||||
|
||||
using Newtonsoft.Json;
|
||||
using Shared;
|
||||
using Shared.Engine;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis.Scripting;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Shared.Models;
|
||||
using Shared.Models.Events;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Net.Mime;
|
||||
using System.Net.Security;
|
||||
using System.Security.Authentication;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace CikavaIdeya
|
||||
{
|
||||
public class ModInit
|
||||
{
|
||||
public static double Version => 010100100100100101010000;
|
||||
|
||||
public static OnlinesSettings CikavaIdeya;
|
||||
public static bool ApnHostProvided;
|
||||
|
||||
public static OnlinesSettings Settings
|
||||
{
|
||||
get => CikavaIdeya;
|
||||
set => CikavaIdeya = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// модуль загружен
|
||||
/// </summary>
|
||||
public static void loaded(InitspaceModel initspace)
|
||||
{
|
||||
|
||||
|
||||
CikavaIdeya = new OnlinesSettings("CikavaIdeya", "https://cikava-ideya.top", streamproxy: false, useproxy: false)
|
||||
{
|
||||
displayname = "ЦікаваІдея",
|
||||
displayindex = 0,
|
||||
proxy = new Shared.Models.Base.ProxySettings()
|
||||
{
|
||||
useAuth = true,
|
||||
username = "a",
|
||||
password = "a",
|
||||
list = new string[] { "socks5://IP:PORT" }
|
||||
}
|
||||
};
|
||||
var conf = ModuleInvoke.Conf("CikavaIdeya", CikavaIdeya);
|
||||
bool hasApn = ApnHelper.TryGetInitConf(conf, out bool apnEnabled, out string apnHost);
|
||||
conf.Remove("apn");
|
||||
conf.Remove("apn_host");
|
||||
CikavaIdeya = conf.ToObject<OnlinesSettings>();
|
||||
if (hasApn)
|
||||
ApnHelper.ApplyInitConf(apnEnabled, apnHost, CikavaIdeya);
|
||||
ApnHostProvided = hasApn && apnEnabled && !string.IsNullOrWhiteSpace(apnHost);
|
||||
if (hasApn && apnEnabled)
|
||||
{
|
||||
CikavaIdeya.streamproxy = false;
|
||||
}
|
||||
else if (CikavaIdeya.streamproxy)
|
||||
{
|
||||
CikavaIdeya.apnstream = false;
|
||||
CikavaIdeya.apn = null;
|
||||
}
|
||||
|
||||
// Виводити "уточнити пошук"
|
||||
AppInit.conf.online.with_search.Add("cikavaideya");
|
||||
}
|
||||
}
|
||||
|
||||
public static class UpdateService
|
||||
{
|
||||
private static readonly string _connectUrl = "https://lmcuk.lampame.v6.rocks/stats";
|
||||
|
||||
private static ConnectResponse? Connect = null;
|
||||
private static DateTime? _connectTime = null;
|
||||
private static DateTime? _disconnectTime = null;
|
||||
|
||||
private static readonly TimeSpan _resetInterval = TimeSpan.FromHours(4);
|
||||
private static Timer? _resetTimer = null;
|
||||
|
||||
private static readonly object _lock = new();
|
||||
|
||||
public static async Task ConnectAsync(string host, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (_connectTime is not null || Connect?.IsUpdateUnavailable == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
if (_connectTime is not null || Connect?.IsUpdateUnavailable == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_connectTime = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var handler = new SocketsHttpHandler
|
||||
{
|
||||
SslOptions = new SslClientAuthenticationOptions
|
||||
{
|
||||
RemoteCertificateValidationCallback = (_, _, _, _) => true,
|
||||
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13
|
||||
}
|
||||
};
|
||||
|
||||
using var client = new HttpClient(handler);
|
||||
client.Timeout = TimeSpan.FromSeconds(15);
|
||||
|
||||
var request = new
|
||||
{
|
||||
Host = host,
|
||||
Module = ModInit.Settings.plugin,
|
||||
Version = ModInit.Version,
|
||||
};
|
||||
|
||||
var requestJson = JsonConvert.SerializeObject(request, Formatting.None);
|
||||
var requestContent = new StringContent(requestJson, Encoding.UTF8, MediaTypeNames.Application.Json);
|
||||
|
||||
var response = await client
|
||||
.PostAsync(_connectUrl, requestContent, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
if (response.Content.Headers.ContentLength > 0)
|
||||
{
|
||||
var responseText = await response.Content
|
||||
.ReadAsStringAsync(cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
Connect = JsonConvert.DeserializeObject<ConnectResponse>(responseText);
|
||||
}
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
_resetTimer?.Dispose();
|
||||
_resetTimer = null;
|
||||
|
||||
if (Connect?.IsUpdateUnavailable != true)
|
||||
{
|
||||
_resetTimer = new Timer(ResetConnectTime, null, _resetInterval, Timeout.InfiniteTimeSpan);
|
||||
}
|
||||
else
|
||||
{
|
||||
_disconnectTime = Connect?.IsNoiseEnabled == true
|
||||
? DateTime.UtcNow.AddHours(Random.Shared.Next(1, 16))
|
||||
: DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ResetConnectTime(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ResetConnectTime(object? state)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_connectTime = null;
|
||||
Connect = null;
|
||||
|
||||
_resetTimer?.Dispose();
|
||||
_resetTimer = null;
|
||||
}
|
||||
}
|
||||
public static bool IsDisconnected()
|
||||
{
|
||||
return _disconnectTime is not null
|
||||
&& DateTime.UtcNow >= _disconnectTime;
|
||||
}
|
||||
|
||||
public static ActionResult Validate(ActionResult result)
|
||||
{
|
||||
return IsDisconnected()
|
||||
? throw new JsonReaderException($"Disconnect error: {Guid.CreateVersion7()}")
|
||||
: result;
|
||||
}
|
||||
}
|
||||
|
||||
public record ConnectResponse(bool IsUpdateUnavailable, bool IsNoiseEnabled);
|
||||
}
|
||||
@ -1,16 +0,0 @@
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace CikavaIdeya.Models
|
||||
{
|
||||
public class EpisodeModel
|
||||
{
|
||||
[JsonPropertyName("episode_number")]
|
||||
public int EpisodeNumber { get; set; }
|
||||
|
||||
[JsonPropertyName("title")]
|
||||
public string Title { get; set; }
|
||||
|
||||
[JsonPropertyName("url")]
|
||||
public string Url { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,19 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CikavaIdeya.Models
|
||||
{
|
||||
public class EpisodeLinkInfo
|
||||
{
|
||||
public string url { get; set; }
|
||||
public string title { get; set; }
|
||||
public int season { get; set; }
|
||||
public int episode { get; set; }
|
||||
}
|
||||
|
||||
public class PlayResult
|
||||
{
|
||||
public string iframe_url { get; set; }
|
||||
public List<(string link, string quality)> streams { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,17 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace CikavaIdeya.Models
|
||||
{
|
||||
public class CikavaIdeyaPlayerModel
|
||||
{
|
||||
[JsonPropertyName("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonPropertyName("qualities")]
|
||||
public List<(string link, string quality)> Qualities { get; set; }
|
||||
|
||||
[JsonPropertyName("subtitles")]
|
||||
public Shared.Models.Templates.SubtitleTpl? Subtitles { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,14 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text.Json.Serialization;
|
||||
|
||||
namespace CikavaIdeya.Models
|
||||
{
|
||||
public class SeasonModel
|
||||
{
|
||||
[JsonPropertyName("season_number")]
|
||||
public int SeasonNumber { get; set; }
|
||||
|
||||
[JsonPropertyName("episodes")]
|
||||
public List<EpisodeModel> Episodes { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,49 +0,0 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Shared.Models;
|
||||
using Shared.Models.Base;
|
||||
using Shared.Models.Module;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace CikavaIdeya
|
||||
{
|
||||
public class OnlineApi
|
||||
{
|
||||
public static List<(string name, string url, string plugin, int index)> Invoke(
|
||||
HttpContext httpContext,
|
||||
IMemoryCache memoryCache,
|
||||
RequestModel requestInfo,
|
||||
string host,
|
||||
OnlineEventsModel args)
|
||||
{
|
||||
long.TryParse(args.id, out long tmdbid);
|
||||
return Events(host, tmdbid, args.imdb_id, args.kinopoisk_id, args.title, args.original_title, args.original_language, args.year, args.source, args.serial, args.account_email);
|
||||
}
|
||||
|
||||
public static List<(string name, string url, string plugin, int index)> Events(string host, long id, string imdb_id, long kinopoisk_id, string title, string original_title, string original_language, int year, string source, int serial, string account_email)
|
||||
{
|
||||
var online = new List<(string name, string url, string plugin, int index)>();
|
||||
|
||||
var init = ModInit.CikavaIdeya;
|
||||
|
||||
// Визначення isAnime згідно Lampac (Deepwiki): original_language == "ja" або "zh"
|
||||
bool hasLang = !string.IsNullOrEmpty(original_language);
|
||||
bool isanime = hasLang && (original_language == "ja" || original_language == "zh");
|
||||
|
||||
// CikavaIdeya — не-аніме провайдер. Додаємо якщо:
|
||||
// - загальний пошук (serial == -1), або
|
||||
// - контент НЕ аніме (!isanime), або
|
||||
// - мова невідома (немає original_language)
|
||||
if (init.enable && !init.rip && (serial == -1 || !isanime || !hasLang))
|
||||
{
|
||||
string url = init.overridehost;
|
||||
if (string.IsNullOrEmpty(url) || UpdateService.IsDisconnected())
|
||||
url = $"{host}/cikavaideya";
|
||||
|
||||
online.Add((init.displayname, url, "cikavaideya", init.displayindex));
|
||||
}
|
||||
|
||||
return online;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
{
|
||||
"enable": true,
|
||||
"version": 3,
|
||||
"initspace": "CikavaIdeya.ModInit",
|
||||
"online": "CikavaIdeya.OnlineApi"
|
||||
}
|
||||
@ -1,86 +0,0 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using Shared.Models.Base;
|
||||
using System;
|
||||
using System.Web;
|
||||
|
||||
namespace Shared.Engine
|
||||
{
|
||||
public static class ApnHelper
|
||||
{
|
||||
public const string DefaultHost = "https://tut.im/proxy.php?url={encodeurl}";
|
||||
|
||||
public static bool TryGetInitConf(JObject conf, out bool enabled, out string host)
|
||||
{
|
||||
enabled = false;
|
||||
host = null;
|
||||
|
||||
if (conf == null)
|
||||
return false;
|
||||
|
||||
if (!conf.TryGetValue("apn", out var apnToken) || apnToken?.Type != JTokenType.Boolean)
|
||||
return false;
|
||||
|
||||
enabled = apnToken.Value<bool>();
|
||||
host = conf.Value<string>("apn_host");
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void ApplyInitConf(bool enabled, string host, BaseSettings init)
|
||||
{
|
||||
if (init == null)
|
||||
return;
|
||||
|
||||
if (!enabled)
|
||||
{
|
||||
init.apnstream = false;
|
||||
init.apn = null;
|
||||
return;
|
||||
}
|
||||
|
||||
if (string.IsNullOrWhiteSpace(host))
|
||||
host = DefaultHost;
|
||||
|
||||
if (init.apn == null)
|
||||
init.apn = new ApnConf();
|
||||
|
||||
init.apn.host = host;
|
||||
init.apnstream = true;
|
||||
}
|
||||
|
||||
public static bool IsEnabled(BaseSettings init)
|
||||
{
|
||||
return init?.apnstream == true && !string.IsNullOrWhiteSpace(init?.apn?.host);
|
||||
}
|
||||
|
||||
public static bool IsAshdiUrl(string url)
|
||||
{
|
||||
return !string.IsNullOrEmpty(url) &&
|
||||
url.IndexOf("ashdi.vip", StringComparison.OrdinalIgnoreCase) >= 0;
|
||||
}
|
||||
|
||||
public static string WrapUrl(BaseSettings init, string url)
|
||||
{
|
||||
if (!IsEnabled(init))
|
||||
return url;
|
||||
|
||||
return BuildUrl(init.apn.host, url);
|
||||
}
|
||||
|
||||
public static string BuildUrl(string host, string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(host) || string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
if (host.Contains("{encodeurl}"))
|
||||
return host.Replace("{encodeurl}", HttpUtility.UrlEncode(url));
|
||||
|
||||
if (host.Contains("{encode_uri}"))
|
||||
return host.Replace("{encode_uri}", HttpUtility.UrlEncode(url));
|
||||
|
||||
if (host.Contains("{uri}"))
|
||||
return host.Replace("{uri}", url);
|
||||
|
||||
return $"{host.TrimEnd('/')}/{url}";
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,218 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Shared;
|
||||
using Shared.Engine;
|
||||
using Shared.Models.Online.Settings;
|
||||
using Shared.Models.Templates;
|
||||
using UAKino.Models;
|
||||
|
||||
namespace UAKino.Controllers
|
||||
{
|
||||
public class Controller : BaseOnlineController
|
||||
{
|
||||
ProxyManager proxyManager;
|
||||
|
||||
public Controller() : base(ModInit.Settings)
|
||||
{
|
||||
proxyManager = new ProxyManager(ModInit.UAKino);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("uakino")]
|
||||
async public Task<ActionResult> Index(long id, string imdb_id, long kinopoisk_id, string title, string original_title, string original_language, int year, string source, int serial, string account_email, string t, bool rjson = false, string href = null, bool checksearch = false)
|
||||
{
|
||||
await UpdateService.ConnectAsync(host);
|
||||
|
||||
var init = await loadKit(ModInit.UAKino);
|
||||
if (!init.enable)
|
||||
return Forbid();
|
||||
|
||||
var invoke = new UAKinoInvoke(init, hybridCache, OnLog, proxyManager);
|
||||
|
||||
if (checksearch)
|
||||
{
|
||||
if (AppInit.conf?.online?.checkOnlineSearch != true)
|
||||
return OnError("uakino", proxyManager);
|
||||
|
||||
var searchResults = await invoke.Search(title, original_title, serial);
|
||||
if (searchResults != null && searchResults.Count > 0)
|
||||
return Content("data-json=", "text/plain; charset=utf-8");
|
||||
|
||||
return OnError("uakino", proxyManager);
|
||||
}
|
||||
|
||||
string itemUrl = href;
|
||||
if (string.IsNullOrEmpty(itemUrl))
|
||||
{
|
||||
var searchResults = await invoke.Search(title, original_title, serial);
|
||||
if (searchResults == null || searchResults.Count == 0)
|
||||
return OnError("uakino", proxyManager);
|
||||
|
||||
if (searchResults.Count > 1)
|
||||
{
|
||||
var similar_tpl = new SimilarTpl(searchResults.Count);
|
||||
foreach (var res in searchResults)
|
||||
{
|
||||
string link = $"{host}/uakino?imdb_id={imdb_id}&kinopoisk_id={kinopoisk_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial={serial}&href={HttpUtility.UrlEncode(res.Url)}";
|
||||
similar_tpl.Append(res.Title, string.Empty, string.Empty, link, res.Poster);
|
||||
}
|
||||
|
||||
return rjson ? Content(similar_tpl.ToJson(), "application/json; charset=utf-8") : Content(similar_tpl.ToHtml(), "text/html; charset=utf-8");
|
||||
}
|
||||
|
||||
itemUrl = searchResults[0].Url;
|
||||
}
|
||||
|
||||
if (serial == 1)
|
||||
{
|
||||
var playlist = await invoke.GetPlaylist(itemUrl);
|
||||
if (playlist == null || playlist.Count == 0)
|
||||
return OnError("uakino", proxyManager);
|
||||
|
||||
var voiceGroups = playlist
|
||||
.GroupBy(p => string.IsNullOrEmpty(p.Voice) ? "Основне" : p.Voice)
|
||||
.Select(g => (key: g.Key, episodes: g.ToList()))
|
||||
.ToList();
|
||||
|
||||
if (voiceGroups.Count == 0)
|
||||
return OnError("uakino", proxyManager);
|
||||
|
||||
if (string.IsNullOrEmpty(t))
|
||||
t = voiceGroups.First().key;
|
||||
|
||||
var voice_tpl = new VoiceTpl();
|
||||
foreach (var voice in voiceGroups)
|
||||
{
|
||||
string voiceLink = $"{host}/uakino?imdb_id={imdb_id}&kinopoisk_id={kinopoisk_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&year={year}&serial=1&t={HttpUtility.UrlEncode(voice.key)}&href={HttpUtility.UrlEncode(itemUrl)}";
|
||||
voice_tpl.Append(voice.key, voice.key == t, voiceLink);
|
||||
}
|
||||
|
||||
var selected = voiceGroups.FirstOrDefault(v => v.key == t);
|
||||
if (selected.episodes == null || selected.episodes.Count == 0)
|
||||
return OnError("uakino", proxyManager);
|
||||
|
||||
var episode_tpl = new EpisodeTpl();
|
||||
int index = 1;
|
||||
foreach (var ep in selected.episodes.OrderBy(e => UAKinoInvoke.TryParseEpisodeNumber(e.Title) ?? int.MaxValue))
|
||||
{
|
||||
int episodeNumber = UAKinoInvoke.TryParseEpisodeNumber(ep.Title) ?? index;
|
||||
string episodeName = string.IsNullOrEmpty(ep.Title) ? $"Епізод {episodeNumber}" : ep.Title;
|
||||
string callUrl = $"{host}/uakino/play?url={HttpUtility.UrlEncode(ep.Url)}&title={HttpUtility.UrlEncode(title ?? original_title)}";
|
||||
if (!string.IsNullOrEmpty(ep.Url) && ep.Url.Contains("ashdi.vip", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
string playUrl = BuildStreamUrl(init, ep.Url);
|
||||
episode_tpl.Append(
|
||||
episodeName,
|
||||
title ?? original_title,
|
||||
"1",
|
||||
episodeNumber.ToString("D2"),
|
||||
playUrl
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
episode_tpl.Append(
|
||||
episodeName,
|
||||
title ?? original_title,
|
||||
"1",
|
||||
episodeNumber.ToString("D2"),
|
||||
accsArgs(callUrl),
|
||||
"call",
|
||||
streamlink: accsArgs($"{callUrl}&play=true")
|
||||
);
|
||||
}
|
||||
index++;
|
||||
}
|
||||
|
||||
episode_tpl.Append(voice_tpl);
|
||||
if (rjson)
|
||||
return Content(episode_tpl.ToJson(), "application/json; charset=utf-8");
|
||||
|
||||
return Content(episode_tpl.ToHtml(), "text/html; charset=utf-8");
|
||||
}
|
||||
else
|
||||
{
|
||||
string playerUrl = await invoke.GetPlayerUrl(itemUrl);
|
||||
if (string.IsNullOrEmpty(playerUrl))
|
||||
{
|
||||
var playlist = await invoke.GetPlaylist(itemUrl);
|
||||
playerUrl = playlist?.FirstOrDefault()?.Url;
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(playerUrl))
|
||||
return OnError("uakino", proxyManager);
|
||||
|
||||
var movie_tpl = new MovieTpl(title, original_title);
|
||||
string callUrl = $"{host}/uakino/play?url={HttpUtility.UrlEncode(playerUrl)}&title={HttpUtility.UrlEncode(title ?? original_title)}";
|
||||
movie_tpl.Append(string.IsNullOrEmpty(title) ? "UAKino" : title, accsArgs(callUrl), "call");
|
||||
|
||||
return rjson ? Content(movie_tpl.ToJson(), "application/json; charset=utf-8") : Content(movie_tpl.ToHtml(), "text/html; charset=utf-8");
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("uakino/play")]
|
||||
async public Task<ActionResult> Play(string url, string title)
|
||||
{
|
||||
await UpdateService.ConnectAsync(host);
|
||||
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return OnError("uakino", proxyManager);
|
||||
|
||||
var init = await loadKit(ModInit.UAKino);
|
||||
if (!init.enable)
|
||||
return Forbid();
|
||||
|
||||
var invoke = new UAKinoInvoke(init, hybridCache, OnLog, proxyManager);
|
||||
var result = await invoke.ParsePlayer(url);
|
||||
if (result == null || string.IsNullOrEmpty(result.File))
|
||||
return OnError("uakino", proxyManager);
|
||||
|
||||
string streamUrl = BuildStreamUrl(init, result.File);
|
||||
string jsonResult = $"{{\"method\":\"play\",\"url\":\"{streamUrl}\",\"title\":\"{title ?? ""}\"}}";
|
||||
return UpdateService.Validate(Content(jsonResult, "application/json; charset=utf-8"));
|
||||
}
|
||||
|
||||
private static string StripLampacArgs(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return url;
|
||||
|
||||
string cleaned = System.Text.RegularExpressions.Regex.Replace(
|
||||
url,
|
||||
@"([?&])(account_email|uid|nws_id)=[^&]*",
|
||||
"$1",
|
||||
System.Text.RegularExpressions.RegexOptions.IgnoreCase
|
||||
);
|
||||
|
||||
cleaned = cleaned.Replace("?&", "?").Replace("&&", "&").TrimEnd('?', '&');
|
||||
return cleaned;
|
||||
}
|
||||
|
||||
string BuildStreamUrl(OnlinesSettings init, string streamLink)
|
||||
{
|
||||
string link = streamLink?.Trim();
|
||||
if (string.IsNullOrEmpty(link))
|
||||
return link;
|
||||
|
||||
link = StripLampacArgs(link);
|
||||
|
||||
if (ApnHelper.IsEnabled(init))
|
||||
{
|
||||
if (ModInit.ApnHostProvided || ApnHelper.IsAshdiUrl(link))
|
||||
return ApnHelper.WrapUrl(init, link);
|
||||
|
||||
var noApn = (OnlinesSettings)init.Clone();
|
||||
noApn.apnstream = false;
|
||||
noApn.apn = null;
|
||||
return HostStreamProxy(noApn, link, proxy: proxyManager.Get());
|
||||
}
|
||||
|
||||
return HostStreamProxy(init, link, proxy: proxyManager.Get());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,197 +0,0 @@
|
||||
using Shared;
|
||||
using Shared.Engine;
|
||||
using Shared.Models.Online.Settings;
|
||||
using Shared.Models.Module;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.CodeAnalysis.Scripting;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Newtonsoft.Json;
|
||||
using Shared.Models;
|
||||
using Shared.Models.Events;
|
||||
using System;
|
||||
using System.Net.Http;
|
||||
using System.Net.Mime;
|
||||
using System.Net.Security;
|
||||
using System.Security.Authentication;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
|
||||
namespace UAKino
|
||||
{
|
||||
public class ModInit
|
||||
{
|
||||
public static double Version => 010100100100100101010000;
|
||||
|
||||
public static OnlinesSettings UAKino;
|
||||
public static bool ApnHostProvided;
|
||||
|
||||
public static OnlinesSettings Settings
|
||||
{
|
||||
get => UAKino;
|
||||
set => UAKino = value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// модуль загружен
|
||||
/// </summary>
|
||||
public static void loaded(InitspaceModel initspace)
|
||||
{
|
||||
|
||||
|
||||
UAKino = new OnlinesSettings("UAKino", "https://uakino.best", streamproxy: false, useproxy: false)
|
||||
{
|
||||
displayname = "UAKino",
|
||||
displayindex = 0,
|
||||
proxy = new Shared.Models.Base.ProxySettings()
|
||||
{
|
||||
useAuth = true,
|
||||
username = "",
|
||||
password = "",
|
||||
list = new string[] { "socks5://ip:port" }
|
||||
}
|
||||
};
|
||||
var conf = ModuleInvoke.Conf("UAKino", UAKino);
|
||||
bool hasApn = ApnHelper.TryGetInitConf(conf, out bool apnEnabled, out string apnHost);
|
||||
conf.Remove("apn");
|
||||
conf.Remove("apn_host");
|
||||
UAKino = conf.ToObject<OnlinesSettings>();
|
||||
if (hasApn)
|
||||
ApnHelper.ApplyInitConf(apnEnabled, apnHost, UAKino);
|
||||
ApnHostProvided = hasApn && apnEnabled && !string.IsNullOrWhiteSpace(apnHost);
|
||||
if (hasApn && apnEnabled)
|
||||
{
|
||||
UAKino.streamproxy = false;
|
||||
}
|
||||
else if (UAKino.streamproxy)
|
||||
{
|
||||
UAKino.apnstream = false;
|
||||
UAKino.apn = null;
|
||||
}
|
||||
|
||||
// Виводити "уточнити пошук"
|
||||
AppInit.conf.online.with_search.Add("uakino");
|
||||
}
|
||||
}
|
||||
|
||||
public static class UpdateService
|
||||
{
|
||||
private static readonly string _connectUrl = "https://lmcuk.lampame.v6.rocks/stats";
|
||||
|
||||
private static ConnectResponse? Connect = null;
|
||||
private static DateTime? _connectTime = null;
|
||||
private static DateTime? _disconnectTime = null;
|
||||
|
||||
private static readonly TimeSpan _resetInterval = TimeSpan.FromHours(4);
|
||||
private static Timer? _resetTimer = null;
|
||||
|
||||
private static readonly object _lock = new();
|
||||
|
||||
public static async Task ConnectAsync(string host, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (_connectTime is not null || Connect?.IsUpdateUnavailable == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
if (_connectTime is not null || Connect?.IsUpdateUnavailable == true)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_connectTime = DateTime.UtcNow;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
using var handler = new SocketsHttpHandler
|
||||
{
|
||||
SslOptions = new SslClientAuthenticationOptions
|
||||
{
|
||||
RemoteCertificateValidationCallback = (_, _, _, _) => true,
|
||||
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13
|
||||
}
|
||||
};
|
||||
|
||||
using var client = new HttpClient(handler);
|
||||
client.Timeout = TimeSpan.FromSeconds(15);
|
||||
|
||||
var request = new
|
||||
{
|
||||
Host = host,
|
||||
Module = ModInit.Settings.plugin,
|
||||
Version = ModInit.Version,
|
||||
};
|
||||
|
||||
var requestJson = JsonConvert.SerializeObject(request, Formatting.None);
|
||||
var requestContent = new StringContent(requestJson, Encoding.UTF8, MediaTypeNames.Application.Json);
|
||||
|
||||
var response = await client
|
||||
.PostAsync(_connectUrl, requestContent, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
if (response.Content.Headers.ContentLength > 0)
|
||||
{
|
||||
var responseText = await response.Content
|
||||
.ReadAsStringAsync(cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
|
||||
Connect = JsonConvert.DeserializeObject<ConnectResponse>(responseText);
|
||||
}
|
||||
|
||||
lock (_lock)
|
||||
{
|
||||
_resetTimer?.Dispose();
|
||||
_resetTimer = null;
|
||||
|
||||
if (Connect?.IsUpdateUnavailable != true)
|
||||
{
|
||||
_resetTimer = new Timer(ResetConnectTime, null, _resetInterval, Timeout.InfiniteTimeSpan);
|
||||
}
|
||||
else
|
||||
{
|
||||
_disconnectTime = Connect?.IsNoiseEnabled == true
|
||||
? DateTime.UtcNow.AddHours(Random.Shared.Next(1, 16))
|
||||
: DateTime.UtcNow;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
ResetConnectTime(null);
|
||||
}
|
||||
}
|
||||
|
||||
private static void ResetConnectTime(object? state)
|
||||
{
|
||||
lock (_lock)
|
||||
{
|
||||
_connectTime = null;
|
||||
Connect = null;
|
||||
|
||||
_resetTimer?.Dispose();
|
||||
_resetTimer = null;
|
||||
}
|
||||
}
|
||||
public static bool IsDisconnected()
|
||||
{
|
||||
return _disconnectTime is not null
|
||||
&& DateTime.UtcNow >= _disconnectTime;
|
||||
}
|
||||
|
||||
public static ActionResult Validate(ActionResult result)
|
||||
{
|
||||
return IsDisconnected()
|
||||
? throw new JsonReaderException($"Disconnect error: {Guid.CreateVersion7()}")
|
||||
: result;
|
||||
}
|
||||
}
|
||||
|
||||
public record ConnectResponse(bool IsUpdateUnavailable, bool IsNoiseEnabled);
|
||||
}
|
||||
@ -1,31 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UAKino.Models
|
||||
{
|
||||
public class SearchResult
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string Poster { get; set; }
|
||||
public string Season { get; set; }
|
||||
}
|
||||
|
||||
public class PlaylistItem
|
||||
{
|
||||
public string Title { get; set; }
|
||||
public string Url { get; set; }
|
||||
public string Voice { get; set; }
|
||||
}
|
||||
|
||||
public class SubtitleInfo
|
||||
{
|
||||
public string Lang { get; set; }
|
||||
public string Url { get; set; }
|
||||
}
|
||||
|
||||
public class PlayerResult
|
||||
{
|
||||
public string File { get; set; }
|
||||
public List<SubtitleInfo> Subtitles { get; set; } = new();
|
||||
}
|
||||
}
|
||||
@ -1,40 +0,0 @@
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.Extensions.Caching.Memory;
|
||||
using Shared.Models;
|
||||
using Shared.Models.Base;
|
||||
using Shared.Models.Module;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace UAKino
|
||||
{
|
||||
public class OnlineApi
|
||||
{
|
||||
public static List<(string name, string url, string plugin, int index)> Invoke(
|
||||
HttpContext httpContext,
|
||||
IMemoryCache memoryCache,
|
||||
RequestModel requestInfo,
|
||||
string host,
|
||||
OnlineEventsModel args)
|
||||
{
|
||||
long.TryParse(args.id, out long tmdbid);
|
||||
return Events(host, tmdbid, args.imdb_id, args.kinopoisk_id, args.title, args.original_title, args.original_language, args.year, args.source, args.serial, args.account_email);
|
||||
}
|
||||
|
||||
public static List<(string name, string url, string plugin, int index)> Events(string host, long id, string imdb_id, long kinopoisk_id, string title, string original_title, string original_language, int year, string source, int serial, string account_email)
|
||||
{
|
||||
var online = new List<(string name, string url, string plugin, int index)>();
|
||||
|
||||
var init = ModInit.UAKino;
|
||||
if (init.enable && !init.rip)
|
||||
{
|
||||
string url = init.overridehost;
|
||||
if (string.IsNullOrEmpty(url) || UpdateService.IsDisconnected())
|
||||
url = $"{host}/uakino";
|
||||
|
||||
online.Add((init.displayname, url, "uakino", init.displayindex));
|
||||
}
|
||||
|
||||
return online;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,15 +0,0 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<OutputType>library</OutputType>
|
||||
<IsPackable>true</IsPackable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Reference Include="Shared">
|
||||
<HintPath>..\..\Shared.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@ -1,498 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
using System.Net.Security;
|
||||
using System.Security.Authentication;
|
||||
using System.Text;
|
||||
using System.Text.Json;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web;
|
||||
using HtmlAgilityPack;
|
||||
using Shared;
|
||||
using Shared.Engine;
|
||||
using Shared.Models;
|
||||
using Shared.Models.Online.Settings;
|
||||
using UAKino.Models;
|
||||
|
||||
namespace UAKino
|
||||
{
|
||||
public class UAKinoInvoke
|
||||
{
|
||||
private const string PlaylistPath = "/engine/ajax/playlists.php";
|
||||
private const string PlaylistField = "playlist";
|
||||
private const string BlacklistRegex = "(/news/)|(/franchise/)";
|
||||
private readonly OnlinesSettings _init;
|
||||
private readonly IHybridCache _hybridCache;
|
||||
private readonly Action<string> _onLog;
|
||||
private readonly ProxyManager _proxyManager;
|
||||
|
||||
public UAKinoInvoke(OnlinesSettings init, IHybridCache hybridCache, Action<string> onLog, ProxyManager proxyManager)
|
||||
{
|
||||
_init = init;
|
||||
_hybridCache = hybridCache;
|
||||
_onLog = onLog;
|
||||
_proxyManager = proxyManager;
|
||||
}
|
||||
|
||||
public async Task<List<SearchResult>> Search(string title, string original_title, int serial)
|
||||
{
|
||||
var queries = new List<string>();
|
||||
if (!string.IsNullOrEmpty(title))
|
||||
queries.Add(title);
|
||||
if (!string.IsNullOrEmpty(original_title) && !queries.Contains(original_title))
|
||||
queries.Add(original_title);
|
||||
|
||||
if (queries.Count == 0)
|
||||
return null;
|
||||
|
||||
string memKey = $"UAKino:search:{string.Join("|", queries)}:{serial}";
|
||||
if (_hybridCache.TryGetValue(memKey, out List<SearchResult> cached))
|
||||
return cached;
|
||||
|
||||
var results = new List<SearchResult>();
|
||||
var seen = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
foreach (var query in queries)
|
||||
{
|
||||
try
|
||||
{
|
||||
string searchUrl = $"{_init.host}/index.php?do=search&subaction=search&story={HttpUtility.UrlEncode(query)}";
|
||||
var headers = new List<HeadersModel>()
|
||||
{
|
||||
new HeadersModel("User-Agent", "Mozilla/5.0"),
|
||||
new HeadersModel("Referer", _init.host)
|
||||
};
|
||||
|
||||
_onLog?.Invoke($"UAKino search: {searchUrl}");
|
||||
string html = await GetString(searchUrl, headers);
|
||||
if (string.IsNullOrEmpty(html))
|
||||
continue;
|
||||
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(html);
|
||||
|
||||
var nodes = doc.DocumentNode.SelectNodes("//div[contains(@class,'movie-item') and contains(@class,'short-item')]");
|
||||
if (nodes == null)
|
||||
continue;
|
||||
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
var titleNode = node.SelectSingleNode(".//a[contains(@class,'movie-title')] | .//a[contains(@class,'full-movie')]");
|
||||
string itemTitle = CleanText(titleNode?.InnerText);
|
||||
string href = NormalizeUrl(titleNode?.GetAttributeValue("href", ""));
|
||||
if (string.IsNullOrEmpty(itemTitle))
|
||||
{
|
||||
var altTitle = node.SelectSingleNode(".//div[contains(@class,'full-movie-title')]");
|
||||
itemTitle = CleanText(altTitle?.InnerText);
|
||||
}
|
||||
|
||||
if (string.IsNullOrEmpty(itemTitle) || string.IsNullOrEmpty(href) || IsBlacklisted(href))
|
||||
continue;
|
||||
|
||||
if (serial == 1 && !IsSeriesUrl(href))
|
||||
continue;
|
||||
if (serial == 0 && !IsMovieUrl(href))
|
||||
continue;
|
||||
|
||||
string seasonText = CleanText(node.SelectSingleNode(".//div[contains(@class,'full-season')]")?.InnerText);
|
||||
if (!string.IsNullOrEmpty(seasonText) && !itemTitle.Contains(seasonText, StringComparison.OrdinalIgnoreCase))
|
||||
itemTitle = $"{itemTitle} ({seasonText})";
|
||||
|
||||
string poster = ExtractPoster(node);
|
||||
|
||||
if (seen.Contains(href))
|
||||
continue;
|
||||
seen.Add(href);
|
||||
|
||||
results.Add(new SearchResult
|
||||
{
|
||||
Title = itemTitle,
|
||||
Url = href,
|
||||
Poster = poster,
|
||||
Season = seasonText
|
||||
});
|
||||
}
|
||||
|
||||
if (results.Count > 0)
|
||||
break;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_onLog?.Invoke($"UAKino search error: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
if (results.Count > 0)
|
||||
_hybridCache.Set(memKey, results, cacheTime(20, init: _init));
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
public async Task<List<PlaylistItem>> GetPlaylist(string href)
|
||||
{
|
||||
string newsId = ExtractNewsId(href);
|
||||
if (string.IsNullOrEmpty(newsId))
|
||||
return null;
|
||||
|
||||
string memKey = $"UAKino:playlist:{newsId}";
|
||||
if (_hybridCache.TryGetValue(memKey, out List<PlaylistItem> cached))
|
||||
return cached;
|
||||
|
||||
string url = BuildPlaylistUrl(newsId);
|
||||
var headers = new List<HeadersModel>()
|
||||
{
|
||||
new HeadersModel("User-Agent", "Mozilla/5.0"),
|
||||
new HeadersModel("Referer", href ?? _init.host),
|
||||
new HeadersModel("X-Requested-With", "XMLHttpRequest")
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
_onLog?.Invoke($"UAKino playlist: {url}");
|
||||
string payload = await GetString(url, headers);
|
||||
if (string.IsNullOrEmpty(payload))
|
||||
return null;
|
||||
|
||||
using var document = JsonDocument.Parse(payload);
|
||||
if (!document.RootElement.TryGetProperty("success", out var successProp) || !successProp.GetBoolean())
|
||||
return null;
|
||||
|
||||
if (!document.RootElement.TryGetProperty("response", out var responseProp))
|
||||
return null;
|
||||
|
||||
string html = responseProp.GetString();
|
||||
if (string.IsNullOrEmpty(html))
|
||||
return null;
|
||||
|
||||
var items = ParsePlaylistHtml(html);
|
||||
if (items.Count > 0)
|
||||
_hybridCache.Set(memKey, items, cacheTime(10, init: _init));
|
||||
|
||||
return items;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_onLog?.Invoke($"UAKino playlist error: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<string> GetPlayerUrl(string href)
|
||||
{
|
||||
if (string.IsNullOrEmpty(href))
|
||||
return null;
|
||||
|
||||
var headers = new List<HeadersModel>()
|
||||
{
|
||||
new HeadersModel("User-Agent", "Mozilla/5.0"),
|
||||
new HeadersModel("Referer", _init.host)
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
_onLog?.Invoke($"UAKino movie page: {href}");
|
||||
string html = await GetString(href, headers);
|
||||
if (string.IsNullOrEmpty(html))
|
||||
return null;
|
||||
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(html);
|
||||
|
||||
var playlistNode = doc.DocumentNode.SelectSingleNode($"//div[contains(@class,'playlists-ajax') and @data-xfname='{PlaylistField}']");
|
||||
if (playlistNode != null)
|
||||
return null;
|
||||
|
||||
var iframe = doc.DocumentNode.SelectSingleNode("//iframe[@id='pre' and not(ancestor::*[@id='overroll'])]") ??
|
||||
doc.DocumentNode.SelectSingleNode("//iframe[@id='pre']");
|
||||
if (iframe == null)
|
||||
return null;
|
||||
|
||||
string src = iframe.GetAttributeValue("src", "");
|
||||
if (string.IsNullOrEmpty(src))
|
||||
src = iframe.GetAttributeValue("data-src", "");
|
||||
|
||||
if (src.Contains("youtube.com", StringComparison.OrdinalIgnoreCase) ||
|
||||
src.Contains("youtu.be", StringComparison.OrdinalIgnoreCase))
|
||||
return null;
|
||||
|
||||
return NormalizeUrl(src);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_onLog?.Invoke($"UAKino player url error: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<PlayerResult> ParsePlayer(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return null;
|
||||
|
||||
if (LooksLikeDirectStream(url))
|
||||
{
|
||||
return new PlayerResult { File = url };
|
||||
}
|
||||
|
||||
var headers = new List<HeadersModel>()
|
||||
{
|
||||
new HeadersModel("User-Agent", "Mozilla/5.0"),
|
||||
new HeadersModel("Referer", _init.host)
|
||||
};
|
||||
|
||||
try
|
||||
{
|
||||
_onLog?.Invoke($"UAKino parse player: {url}");
|
||||
string html = await GetString(url, headers);
|
||||
if (string.IsNullOrEmpty(html))
|
||||
return null;
|
||||
|
||||
string file = ExtractPlayerFile(html);
|
||||
if (string.IsNullOrEmpty(file))
|
||||
return null;
|
||||
|
||||
return new PlayerResult
|
||||
{
|
||||
File = NormalizeUrl(file),
|
||||
Subtitles = ExtractSubtitles(html)
|
||||
};
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_onLog?.Invoke($"UAKino parse player error: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private async Task<string> GetString(string url, List<HeadersModel> headers, int timeoutSeconds = 15)
|
||||
{
|
||||
string requestUrl = ApnHelper.IsAshdiUrl(url) && ApnHelper.IsEnabled(_init)
|
||||
? ApnHelper.WrapUrl(_init, url)
|
||||
: url;
|
||||
|
||||
var handler = new SocketsHttpHandler
|
||||
{
|
||||
AllowAutoRedirect = true,
|
||||
AutomaticDecompression = DecompressionMethods.Brotli | DecompressionMethods.GZip | DecompressionMethods.Deflate,
|
||||
SslOptions = new SslClientAuthenticationOptions
|
||||
{
|
||||
RemoteCertificateValidationCallback = (_, _, _, _) => true,
|
||||
EnabledSslProtocols = SslProtocols.Tls12 | SslProtocols.Tls13
|
||||
}
|
||||
};
|
||||
|
||||
var proxy = _proxyManager.Get();
|
||||
if (proxy != null)
|
||||
{
|
||||
handler.UseProxy = true;
|
||||
handler.Proxy = proxy;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler.UseProxy = false;
|
||||
}
|
||||
|
||||
using var client = new HttpClient(handler);
|
||||
using var req = new HttpRequestMessage(HttpMethod.Get, requestUrl);
|
||||
|
||||
if (headers != null)
|
||||
{
|
||||
foreach (var h in headers)
|
||||
req.Headers.TryAddWithoutValidation(h.name, h.val);
|
||||
}
|
||||
|
||||
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(Math.Max(5, timeoutSeconds)));
|
||||
using var response = await client.SendAsync(req, cts.Token).ConfigureAwait(false);
|
||||
if (!response.IsSuccessStatusCode)
|
||||
return null;
|
||||
|
||||
return await response.Content.ReadAsStringAsync(cts.Token).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
private List<PlaylistItem> ParsePlaylistHtml(string html)
|
||||
{
|
||||
var items = new List<PlaylistItem>();
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(html);
|
||||
|
||||
var nodes = doc.DocumentNode.SelectNodes("//li[@data-file]");
|
||||
if (nodes == null)
|
||||
return items;
|
||||
|
||||
foreach (var node in nodes)
|
||||
{
|
||||
string dataFile = node.GetAttributeValue("data-file", "");
|
||||
if (string.IsNullOrEmpty(dataFile))
|
||||
continue;
|
||||
|
||||
string title = CleanText(node.InnerText);
|
||||
string voice = node.GetAttributeValue("data-voice", "");
|
||||
|
||||
items.Add(new PlaylistItem
|
||||
{
|
||||
Title = string.IsNullOrEmpty(title) ? "Episode" : title,
|
||||
Url = NormalizeUrl(dataFile),
|
||||
Voice = voice
|
||||
});
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private string BuildPlaylistUrl(string newsId)
|
||||
{
|
||||
long ts = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
|
||||
return $"{_init.host}{PlaylistPath}?news_id={newsId}&xfield={PlaylistField}&time={ts}";
|
||||
}
|
||||
|
||||
private static string ExtractNewsId(string href)
|
||||
{
|
||||
if (string.IsNullOrEmpty(href))
|
||||
return null;
|
||||
|
||||
string tail = href.TrimEnd('/').Split('/').LastOrDefault();
|
||||
if (string.IsNullOrEmpty(tail))
|
||||
return null;
|
||||
|
||||
string newsId = tail.Split('-')[0];
|
||||
return string.IsNullOrEmpty(newsId) ? null : newsId;
|
||||
}
|
||||
|
||||
private static string ExtractPlayerFile(string html)
|
||||
{
|
||||
var match = Regex.Match(html, "file\\s*:\\s*['\"]([^'\"]+)['\"]", RegexOptions.IgnoreCase);
|
||||
if (match.Success)
|
||||
{
|
||||
string value = match.Groups[1].Value.Trim();
|
||||
if (!value.StartsWith("[", StringComparison.Ordinal))
|
||||
return value;
|
||||
}
|
||||
|
||||
var sourceMatch = Regex.Match(html, "<source[^>]+src=['\"]([^'\"]+)['\"]", RegexOptions.IgnoreCase);
|
||||
if (sourceMatch.Success)
|
||||
return sourceMatch.Groups[1].Value;
|
||||
|
||||
var m3u8Match = Regex.Match(html, "(https?://[^\"'\\s>]+\\.m3u8[^\"'\\s>]*)", RegexOptions.IgnoreCase);
|
||||
if (m3u8Match.Success)
|
||||
return m3u8Match.Groups[1].Value;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<SubtitleInfo> ExtractSubtitles(string html)
|
||||
{
|
||||
var subtitles = new List<SubtitleInfo>();
|
||||
var match = Regex.Match(html, "subtitle\\s*:\\s*['\"]([^'\"]+)['\"]", RegexOptions.IgnoreCase);
|
||||
if (!match.Success)
|
||||
return subtitles;
|
||||
|
||||
string value = match.Groups[1].Value.Trim();
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return subtitles;
|
||||
|
||||
if (value.StartsWith("[", StringComparison.Ordinal) && value.Contains(']'))
|
||||
{
|
||||
int endIdx = value.LastIndexOf(']');
|
||||
string label = value.Substring(1, endIdx - 1).Trim();
|
||||
string url = value[(endIdx + 1)..].Trim();
|
||||
url = NormalizeUrl(url);
|
||||
if (!string.IsNullOrEmpty(url))
|
||||
subtitles.Add(new SubtitleInfo { Lang = string.IsNullOrEmpty(label) ? "unknown" : label, Url = url });
|
||||
}
|
||||
else if (value.StartsWith("http", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
subtitles.Add(new SubtitleInfo { Lang = "unknown", Url = value });
|
||||
}
|
||||
|
||||
return subtitles;
|
||||
}
|
||||
|
||||
private string NormalizeUrl(string url)
|
||||
{
|
||||
if (string.IsNullOrEmpty(url))
|
||||
return string.Empty;
|
||||
|
||||
if (url.StartsWith("//"))
|
||||
return $"https:{url}";
|
||||
|
||||
if (url.StartsWith("/"))
|
||||
return $"{_init.host}{url}";
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
private static bool LooksLikeDirectStream(string url)
|
||||
{
|
||||
return url.Contains(".m3u8", StringComparison.OrdinalIgnoreCase) || url.EndsWith(".mp4", StringComparison.OrdinalIgnoreCase);
|
||||
}
|
||||
|
||||
private static bool IsBlacklisted(string url)
|
||||
{
|
||||
return Regex.IsMatch(url ?? string.Empty, BlacklistRegex, RegexOptions.IgnoreCase);
|
||||
}
|
||||
|
||||
private static bool IsSeriesUrl(string url)
|
||||
{
|
||||
return url.Contains("/seriesss/") || url.Contains("/anime-series/") || url.Contains("/cartoonseries/");
|
||||
}
|
||||
|
||||
private static bool IsMovieUrl(string url)
|
||||
{
|
||||
return url.Contains("/filmy/") || url.Contains("/anime-solo/") || url.Contains("/features/");
|
||||
}
|
||||
|
||||
private string ExtractPoster(HtmlNode node)
|
||||
{
|
||||
var img = node.SelectSingleNode(".//img");
|
||||
if (img == null)
|
||||
return string.Empty;
|
||||
|
||||
string src = img.GetAttributeValue("src", "");
|
||||
if (string.IsNullOrEmpty(src))
|
||||
src = img.GetAttributeValue("data-src", "");
|
||||
|
||||
return NormalizeUrl(src);
|
||||
}
|
||||
|
||||
private static string CleanText(string value)
|
||||
{
|
||||
if (string.IsNullOrEmpty(value))
|
||||
return string.Empty;
|
||||
|
||||
return HtmlEntity.DeEntitize(value).Trim();
|
||||
}
|
||||
|
||||
private static int? ExtractEpisodeNumber(string title)
|
||||
{
|
||||
if (string.IsNullOrEmpty(title))
|
||||
return null;
|
||||
|
||||
var match = Regex.Match(title, @"(\d+)");
|
||||
if (match.Success && int.TryParse(match.Groups[1].Value, out int number))
|
||||
return number;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static TimeSpan cacheTime(int multiaccess, int home = 5, int mikrotik = 2, OnlinesSettings init = null, int rhub = -1)
|
||||
{
|
||||
if (init != null && init.rhub && rhub != -1)
|
||||
return TimeSpan.FromMinutes(rhub);
|
||||
|
||||
int ctime = AppInit.conf.mikrotik ? mikrotik : AppInit.conf.multiaccess ? init != null && init.cache_time > 0 ? init.cache_time : multiaccess : home;
|
||||
if (ctime > multiaccess)
|
||||
ctime = multiaccess;
|
||||
|
||||
return TimeSpan.FromMinutes(ctime);
|
||||
}
|
||||
|
||||
public static int? TryParseEpisodeNumber(string title)
|
||||
{
|
||||
return ExtractEpisodeNumber(title);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
{
|
||||
"enable": true,
|
||||
"version": 3,
|
||||
"initspace": "UAKino.ModInit",
|
||||
"online": "UAKino.OnlineApi"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user