mirror of
https://github.com/lampame/lampac-ukraine.git
synced 2026-04-16 17:32:20 +00:00
Try add init4Uaflix
This commit is contained in:
parent
496a1f34b7
commit
66d712bb41
@ -11,26 +11,32 @@ using Shared;
|
||||
using Shared.Models.Templates;
|
||||
using Uaflix.Models;
|
||||
using System.Text.RegularExpressions;
|
||||
using Shared.Models.Online.Settings;
|
||||
using Shared.Engine;
|
||||
using Shared.Models;
|
||||
|
||||
namespace Uaflix.Controllers
|
||||
{
|
||||
public class Controller : BaseOnlineController
|
||||
{
|
||||
ProxyManager proxyManager = new ProxyManager(ModInit.UaFlix);
|
||||
static HttpClient httpClient = new HttpClient();
|
||||
ProxyManager proxyManager;
|
||||
|
||||
public Controller()
|
||||
{
|
||||
proxyManager = new ProxyManager(ModInit.UaFlix);
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
[Route("uaflix")]
|
||||
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, bool rjson = false)
|
||||
{
|
||||
var init = ModInit.UaFlix;
|
||||
var init = await loadKit(ModInit.UaFlix);
|
||||
if (!init.enable)
|
||||
return Forbid();
|
||||
|
||||
var proxy = proxyManager.Get();
|
||||
var result = await search(imdb_id, kinopoisk_id, title, original_title, year, serial);
|
||||
var result = await search(init, imdb_id, kinopoisk_id, title, original_title, year, serial, s);
|
||||
|
||||
if (result == null)
|
||||
if (result == null || result.movie == null)
|
||||
{
|
||||
proxyManager.Refresh();
|
||||
return Content("Uaflix", "text/html; charset=utf-8");
|
||||
@ -57,7 +63,7 @@ namespace Uaflix.Controllers
|
||||
return rjson ? Content(season_tpl.ToJson(), "application/json; charset=utf-8") : Content(season_tpl.ToHtml(), "text/html; charset=utf-8");
|
||||
}
|
||||
|
||||
var episodes = seasons.GetValueOrDefault(s, null);
|
||||
var episodes = seasons.GetValueOrDefault<int, List<Movie>>(s, null);
|
||||
OnLog($"Вибраний сезон: {s}, кількість епізодів: {episodes?.Count ?? 0}");
|
||||
if (episodes == null)
|
||||
return Content("Uaflix", "text/html; charset=utf-8");
|
||||
@ -118,21 +124,25 @@ namespace Uaflix.Controllers
|
||||
return Content("Uaflix", "text/html; charset=utf-8");
|
||||
}
|
||||
|
||||
async ValueTask<Result> search(string imdb_id, long kinopoisk_id, string title, string original_title, int year, int serial)
|
||||
async ValueTask<Result> search(OnlinesSettings init, string imdb_id, long kinopoisk_id, string title, string original_title, int year, int serial, int s = -1)
|
||||
{
|
||||
string memKey = $"UaFlix:view:{kinopoisk_id}:{imdb_id}";
|
||||
string memKey = $"UaFlix:view:{kinopoisk_id}:{imdb_id}:{s}";
|
||||
if (!hybridCache.TryGetValue(memKey, out Result res))
|
||||
{
|
||||
try
|
||||
{
|
||||
var proxy = proxyManager.Get();
|
||||
|
||||
string filmTitle = !string.IsNullOrEmpty(title) ? title : original_title;
|
||||
string searchUrl = $"https://uafix.net/index.php?do=search&subaction=search&story={HttpUtility.UrlEncode(filmTitle)}";
|
||||
string searchUrl = $"{init.host}/index.php?do=search&subaction=search&story={HttpUtility.UrlEncode(filmTitle)}";
|
||||
|
||||
httpClient.DefaultRequestHeaders.Clear();
|
||||
httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0");
|
||||
httpClient.DefaultRequestHeaders.Add("Referer", "https://uafix.net/");
|
||||
var headers = new List<HeadersModel>()
|
||||
{
|
||||
new HeadersModel("User-Agent", "Mozilla/5.0"),
|
||||
new HeadersModel("Referer", init.host)
|
||||
};
|
||||
|
||||
var searchHtml = await httpClient.GetStringAsync(searchUrl);
|
||||
var searchHtml = await Http.Get(searchUrl, proxy: proxy, headers: headers);
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(searchHtml);
|
||||
|
||||
@ -192,12 +202,12 @@ namespace Uaflix.Controllers
|
||||
|
||||
string href = filmNode.GetAttributeValue("href", "");
|
||||
if (!href.StartsWith("http"))
|
||||
href = "https://uafix.net" + href;
|
||||
href = init.host + href;
|
||||
|
||||
// Get film page and check year
|
||||
try
|
||||
{
|
||||
var filmPageHtml = await httpClient.GetStringAsync(href);
|
||||
var filmPageHtml = await Http.Get(href, proxy: proxy, headers: headers);
|
||||
var filmDoc = new HtmlDocument();
|
||||
filmDoc.LoadHtml(filmPageHtml);
|
||||
|
||||
@ -261,9 +271,9 @@ namespace Uaflix.Controllers
|
||||
}
|
||||
|
||||
if (!filmUrl.StartsWith("http"))
|
||||
filmUrl = "https://uafix.net" + filmUrl;
|
||||
filmUrl = init.host + filmUrl;
|
||||
|
||||
var filmHtml = await httpClient.GetStringAsync(filmUrl);
|
||||
var filmHtml = await Http.Get(filmUrl, proxy: proxy, headers: headers);
|
||||
doc.LoadHtml(filmHtml);
|
||||
|
||||
var movies = new List<Movie>();
|
||||
@ -279,7 +289,7 @@ namespace Uaflix.Controllers
|
||||
{
|
||||
string episodeUrl = episodeNode.GetAttributeValue("href", "");
|
||||
if (!episodeUrl.StartsWith("http"))
|
||||
episodeUrl = "https://uafix.net" + episodeUrl;
|
||||
episodeUrl = init.host + episodeUrl;
|
||||
|
||||
if (uniqueEpisodes.Add(episodeUrl))
|
||||
{
|
||||
@ -290,7 +300,7 @@ namespace Uaflix.Controllers
|
||||
{
|
||||
if (int.TryParse(match.Groups[1].Value, out int seasonNumber) && int.TryParse(match.Groups[2].Value, out int episodeNumber))
|
||||
{
|
||||
var episodeMovies = await ParseEpisode(episodeUrl, filmTitle, episodeTitle, seasonNumber, episodeNumber);
|
||||
var episodeMovies = await ParseEpisode(init, episodeUrl, filmTitle, episodeTitle, seasonNumber, episodeNumber);
|
||||
if (episodeMovies != null)
|
||||
{
|
||||
movies.AddRange(episodeMovies);
|
||||
@ -303,7 +313,7 @@ namespace Uaflix.Controllers
|
||||
}
|
||||
else
|
||||
{
|
||||
var episodeMovies = await ParseEpisode(filmUrl, filmTitle, null, 1, 1);
|
||||
var episodeMovies = await ParseEpisode(init, filmUrl, filmTitle, null, 1, 1);
|
||||
if (episodeMovies != null)
|
||||
movies.AddRange(episodeMovies);
|
||||
}
|
||||
@ -326,12 +336,19 @@ namespace Uaflix.Controllers
|
||||
return res;
|
||||
}
|
||||
|
||||
async Task<List<Movie>> ParseEpisode(string url, string filmTitle, string episodeTitle = null, int seasonNumber = 0, int episodeNumber = 0)
|
||||
async Task<List<Movie>> ParseEpisode(OnlinesSettings init, string url, string filmTitle, string episodeTitle = null, int seasonNumber = 0, int episodeNumber = 0)
|
||||
{
|
||||
var movies = new List<Movie>();
|
||||
try
|
||||
{
|
||||
string html = await httpClient.GetStringAsync(url);
|
||||
var proxy = proxyManager.Get();
|
||||
var headers = new List<HeadersModel>()
|
||||
{
|
||||
new HeadersModel("User-Agent", "Mozilla/5.0"),
|
||||
new HeadersModel("Referer", init.host)
|
||||
};
|
||||
|
||||
string html = await Http.Get(url, proxy: proxy, headers: headers);
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(html);
|
||||
|
||||
@ -403,10 +420,13 @@ namespace Uaflix.Controllers
|
||||
var result = new List<(string link, string quality)>();
|
||||
try
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, iframeUrl);
|
||||
request.Headers.Add("User-Agent", "Mozilla/5.0");
|
||||
var response = await httpClient.SendAsync(request);
|
||||
var html = await response.Content.ReadAsStringAsync();
|
||||
var proxy = proxyManager.Get();
|
||||
var headers = new List<HeadersModel>()
|
||||
{
|
||||
new HeadersModel("User-Agent", "Mozilla/5.0"),
|
||||
new HeadersModel("Referer", "https://zetvideo.net/")
|
||||
};
|
||||
var html = await Http.Get(iframeUrl, proxy: proxy, headers: headers);
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(html);
|
||||
|
||||
@ -452,11 +472,14 @@ namespace Uaflix.Controllers
|
||||
var result = new List<(string link, string quality)>();
|
||||
try
|
||||
{
|
||||
var request = new HttpRequestMessage(HttpMethod.Get, iframeUrl);
|
||||
request.Headers.Add("User-Agent", "Mozilla/5.0");
|
||||
request.Headers.Add("Referer", "https://ashdi.vip/");
|
||||
var response = await httpClient.SendAsync(request);
|
||||
var html = await response.Content.ReadAsStringAsync();
|
||||
var proxy = proxyManager.Get();
|
||||
var headers = new List<HeadersModel>()
|
||||
{
|
||||
new HeadersModel("User-Agent", "Mozilla/5.0"),
|
||||
new HeadersModel("Referer", "https://ashdi.vip/")
|
||||
};
|
||||
|
||||
var html = await Http.Get(iframeUrl, proxy: proxy, headers: headers);
|
||||
var doc = new HtmlDocument();
|
||||
doc.LoadHtml(html);
|
||||
|
||||
@ -501,11 +524,16 @@ namespace Uaflix.Controllers
|
||||
{
|
||||
try
|
||||
{
|
||||
var proxy = proxyManager.Get();
|
||||
string url = $"https://ashdi.vip/vod/{id}";
|
||||
httpClient.DefaultRequestHeaders.Clear();
|
||||
httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0");
|
||||
httpClient.DefaultRequestHeaders.Add("Referer", "https://ashdi.vip/");
|
||||
var html = await httpClient.GetStringAsync(url);
|
||||
|
||||
var headers = new List<HeadersModel>()
|
||||
{
|
||||
new HeadersModel("User-Agent", "Mozilla/5.0"),
|
||||
new HeadersModel("Referer", "https://ashdi.vip/")
|
||||
};
|
||||
|
||||
var html = await Http.Get(url, proxy: proxy, headers: headers);
|
||||
|
||||
string subtitle = new Regex("subtitle(\")?:\"([^\"]+)\"").Match(html).Groups[2].Value;
|
||||
if (!string.IsNullOrEmpty(subtitle))
|
||||
|
||||
@ -12,12 +12,12 @@ namespace Uaflix
|
||||
/// </summary>
|
||||
public static void loaded()
|
||||
{
|
||||
UaFlix = new OnlinesSettings("UaFlix", "uafix.net", streamproxy: false)
|
||||
UaFlix = new OnlinesSettings("Uaflix", "https://uafix.net", streamproxy: false)
|
||||
{
|
||||
displayname = "🇺🇦 UaFlix"
|
||||
};
|
||||
|
||||
// Выводить "уточнить поиск"
|
||||
// Виводити "уточнити пошук"
|
||||
AppInit.conf.online.with_search.Add("uaflix");
|
||||
}
|
||||
}
|
||||
|
||||
@ -9,19 +9,15 @@ namespace Uaflix
|
||||
{
|
||||
var online = new List<(string name, string url, string plugin, int index)>();
|
||||
|
||||
void send(BaseSettings init, string plugin)
|
||||
{
|
||||
var init = ModInit.UaFlix;
|
||||
if (init.enable && !init.rip)
|
||||
{
|
||||
string url = init.overridehost;
|
||||
if (string.IsNullOrEmpty(url))
|
||||
url = $"{host}/{plugin}";
|
||||
url = $"{host}/uaflix";
|
||||
|
||||
online.Add((init.displayname, url, plugin, online.Count));
|
||||
online.Add((init.displayname, url, "uaflix", init.displayindex > 0 ? init.displayindex : online.Count));
|
||||
}
|
||||
}
|
||||
|
||||
send(ModInit.UaFlix, "uaflix");
|
||||
|
||||
return online;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user