From ca864d14b97e1554b4ef7af8b380deabc08d1101 Mon Sep 17 00:00:00 2001 From: immisterio <96652250+immisterio@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:44:11 +0200 Subject: [PATCH] Zetflix --- AppInit.cs | 2 + Controllers/ApiController.cs | 3 + Controllers/LITE/Kinobase.cs | 4 +- Controllers/LITE/Zetflix.cs | 181 +++++++++++++++++++++++++++++++++++ README.md | 2 +- 5 files changed, 189 insertions(+), 3 deletions(-) create mode 100644 Controllers/LITE/Zetflix.cs diff --git a/AppInit.cs b/AppInit.cs index 1e20e8f4..9a1cc86b 100644 --- a/AppInit.cs +++ b/AppInit.cs @@ -119,6 +119,8 @@ public class AppInit public FilmixSettings Filmix = new FilmixSettings("http://filmixapp.cyou"); + public OnlinesSettings Zetflix = new OnlinesSettings("https://8nov.zetfix.online"); + public VCDNSettings VCDN = new VCDNSettings("https://videocdn.tv", "3i40G5TSECmLF77oAqnEgbx61ZWaOYaE", "http://58.svetacdn.in", false); diff --git a/Controllers/ApiController.cs b/Controllers/ApiController.cs index 54bd72bc..fdeec045 100644 --- a/Controllers/ApiController.cs +++ b/Controllers/ApiController.cs @@ -58,6 +58,9 @@ public ActionResult Lite() if (AppInit.conf.Kinobase.enable) online += "{name:'Kinobase',url:'{localhost}/kinobase'},"; + if (AppInit.conf.Zetflix.enable) + online += "{name:'Zetflix',url:'{localhost}/zetflix'},"; + if (AppInit.conf.Filmix.enable) online += "{name:'Filmix',url:'{localhost}/filmix'},"; diff --git a/Controllers/LITE/Kinobase.cs b/Controllers/LITE/Kinobase.cs index a961bfc3..c36bd27e 100644 --- a/Controllers/LITE/Kinobase.cs +++ b/Controllers/LITE/Kinobase.cs @@ -22,7 +22,7 @@ async public Task Index(string title, string original_title, int y if (year == 0 || !AppInit.conf.Kinobase.enable) return Content(string.Empty); - string content = await embed(memoryCache, title, original_title, year); + string content = await embed(title, original_title, year); if (content == null) return Content(string.Empty); @@ -168,7 +168,7 @@ string getStreamLink(string _data) #region embed - async static ValueTask embed(IMemoryCache memoryCache, string title, string original_title, int year) + async ValueTask embed(string title, string original_title, int year) { string memKey = $"kinobase:view:{title}:{original_title}:{year}"; diff --git a/Controllers/LITE/Zetflix.cs b/Controllers/LITE/Zetflix.cs new file mode 100644 index 00000000..2256ef8d --- /dev/null +++ b/Controllers/LITE/Zetflix.cs @@ -0,0 +1,181 @@ +using System; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Caching.Memory; +using Newtonsoft.Json; +using System.Collections.Generic; +using Lampac.Engine; +using Lampac.Engine.CORE; +using Newtonsoft.Json.Linq; +using System.Web; +using System.Linq; + +namespace Lampac.Controllers.LITE +{ + public class Zetflix : BaseController + { + [HttpGet] + [Route("lite/zetflix")] + async public Task Index(int id, long kinopoisk_id, string title, string original_title, string t, int s = -1) + { + if (kinopoisk_id == 0 || id == 0 || !AppInit.conf.Zetflix.enable) + return Content(string.Empty); + + var root = await embed(kinopoisk_id, s); + if (root.pl == null) + return Content(string.Empty); + + bool firstjson = true; + string html = "
"; + + if (root.movie) + { + #region Фильм + foreach (var pl in root.pl) + { + string name = pl.Value("title"); + string file = pl.Value("file"); + + if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(file)) + continue; + + string streansquality = string.Empty; + List<(string link, string quality)> streams = new List<(string, string)>(); + + foreach (var quality in new List { "2160", "2060", "1440", "1080", "720", "480", "360", "240" }) + { + string link = new Regex($"\\[{quality}p?\\]" + "([^\\[\\|,\n\r\t ]+\\.(mp4|m3u8))").Match(file).Groups[1].Value; + if (string.IsNullOrEmpty(link)) + continue; + + link = AppInit.conf.Zetflix.streamproxy ? $"{AppInit.Host(HttpContext)}/proxy/{link}" : link; + + streams.Add((link, $"{quality}p")); + streansquality += $"\"{quality}p\":\"" + link + "\","; + } + + streansquality = "\"quality\": {" + Regex.Replace(streansquality, ",$", "") + "}"; + + html += "
" + name + "
"; + firstjson = false; + } + #endregion + } + else + { + #region Сериал + if (s == -1) + { + int number_of_seasons = 1; + + var themoviedb = await HttpClient.Get($"https://api.themoviedb.org/3/tv/{id}?api_key=4ef0d7355d9ffb5151e987764708ce96"); + if (themoviedb != null) + { + number_of_seasons = themoviedb.Value("number_of_seasons"); + if (1 > number_of_seasons) + number_of_seasons = 1; + } + + for (int i = 1; i <= number_of_seasons; i++) + { + string link = $"{AppInit.Host(HttpContext)}/lite/zetfix?id={id}&kinopoisk_id={kinopoisk_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&s={i}"; + + html += "
" + $"{i} сезон" + "
"; + firstjson = false; + } + } + else + { + #region Перевод + foreach (var pl in root.pl) + { + string perevod = pl.Value("title"); + + if (html.Contains(perevod)) + continue; + + if (string.IsNullOrWhiteSpace(t)) + t = perevod; + + string link = $"{AppInit.Host(HttpContext)}/lite/zetfix?id={id}&kinopoisk_id={kinopoisk_id}&title={HttpUtility.UrlEncode(title)}&original_title={HttpUtility.UrlEncode(original_title)}&s={s}&t={HttpUtility.UrlEncode(perevod)}"; + string active = t == perevod ? "active" : ""; + + html += "
" + perevod + "
"; + } + + html += "
"; + #endregion + + #region Серии + foreach (var pl in root.pl.Reverse()) + { + string perevod = pl.Value("title"); + if (perevod != t) + continue; + + var item = pl.Value("folder").First; + string name = item.Value("comment"); + string file = item.Value("file"); + + if (string.IsNullOrWhiteSpace(name) || string.IsNullOrWhiteSpace(file)) + continue; + + string streansquality = string.Empty; + List<(string link, string quality)> streams = new List<(string, string)>(); + + foreach (var quality in new List { "2160", "2060", "1440", "1080", "720", "480", "360", "240" }) + { + string link = new Regex($"\\[{quality}p?\\]" + "([^\\[\\|,\n\r\t ]+\\.(mp4|m3u8))").Match(file).Groups[1].Value; + if (string.IsNullOrEmpty(link)) + continue; + + link = AppInit.conf.Zetflix.streamproxy ? $"{AppInit.Host(HttpContext)}/proxy/{link}" : link; + + streams.Add((link, $"{quality}p")); + streansquality += $"\"{quality}p\":\"" + link + "\","; + } + + streansquality = "\"quality\": {" + Regex.Replace(streansquality, ",$", "") + "}"; + + html += "
" + name + "
"; + firstjson = false; + } + #endregion + } + #endregion + } + + return Content(html + "
", "text/html; charset=utf-8"); + } + + + #region embed + async ValueTask<(JArray pl, bool movie)> embed(long kinopoisk_id, int s) + { + string memKey = $"zetfix:view:{kinopoisk_id}:{s}"; + + if (!memoryCache.TryGetValue(memKey, out (JArray pl, bool movie) cache)) + { + string html = await HttpClient.Get($"{AppInit.conf.Zetflix.host}/iplayer/videodb.php?kp={kinopoisk_id}" + (s > 0 ? $"&season={s}" : ""), timeoutSeconds: 8, useproxy: AppInit.conf.Zetflix.useproxy, addHeaders: new List<(string name, string val)>() + { + ("dnt", "1"), + ("pragma", "no-cache"), + ("referer", $"{AppInit.conf.Zetflix.host}/iplayer/player.php?id=JTJGaXBsYXllciUyRnZpZGVvZGIucGhwJTNGa3AlM0Q0NDcxMDU0JTI2c2Vhc29uJTNEMSUyNmVwaXNvZGUlM0Q2JTI2cG9zdGVyJTNEaHR0cHMlM0ElMkYlMkZ6ZXRmaXgub25saW5lJTJGdXBsb2FkcyUyRnBvc3RzJTJGMjAyMS0wNyUyRjE2MjUxMjY0NTVfbW9uYXJoaTYuanBnJTI2enZ1ayUzRFNESStNZWRpYSUyQ1ZTSStNb3Njb3clMkMlRDAlOUYlRDAlQjglRDElODQlRDAlQjAlRDAlQjMlRDAlQkUlRDElODAlMkNOZXRmbGl4JTJDTG9zdEZpbG0=&poster=aHR0cHM6Ly96ZXRmaXgub25saW5lL3VwbG9hZHMvcG9zdHMvMjAyMS0wNy8xNjI1MTI2NDU1X21vbmFyaGk2LmpwZw=="), + ("upgrade-insecure-requests", "1") + }); + + string file = new Regex("file:([^\n\r]+,\\])").Match(html).Groups[1].Value; + if (string.IsNullOrWhiteSpace(file)) + return (null, false); + + cache.movie = !file.Contains("\"comment\":"); + cache.pl = JsonConvert.DeserializeObject(file); + memoryCache.Set(memKey, cache, DateTime.Now.AddMinutes(AppInit.conf.multiaccess ? 20 : 5)); + } + + return cache; + } + #endregion + } +} diff --git a/README.md b/README.md index 5be1b83a..bd332f93 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ curl -s https://raw.githubusercontent.com/immisterio/lampac/main/install.sh | ba 2. В "Основной источник" выбрать "CUB" # Источники -* Public online - Videocdn, Rezka, Kinobase, Collaps, Filmix, Kinokrad, Kinotochka, Kinoprofi, LostfilmHD, VideoAPI (ENG), Ashdi (UKR), Eneyida (UKR) +* Public online - Videocdn, Rezka, Kinobase, Collaps, Filmix, Zetflix, Kinokrad, Kinotochka, Kinoprofi, LostfilmHD, VideoAPI (ENG), Ashdi (UKR), Eneyida (UKR) * Private online - HDVB (FREE), IframeVideo (FREE), Bazon (PAY), Alloha (PAY), Kodik (PAY), Seasonvar (PAY), KinoPub (PAY) * Public Trackers - kinozal.tv, nnmclub.to, rutor.info, megapeer.vip, torrent.by, bitru.org, anilibria.tv * Private Trackers - toloka.to, rutracker.net, underver.se, selezen.net, animelayer.ru