using Shared.Engine.RxEnumerate; using Shared.Models.SISI.Base; using Shared.Models.SISI.OnResult; using System.Text; using System.Threading; using System.Web; namespace Shared.Engine.SISI { public static class XhamsterTo { static readonly ThreadLocal sbUri = new(() => new StringBuilder(PoolInvk.rentChunk)); #region Uri public static string Uri(string host, string plugin, string search, string c, string q, string sort, int pg) { var url = sbUri.Value; url.Clear(); if (!string.IsNullOrWhiteSpace(search)) { url.Append($"{host}/search/{HttpUtility.UrlEncode(search)}?page={pg}"); } else { switch (plugin ?? "") { case "xmrsml": url.Append($"{host}/shemale"); break; case "xmrgay": url.Append($"{host}/gay"); break; default: url.Append(host); break; } if (!string.IsNullOrEmpty(c)) url.Append($"/categories/{c}"); if (!string.IsNullOrEmpty(q)) url.Append($"/{q}"); switch (sort ?? "") { case "newest": url.Append("/newest"); break; case "best": url.Append("/best"); break; default: break; } if (pg > 0) url.Append($"/{pg}"); } return url.ToString(); } #endregion #region Playlist public static List Playlist(string route, ReadOnlySpan html, Func onplaylist = null) { if (html.IsEmpty) return null; ReadOnlySpan section = html.Contains("mixed-section", StringComparison.Ordinal) ? HtmlSpan.Node(html, "div", "class", "mixed-section", HtmlSpanTargetType.Contains) : html; if (section.IsEmpty) return null; var rx = Rx.Split("(
(rx.Count); foreach (var row in rx.Rows()) { if (row.Contains("badge_premium")) continue; var g = row.Groups("__nam[^\"]+\" href=\"https?://[^/]+/([^\"]+)\"([^>]+)?>()?([^<]+)"); string title = g[4].Value; string href = g[1].Value; if (!string.IsNullOrEmpty(href) && !string.IsNullOrWhiteSpace(title)) { string duration = row.Match("data-role=\"video-duration\"><[^>]+>([^<]+)"); if (string.IsNullOrEmpty(duration)) duration = row.Match("datetime=\"([^\"]+)\""); string img = row.Match(" srcset=\"([^\"]+)\"") ?? string.Empty; if (!img.StartsWith("http") || img.Contains("(w:16,h:9)")) { img = row.Match("thumb-image-container__image\" src=\"([^\"]+)\"") ?? string.Empty; if (!img.StartsWith("http")) img = row.Match("