Compare commits

..

No commits in common. "0f6b0485450ac278bf314a7c3b7111fa4c5483de" and "ce58434c317237daab2de31591d831f8ee2a7600" have entirely different histories.

15 changed files with 62 additions and 186 deletions

3
.gitignore vendored
View File

@ -16,5 +16,4 @@ bin
obj obj
.vscode/settings.json .vscode/settings.json
.qwen .qwen
log log
.kilo

View File

@ -4,7 +4,6 @@ using System.Threading.Tasks;
using Shared; using Shared;
using Shared.Models.Online.Settings; using Shared.Models.Online.Settings;
using Shared.Models; using Shared.Models;
using Shared.Models.Templates;
using System.Text.Json; using System.Text.Json;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
@ -15,13 +14,6 @@ using Shared.Engine;
namespace LME.AnimeON namespace LME.AnimeON
{ {
public class AshdiStream
{
public string Title { get; set; }
public string Link { get; set; }
public SubtitleTpl Subtitles { get; set; }
}
public class AnimeONInvoke public class AnimeONInvoke
{ {
private static readonly Regex Quality4kRegex = new Regex(@"(^|[^0-9])(2160p?)([^0-9]|$)|\b4k\b|\buhd\b", RegexOptions.IgnoreCase); private static readonly Regex Quality4kRegex = new Regex(@"(^|[^0-9])(2160p?)([^0-9]|$)|\b4k\b|\buhd\b", RegexOptions.IgnoreCase);
@ -200,12 +192,12 @@ namespace LME.AnimeON
public async Task<string> ParseAshdiPage(string url, bool disableAshdiMultivoiceForVod = false) public async Task<string> ParseAshdiPage(string url, bool disableAshdiMultivoiceForVod = false)
{ {
var streams = await ParseAshdiPageStreams(url, disableAshdiMultivoiceForVod); var streams = await ParseAshdiPageStreams(url, disableAshdiMultivoiceForVod);
return streams?.FirstOrDefault()?.Link; return streams?.FirstOrDefault().link;
} }
public async Task<List<AshdiStream>> ParseAshdiPageStreams(string url, bool disableAshdiMultivoiceForVod = false) public async Task<List<(string title, string link)>> ParseAshdiPageStreams(string url, bool disableAshdiMultivoiceForVod = false)
{ {
var streams = new List<AshdiStream>(); var streams = new List<(string title, string link)>();
try try
{ {
var headers = new List<HeadersModel>() var headers = new List<HeadersModel>()
@ -242,12 +234,7 @@ namespace LME.AnimeON
continue; continue;
string rawTitle = item.TryGetProperty("title", out var titleProp) ? titleProp.GetString() : null; string rawTitle = item.TryGetProperty("title", out var titleProp) ? titleProp.GetString() : null;
streams.Add(new AshdiStream streams.Add((BuildDisplayTitle(rawTitle, file, index), file));
{
Title = BuildDisplayTitle(rawTitle, file, index),
Link = file,
Subtitles = ApnHelper.ParseSubtitles(item.TryGetProperty("subtitle", out var subtitleProp) ? subtitleProp.GetString() : null)
});
index++; index++;
} }
@ -260,12 +247,7 @@ namespace LME.AnimeON
if (match.Success) if (match.Success)
{ {
string file = match.Groups[1].Value; string file = match.Groups[1].Value;
streams.Add(new AshdiStream streams.Add((BuildDisplayTitle("Основне джерело", file, 1), file));
{
Title = BuildDisplayTitle("Основне джерело", file, 1),
Link = file,
Subtitles = ApnHelper.ParseSubtitles(ApnHelper.ExtractPlayerSubtitle(html))
});
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -251,14 +251,12 @@ namespace LME.AnimeON.Controllers
{ {
foreach (var ashdiStream in ashdiStreams) foreach (var ashdiStream in ashdiStreams)
{ {
string optionName = $"{translationName} {ashdiStream.Title}"; string optionName = $"{translationName} {ashdiStream.title}";
string subtitlesParam = ashdiStream.Subtitles != null ? $"&subtitles={HttpUtility.UrlEncode(JsonSerializer.Serialize(ashdiStream.Subtitles.ToObject()))}" : string.Empty; string callUrl = $"{host}/lite/lme_animeon/play?url={HttpUtility.UrlEncode(ashdiStream.link)}";
string callUrl = $"{host}/lite/lme_animeon/play?url={HttpUtility.UrlEncode(ashdiStream.Link)}{subtitlesParam}";
tpl.Append(optionName, accsArgs(callUrl), "call"); tpl.Append(optionName, accsArgs(callUrl), "call");
} }
continue;
} }
continue;
} }
if (needsResolve || streamLink.Contains("moonanime.art/iframe/") || streamLink.Contains("ashdi.vip/vod")) if (needsResolve || streamLink.Contains("moonanime.art/iframe/") || streamLink.Contains("ashdi.vip/vod"))
@ -377,7 +375,7 @@ namespace LME.AnimeON.Controllers
} }
[HttpGet("lite/lme_animeon/play")] [HttpGet("lite/lme_animeon/play")]
public async Task<ActionResult> Play(string url, int episode_id = 0, string title = null, int serial = 0, string subtitles = null) public async Task<ActionResult> Play(string url, int episode_id = 0, string title = null, int serial = 0)
{ {
await UpdateService.ConnectAsync(host); await UpdateService.ConnectAsync(host);
@ -423,25 +421,10 @@ namespace LME.AnimeON.Controllers
forceProxy = true; forceProxy = true;
} }
SubtitleTpl subtitleTpl = null;
if (!string.IsNullOrEmpty(subtitles))
{
try
{
var subtitleDtos = JsonSerializer.Deserialize<List<SubtitleDto>>(subtitles);
if (subtitleDtos != null && subtitleDtos.Count > 0)
{
subtitleTpl = new SubtitleTpl(subtitleDtos.Count);
foreach (var sub in subtitleDtos)
subtitleTpl.Append(sub.label, sub.url);
}
}
catch { }
}
string streamUrl = BuildStreamUrl(init, streamLink, streamHeaders, forceProxy); string streamUrl = BuildStreamUrl(init, streamLink, streamHeaders, forceProxy);
string jsonResult = $"{{\"method\":\"play\",\"url\":\"{streamUrl}\",\"title\":\"{title ?? string.Empty}\"}}";
OnLog("AnimeON Play: return call JSON"); OnLog("AnimeON Play: return call JSON");
return UpdateService.Validate(Content(VideoTpl.ToJson("play", streamUrl, title ?? string.Empty, subtitles: subtitleTpl), "application/json; charset=utf-8")); return UpdateService.Validate(Content(jsonResult, "application/json; charset=utf-8"));
} }
private static string StripLampacArgs(string url) private static string StripLampacArgs(string url)

View File

@ -166,7 +166,7 @@ namespace LME.KlonFUN.Controllers
: $"Серія {episode.Number}"; : $"Серія {episode.Number}";
string streamUrl = BuildStreamUrl(init, episode.Link); string streamUrl = BuildStreamUrl(init, episode.Link);
episodeTpl.Append(episodeTitle, contentTitle, s.ToString(), episode.Number.ToString("D2"), streamUrl, subtitles: episode.Subtitles); episodeTpl.Append(episodeTitle, contentTitle, s.ToString(), episode.Number.ToString("D2"), streamUrl);
} }
episodeTpl.Append(voiceTpl); episodeTpl.Append(voiceTpl);
@ -190,7 +190,7 @@ namespace LME.KlonFUN.Controllers
: $"Варіант {i + 1}"; : $"Варіант {i + 1}";
string streamUrl = BuildStreamUrl(init, stream.Link); string streamUrl = BuildStreamUrl(init, stream.Link);
movieTpl.Append(label, streamUrl, subtitles: stream.Subtitles); movieTpl.Append(label, streamUrl);
} }
return rjson return rjson

View File

@ -206,8 +206,7 @@ namespace LME.KlonFUN
streams.Add(new MovieStream streams.Add(new MovieStream
{ {
Title = voiceTitle, Title = voiceTitle,
Link = link, Link = link
Subtitles = ApnHelper.ParseSubtitles(item.Value<string>("subtitle"))
}); });
index++; index++;
@ -222,8 +221,7 @@ namespace LME.KlonFUN
streams.Add(new MovieStream streams.Add(new MovieStream
{ {
Title = FormatMovieTitle("Основне джерело", directMatch.Groups["url"].Value, 1), Title = FormatMovieTitle("Основне джерело", directMatch.Groups["url"].Value, 1),
Link = directMatch.Groups["url"].Value, Link = directMatch.Groups["url"].Value
Subtitles = ApnHelper.ParseSubtitles(ApnHelper.ExtractPlayerSubtitle(playerHtml))
}); });
} }
} }
@ -312,8 +310,7 @@ namespace LME.KlonFUN
{ {
Number = episodeNumber, Number = episodeNumber,
Title = string.IsNullOrWhiteSpace(episodeTitle) ? $"Серія {episodeNumber}" : episodeTitle, Title = string.IsNullOrWhiteSpace(episodeTitle) ? $"Серія {episodeNumber}" : episodeTitle,
Link = link, Link = link
Subtitles = ApnHelper.ParseSubtitles(episodeObj.Value<string>("subtitle"))
}); });
episodeFallback++; episodeFallback++;

View File

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using Shared.Models.Templates;
namespace LME.KlonFUN.Models namespace LME.KlonFUN.Models
{ {
@ -48,7 +47,6 @@ namespace LME.KlonFUN.Models
{ {
public string Title { get; set; } public string Title { get; set; }
public string Link { get; set; } public string Link { get; set; }
public SubtitleTpl Subtitles { get; set; }
} }
public class SerialEpisode public class SerialEpisode
@ -56,7 +54,6 @@ namespace LME.KlonFUN.Models
public int Number { get; set; } public int Number { get; set; }
public string Title { get; set; } public string Title { get; set; }
public string Link { get; set; } public string Link { get; set; }
public SubtitleTpl Subtitles { get; set; }
} }
public class SerialVoice public class SerialVoice

View File

@ -107,7 +107,7 @@ namespace LME.Makhno
if (play) if (play)
return UpdateService.Validate(Redirect(streamUrl)); return UpdateService.Validate(Redirect(streamUrl));
return UpdateService.Validate(Content(VideoTpl.ToJson("play", streamUrl, episodeTitle, subtitles: episode.Subtitles), "application/json; charset=utf-8")); return UpdateService.Validate(Content(VideoTpl.ToJson("play", streamUrl, episodeTitle), "application/json; charset=utf-8"));
} }
} }
@ -150,7 +150,7 @@ namespace LME.Makhno
if (play) if (play)
return UpdateService.Validate(Redirect(streamUrl)); return UpdateService.Validate(Redirect(streamUrl));
return UpdateService.Validate(Content(VideoTpl.ToJson("play", streamUrl, title ?? original_title, subtitles: playerData.Subtitles ?? playerData.Movies?.FirstOrDefault(m => m.File == playerData.File)?.Subtitles), "application/json; charset=utf-8")); return UpdateService.Validate(Content(VideoTpl.ToJson("play", streamUrl, title ?? original_title), "application/json; charset=utf-8"));
} }
private async Task<ActionResult> HandleMovie(string playUrl, string imdb_id, string title, string original_title, int year, bool rjson, MakhnoInvoke invoke) private async Task<ActionResult> HandleMovie(string playUrl, string imdb_id, string title, string original_title, int year, bool rjson, MakhnoInvoke invoke)
@ -171,8 +171,7 @@ namespace LME.Makhno
{ {
File = playerData.File, File = playerData.File,
Title = "Основне джерело", Title = "Основне джерело",
Quality = "auto", Quality = "auto"
Subtitles = playerData.Subtitles
}); });
} }
@ -190,7 +189,7 @@ namespace LME.Makhno
? stream.Title ? stream.Title
: $"Варіант {index}"; : $"Варіант {index}";
tpl.Append(label, BuildStreamUrl(init, stream.File), subtitles: stream.Subtitles); tpl.Append(label, BuildStreamUrl(init, stream.File));
index++; index++;
} }
@ -391,15 +390,13 @@ namespace LME.Makhno
if (!string.IsNullOrEmpty(episode.File)) if (!string.IsNullOrEmpty(episode.File))
{ {
string streamUrl = BuildStreamUrl(init, episode.File); string streamUrl = BuildStreamUrl(init, episode.File);
episode_tpl.Append( episode_tpl.Append(
episode.Title, episode.Title,
title ?? original_title, title ?? original_title,
requestedSeason.ToString(), requestedSeason.ToString(),
(i + 1).ToString("D2"), (i + 1).ToString("D2"),
streamUrl, streamUrl
subtitles: episode.Subtitles );
);
} }
} }
} }

View File

@ -114,22 +114,18 @@ namespace LME.Makhno
{ {
string file = fileMatch.Groups[1].Value; string file = fileMatch.Groups[1].Value;
var posterMatch = Regex.Match(html, @"poster:[""']([^""']+)[""']", RegexOptions.IgnoreCase); var posterMatch = Regex.Match(html, @"poster:[""']([^""']+)[""']", RegexOptions.IgnoreCase);
var subtitles = ApnHelper.ParseSubtitles(ApnHelper.ExtractPlayerSubtitle(html));
return new PlayerData return new PlayerData
{ {
File = file, File = file,
Poster = posterMatch.Success ? posterMatch.Groups[1].Value : null, Poster = posterMatch.Success ? posterMatch.Groups[1].Value : null,
Voices = new List<Voice>(), Voices = new List<Voice>(),
Subtitles = subtitles,
Movies = new List<MovieVariant>() Movies = new List<MovieVariant>()
{ {
new MovieVariant new MovieVariant
{ {
File = file, File = file,
Quality = DetectQualityTag(file) ?? "auto", Quality = DetectQualityTag(file) ?? "auto",
Title = BuildMovieTitle("Основне джерело", file, 1), Title = BuildMovieTitle("Основне джерело", file, 1)
Subtitles = subtitles
} }
} }
}; };
@ -242,8 +238,7 @@ namespace LME.Makhno
Title = episode["title"]?.ToString(), Title = episode["title"]?.ToString(),
File = episode["file"]?.ToString(), File = episode["file"]?.ToString(),
Poster = episode["poster"]?.ToString(), Poster = episode["poster"]?.ToString(),
Subtitle = episode["subtitle"]?.ToString(), Subtitle = episode["subtitle"]?.ToString()
Subtitles = ApnHelper.ParseSubtitles(episode["subtitle"]?.ToString())
}); });
} }
} }
@ -294,8 +289,7 @@ namespace LME.Makhno
{ {
File = file, File = file,
Quality = DetectQualityTag($"{rawTitle} {file}") ?? "auto", Quality = DetectQualityTag($"{rawTitle} {file}") ?? "auto",
Title = BuildMovieTitle(rawTitle, file, index), Title = BuildMovieTitle(rawTitle, file, index)
Subtitles = ApnHelper.ParseSubtitles(item["subtitle"]?.ToString())
}); });
index++; index++;
} }

View File

@ -1,5 +1,4 @@
using System.Collections.Generic; using System.Collections.Generic;
using Shared.Models.Templates;
namespace LME.Makhno.Models namespace LME.Makhno.Models
{ {
@ -10,7 +9,6 @@ namespace LME.Makhno.Models
public List<Voice> Voices { get; set; } public List<Voice> Voices { get; set; }
public List<Season> Seasons { get; set; } public List<Season> Seasons { get; set; }
public List<MovieVariant> Movies { get; set; } public List<MovieVariant> Movies { get; set; }
public SubtitleTpl Subtitles { get; set; }
} }
public class Voice public class Voice
@ -32,7 +30,6 @@ namespace LME.Makhno.Models
public string Id { get; set; } public string Id { get; set; }
public string Poster { get; set; } public string Poster { get; set; }
public string Subtitle { get; set; } public string Subtitle { get; set; }
public SubtitleTpl Subtitles { get; set; }
} }
public class MovieVariant public class MovieVariant
@ -40,6 +37,5 @@ namespace LME.Makhno.Models
public string Title { get; set; } public string Title { get; set; }
public string File { get; set; } public string File { get; set; }
public string Quality { get; set; } public string Quality { get; set; }
public SubtitleTpl Subtitles { get; set; }
} }
} }

View File

@ -1,7 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using System.Web; using System.Web;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
@ -178,14 +177,12 @@ namespace LME.Mikai.Controllers
{ {
foreach (var ashdiStream in ashdiStreams) foreach (var ashdiStream in ashdiStreams)
{ {
string optionName = $"{voice.DisplayName} {ashdiStream.Title}"; string optionName = $"{voice.DisplayName} {ashdiStream.title}";
string subtitlesParam = ashdiStream.Subtitles != null ? $"&subtitles={HttpUtility.UrlEncode(JsonSerializer.Serialize(ashdiStream.Subtitles.ToObject()))}" : string.Empty; string ashdiCallUrl = $"{host}/lite/lme_mikai/play?url={HttpUtility.UrlEncode(ashdiStream.link)}&title={HttpUtility.UrlEncode(displayTitle)}";
string ashdiCallUrl = $"{host}/lite/lme_mikai/play?url={HttpUtility.UrlEncode(ashdiStream.Link)}&title={HttpUtility.UrlEncode(displayTitle)}{subtitlesParam}";
movieTpl.Append(optionName, accsArgs(ashdiCallUrl), "call"); movieTpl.Append(optionName, accsArgs(ashdiCallUrl), "call");
} }
continue;
} }
continue;
} }
string callUrl = $"{host}/lite/lme_mikai/play?url={HttpUtility.UrlEncode(episode.Url)}&title={HttpUtility.UrlEncode(displayTitle)}"; string callUrl = $"{host}/lite/lme_mikai/play?url={HttpUtility.UrlEncode(episode.Url)}&title={HttpUtility.UrlEncode(displayTitle)}";
@ -207,7 +204,7 @@ namespace LME.Mikai.Controllers
} }
[HttpGet("lite/lme_mikai/play")] [HttpGet("lite/lme_mikai/play")]
public async Task<ActionResult> Play(string url, string title = null, int serial = 0, string subtitles = null) public async Task<ActionResult> Play(string url, string title = null, int serial = 0)
{ {
await UpdateService.ConnectAsync(host); await UpdateService.ConnectAsync(host);
@ -238,24 +235,9 @@ namespace LME.Mikai.Controllers
forceProxy = true; forceProxy = true;
} }
SubtitleTpl subtitleTpl = null;
if (!string.IsNullOrEmpty(subtitles))
{
try
{
var subtitleDtos = JsonSerializer.Deserialize<List<SubtitleDto>>(subtitles);
if (subtitleDtos != null && subtitleDtos.Count > 0)
{
subtitleTpl = new SubtitleTpl(subtitleDtos.Count);
foreach (var sub in subtitleDtos)
subtitleTpl.Append(sub.label, sub.url);
}
}
catch { }
}
string streamUrl = BuildStreamUrl(init, streamLink, streamHeaders, forceProxy); string streamUrl = BuildStreamUrl(init, streamLink, streamHeaders, forceProxy);
return UpdateService.Validate(Content(VideoTpl.ToJson("play", streamUrl, title ?? string.Empty, subtitles: subtitleTpl), "application/json; charset=utf-8")); string jsonResult = $"{{\"method\":\"play\",\"url\":\"{streamUrl}\",\"title\":\"{title ?? string.Empty}\"}}";
return UpdateService.Validate(Content(jsonResult, "application/json; charset=utf-8"));
} }
private async Task<List<MikaiAnime>> CollectSeasonDetails(MikaiAnime details, MikaiInvoke invoke) private async Task<List<MikaiAnime>> CollectSeasonDetails(MikaiAnime details, MikaiInvoke invoke)

View File

@ -11,17 +11,9 @@ using Shared;
using Shared.Engine; using Shared.Engine;
using Shared.Models; using Shared.Models;
using Shared.Models.Online.Settings; using Shared.Models.Online.Settings;
using Shared.Models.Templates;
namespace LME.Mikai namespace LME.Mikai
{ {
public class AshdiStream
{
public string Title { get; set; }
public string Link { get; set; }
public SubtitleTpl Subtitles { get; set; }
}
public class MikaiInvoke public class MikaiInvoke
{ {
private static readonly Regex Quality4kRegex = new Regex(@"(^|[^0-9])(2160p?)([^0-9]|$)|\b4k\b|\buhd\b", RegexOptions.IgnoreCase); private static readonly Regex Quality4kRegex = new Regex(@"(^|[^0-9])(2160p?)([^0-9]|$)|\b4k\b|\buhd\b", RegexOptions.IgnoreCase);
@ -184,12 +176,12 @@ namespace LME.Mikai
public async Task<string> ParseAshdiPage(string url, bool disableAshdiMultivoiceForVod = false) public async Task<string> ParseAshdiPage(string url, bool disableAshdiMultivoiceForVod = false)
{ {
var streams = await ParseAshdiPageStreams(url, disableAshdiMultivoiceForVod); var streams = await ParseAshdiPageStreams(url, disableAshdiMultivoiceForVod);
return streams?.FirstOrDefault()?.Link; return streams?.FirstOrDefault().link;
} }
public async Task<List<AshdiStream>> ParseAshdiPageStreams(string url, bool disableAshdiMultivoiceForVod = false) public async Task<List<(string title, string link)>> ParseAshdiPageStreams(string url, bool disableAshdiMultivoiceForVod = false)
{ {
var streams = new List<AshdiStream>(); var streams = new List<(string title, string link)>();
try try
{ {
var headers = new List<HeadersModel>() var headers = new List<HeadersModel>()
@ -226,12 +218,7 @@ namespace LME.Mikai
continue; continue;
string rawTitle = item.TryGetProperty("title", out var titleProp) ? titleProp.GetString() : null; string rawTitle = item.TryGetProperty("title", out var titleProp) ? titleProp.GetString() : null;
streams.Add(new AshdiStream streams.Add((BuildDisplayTitle(rawTitle, file, index), file));
{
Title = BuildDisplayTitle(rawTitle, file, index),
Link = file,
Subtitles = ApnHelper.ParseSubtitles(item.TryGetProperty("subtitle", out var subtitleProp) ? subtitleProp.GetString() : null)
});
index++; index++;
} }
@ -244,12 +231,7 @@ namespace LME.Mikai
if (match.Success) if (match.Success)
{ {
string file = match.Groups[1].Value; string file = match.Groups[1].Value;
streams.Add(new AshdiStream streams.Add((BuildDisplayTitle("Основне джерело", file, 1), file));
{
Title = BuildDisplayTitle("Основне джерело", file, 1),
Link = file,
Subtitles = ApnHelper.ParseSubtitles(ApnHelper.ExtractPlayerSubtitle(html))
});
} }
} }
catch (Exception ex) catch (Exception ex)

View File

@ -1,9 +1,6 @@
using Newtonsoft.Json.Linq; using Newtonsoft.Json.Linq;
using Shared.Models.Base; using Shared.Models.Base;
using Shared.Models.Templates;
using System; using System;
using System.Net;
using System.Text.RegularExpressions;
using System.Web; using System.Web;
namespace Shared.Engine namespace Shared.Engine
@ -12,8 +9,6 @@ namespace Shared.Engine
{ {
public const string DefaultHost = "https://tut.im/proxy.php?url={encodeurl}"; public const string DefaultHost = "https://tut.im/proxy.php?url={encodeurl}";
private static readonly Regex SubtitleLineRegex = new Regex(@"\[([^\]]+)\]([^,]+)", RegexOptions.Compiled);
public static bool TryGetInitConf(JObject conf, out bool enabled, out string host) public static bool TryGetInitConf(JObject conf, out bool enabled, out string host)
{ {
enabled = false; enabled = false;
@ -125,40 +120,6 @@ namespace Shared.Engine
return $"{host.TrimEnd('/')}/{url}"; return $"{host.TrimEnd('/')}/{url}";
} }
public static SubtitleTpl ParseSubtitles(string subtitleValue)
{
if (string.IsNullOrWhiteSpace(subtitleValue))
return null;
var subtitles = new SubtitleTpl();
string normalized = WebUtility.HtmlDecode(subtitleValue)
.Replace("\\/", "/")
.Replace("\\'", "'")
.Replace("\\\"", "\"");
foreach (Match match in SubtitleLineRegex.Matches(normalized))
{
string label = WebUtility.HtmlDecode(match.Groups[1].Value).Trim();
string url = WebUtility.HtmlDecode(match.Groups[2].Value).Trim();
if (!string.IsNullOrWhiteSpace(label) && !string.IsNullOrWhiteSpace(url))
subtitles.Append(label, url);
}
return subtitles.IsEmpty ? null : subtitles;
}
public static string ExtractPlayerSubtitle(string html)
{
if (string.IsNullOrWhiteSpace(html))
return null;
var match = Regex.Match(html, @"subtitle\s*:\s*['""]([^'""']+)['""]", RegexOptions.IgnoreCase);
if (!match.Success)
match = Regex.Match(html, @"subtitle['""]?\s*:\s*['""]([^'""']+)['""]", RegexOptions.IgnoreCase);
return match.Success ? match.Groups[1].Value : null;
}
private static string NormalizeHost(string host) private static string NormalizeHost(string host)
{ {
if (string.IsNullOrWhiteSpace(host)) if (string.IsNullOrWhiteSpace(host))

View File

@ -104,10 +104,9 @@ namespace LME.Uaflix.Controllers
{ {
// Повертаємо JSON з інформацією про стрім для методу 'play' // Повертаємо JSON з інформацією про стрім для методу 'play'
string streamUrl = BuildStreamUrl(init, playResult.streams.First().link); string streamUrl = BuildStreamUrl(init, playResult.streams.First().link);
var subtitles = playResult.subtitles ?? playResult.streams.FirstOrDefault(s => s.subtitles != null)?.subtitles; string jsonResult = $"{{\"method\":\"play\",\"url\":\"{streamUrl}\",\"title\":\"{title ?? original_title}\"}}";
OnLog($"=== RETURN: call method JSON for episode_url ==="); OnLog($"=== RETURN: call method JSON for episode_url ===");
return UpdateService.Validate(Content(VideoTpl.ToJson("play", streamUrl, title ?? original_title, subtitles: subtitles), "application/json; charset=utf-8")); return UpdateService.Validate(Content(jsonResult, "application/json; charset=utf-8"));
} }
OnLog("=== RETURN: call method no streams ==="); OnLog("=== RETURN: call method no streams ===");
@ -285,8 +284,7 @@ namespace LME.Uaflix.Controllers
e: ep.Number.ToString(), e: ep.Number.ToString(),
link: accsArgs(callUrl), link: accsArgs(callUrl),
method: "call", method: "call",
streamlink: accsArgs($"{callUrl}&play=true"), streamlink: accsArgs($"{callUrl}&play=true")
subtitles: ApnHelper.ParseSubtitles(ep.Subtitle)
); );
} }
else else
@ -298,8 +296,7 @@ namespace LME.Uaflix.Controllers
title: title, title: title,
s: s.ToString(), s: s.ToString(),
e: ep.Number.ToString(), e: ep.Number.ToString(),
link: playUrl, link: playUrl
subtitles: ApnHelper.ParseSubtitles(ep.Subtitle)
); );
} }
@ -354,7 +351,7 @@ namespace LME.Uaflix.Controllers
? stream.title ? stream.title
: $"Варіант {index}"; : $"Варіант {index}";
tpl.Append(label, BuildStreamUrl(init, stream.link), subtitles: stream.subtitles ?? playResult.subtitles); tpl.Append(label, BuildStreamUrl(init, stream.link));
index++; index++;
} }

View File

@ -15,6 +15,5 @@ namespace LME.Uaflix.Models
public string link { get; set; } public string link { get; set; }
public string quality { get; set; } public string quality { get; set; }
public string title { get; set; } public string title { get; set; }
public SubtitleTpl? subtitles { get; set; }
} }
} }

View File

@ -582,8 +582,7 @@ namespace LME.Uaflix
{ {
link = fileUrl, link = fileUrl,
quality = DetectQualityTag($"{rawTitle} {fileUrl}") ?? "auto", quality = DetectQualityTag($"{rawTitle} {fileUrl}") ?? "auto",
title = BuildDisplayTitle(rawTitle, fileUrl, index), title = BuildDisplayTitle(rawTitle, fileUrl, index)
subtitles = ApnHelper.ParseSubtitles(item?["subtitle"]?.ToString())
}); });
index++; index++;
} }
@ -606,8 +605,7 @@ namespace LME.Uaflix
{ {
link = fallbackFile, link = fallbackFile,
quality = DetectQualityTag(fallbackFile) ?? "auto", quality = DetectQualityTag(fallbackFile) ?? "auto",
title = BuildDisplayTitle(ExtractVoiceFromUrl(fallbackFile), fallbackFile, 1), title = BuildDisplayTitle(ExtractVoiceFromUrl(fallbackFile), fallbackFile, 1)
subtitles = ApnHelper.ParseSubtitles(ApnHelper.ExtractPlayerSubtitle(html))
}); });
return result; return result;
@ -2052,7 +2050,19 @@ namespace LME.Uaflix
string url = $"https://ashdi.vip/vod/{id}"; string url = $"https://ashdi.vip/vod/{id}";
var html = await GetHtml(AshdiRequestUrl(url), new List<HeadersModel>() { new HeadersModel("User-Agent", "Mozilla/5.0"), new HeadersModel("Referer", "https://ashdi.vip/") }); var html = await GetHtml(AshdiRequestUrl(url), new List<HeadersModel>() { new HeadersModel("User-Agent", "Mozilla/5.0"), new HeadersModel("Referer", "https://ashdi.vip/") });
string subtitle = new Regex("subtitle(\")?:\"([^\"]+)\"").Match(html).Groups[2].Value; string subtitle = new Regex("subtitle(\")?:\"([^\"]+)\"").Match(html).Groups[2].Value;
return ApnHelper.ParseSubtitles(subtitle); if (!string.IsNullOrEmpty(subtitle))
{
var match = new Regex("\\[([^\\]]+)\\](https?://[^\\,]+)").Match(subtitle);
var st = new Shared.Models.Templates.SubtitleTpl();
while (match.Success)
{
st.Append(match.Groups[1].Value, match.Groups[2].Value);
match = match.NextMatch();
}
if (st.data != null && st.data.Count > 0)
return st;
}
return null;
} }
private static string WithAshdiMultivoice(string url) private static string WithAshdiMultivoice(string url)