Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* * 🎬 Movies Ultimate
- ------------------
- * Design & Dev: Khal * ------------------
- -id @ REMiX_KSA
- * -------------------------------------
- */
- // --- Configuration ---
- acheFileName: "fconst CONFIG = {
- baseURL: "https://www.faselhds.xyz",
- timeoutSeconds: 20,
- caselhd_remix_cache.json",
- accentColor: new Color("#2c3e50"), // Dark Blue
- highlightColor: new Color("#e74c3c"), // Red
- lback-url/play?url={url}",
- "Infu textColor: new Color("#ffffff"),
- bgColor: new Color("#1c1c1e")
- };
- const PLAYERS = {
- "SenPlayer": "senplayer://x-ca
- lse": "infuse://x-callback-url/play?url={url}",
- "VLC": "vlc-x-callback://x-callback-url/stream?url={url}",
- "Outplayer": "outplayer://{url}",
- "nPlayer": "nplayer-https://{encoded}",
- ctions (UITable) ---
- "Safari": "{url}",
- "نسخ الرابط": "copy"
- };
- // --- Main Execution ---
- await run();
- async function run() {
- const state = loadState();
- await showMainMenu(state);
- }
- // --- UI Fu
- nasync function showMainMenu(state) {
- let table = new UITable();
- table.showSeparators = true;
- // Header
- addHeader(table, "Movies Ultimate", "By: Jad7 & Edit: Khalid | x: REMiX_KSA");
- // Menu Items
- handleSearch(state);
- });
- addMenuItem(table, "❤️ المفضلة (Favorites)", " addMenuItem(table, "🔥 الأكثر مشاهدة (Trending)", "star.fill", async () => {
- await showTrending(state);
- });
- addMenuItem(table, "🔍 بحث جديد (Search)", "magnifyingglass", async () => {
- await
- heart.fill", async () => {
- await showFavorites(state);
- });
- addMenuItem(table, "🕒 سجل البحث (History)", "clock", async () => {
- await showHistory(state);
- });
- addMenuItem(table, "⚙️ الإعدادات (Settings)", "gear", async () => {
- await handleSettings(state);
- });
- await table.present();
- }
- async function showTrending(state) {
- await showNotification("جاري التحميل...", "يتم جلب القائمة...");
- // FaselHD doesn't have a simple JSON API, so we scrape the home page or a specific category
- // Let's scrape the "Movies" or "Series" page for now, or just the
- home page recent additions
- let results = await searchFasel("", true); // Empty query with isTrending flag
- if (results.length === 0) {
- await showAlert("تنبيه", "لم يتم العثور على محتوى.");
- return;
- }
- await showResultsTable(state, "🔥 الأكثر مشاهدة", results);
- }
- async function showFavorites(state) {
- showAlert("السجل", "سجل البحث فارغ.") let favs = state.favorites || [];
- if (favs.length === 0) {
- await showAlert("المفضلة", "قائمة المفضلة فارغة.");
- return;
- }
- await showResultsTable(state, "❤️ المفضلة", favs, true);
- }
- async function showHistory(state) {
- let history = state.history || [];
- if (history.length === 0) {
- await
- ;
- return;
- }
- let table = new UITable();
- addHeader(table, "سجل البحث");
- history.forEach(q => {
- let row = new UITableRow();
- row.dismissOnSelect = true;
- row.onSelect = async () => {
- await handleSearch(state, q);
- };
- let cell = row.addText(q);
- table.addRow(row);
- });
- // Clear History Option
- await table.present();
- }
- asyn let clearRow = new UITableRow();
- clearRow.dismissOnSelect = false; // Don't close, just refresh or alert
- let clearCell = clearRow.addText("🗑️ مسح السجل");
- clearCell.titleColor = Color.red();
- clearRow.onSelect = async () => {
- state.history = [];
- saveState(state);
- await showAlert("تم", "تم مسح السجل");
- };
- table.addRow(clearRow)
- ;c function handleSearch(state, initialQuery = null) {
- let query = initialQuery;
- if (!query) {
- query = await presentPrompt("بحث جديد", "اكتب اسم الفيلم أو المسلسل:");
- }
- if (!query) return;
- addToHistory(state, query);
- await showNotification("جاري البحث...", query);
- let results = await searchFasel(query);
- if (results.length === 0) {
- await showAlert("عذراً", "لم يتم العثور على نتائج.");
- aceholder.com/1 return;
- }
- await showResultsTable(state, `نتائج: ${query}`, results);
- }
- async function showResultsTable(state, title, items, isFavorites = false) {
- let table = new UITable();
- addHeader(table, title);
- for (let item of items) {
- let row = new UITableRow();
- row.height = 80;
- row.dismissOnSelect = true;
- // Image
- let imgCell = row.addImageAtURL(item.img || "https://via.p
- l00");
- imgCell.widthWeight = 20;
- // Title & Rating
- let textCell = row.addText(item.title, item.rating ? `⭐ ${item.rating}` : "");
- textCell.widthWeight = 70;
- textCell.subtitleColor = Color.gray();
- row.onSelect = async () => {
- await processItem(state, item);
- };
- table.addRow(row);
- }
- await table.present();
- }
- async function processItem(state, item, isSeason = false) {
- details.seasons.length > 0) {
- // Auto-detect season from title
- if (item.title.includes("الموسم") || item.title.includes("Season")) {
- isSeason = true;
- }
- await showNotification("جاري المعالجة...", item.title);
- let details = await getDetails(item.href);
- // Case 1: It has seasons AND we are not already in a season view
- // This must come BEFORE episodes check to avoid showing random episodes on a series page
- if (!isSeason && details.seasons &&
- let table = new UITable();
- addHeader(table, `مواسم: ${item.title}`);
- details.seasons.forEach(s => {
- let row = new UITableRow();
- row.addText(s.title);
- row.dismissOnSelect = true;
- row.onSelect = async () => {
- // Explicitly pass true for isSeason
- await processItem(state, s, true);
- };
- table.addRow(row);
- });
- await table.present();
- return;
- }
- // Case 2: It has episodes
- favRow.addText("❤️ إضافة للمفضلة");
- if (details.episodes && details.episodes.length > 0) {
- // If single episode/movie, play directly or show options
- if (details.episodes.length === 1) {
- await showEpisodeOptions(state, item, details.episodes[0].href);
- } else {
- // Show Episodes List
- let table = new UITable();
- addHeader(table, item.title);
- // Add "Add to Favorites" row
- if (!isFavorite(state, item)) {
- let favRow = new UITableRow();
- favRow.onSelect = () => {
- addToFavorites(state, item);
- showNotification("تم", "تمت الإضافة للمفضلة");
- };
- table.addRow(favRow);
- }
- details.episodes.forEach(ep => {
- let row = new UITableRow();
- row.addText(ep.title);
- row.dismissOnSelect = true;
- row.onSelect = async () => {
- await showEpisodeOptions(state, item, ep.href);
- };
- table.addRow(row);
- });
- await table.present();
- رابط", "ي }
- } else {
- await showAlert("خطأ", "لم يتم العثور على محتوى.");
- }
- }
- async function showEpisodeOptions(state, item, url) {
- // If default player is set, we might want to just play?
- // But user wants to Copy Link or Favorite too.
- // Let's keep the menu but make it smarter.
- let options = ["تشغيل", "نسخ الرابط", "إضافة للمفضلة"];
- if (isFavorite(state, item)) options = ["تشغيل", "نسخ الرابط", "إزالة من المفضلة"];
- let idx = await presentMenu(item.title, options);
- if (idx === -1) return;
- if (idx === 0) {
- await showNotification("🚀 استخراج ا
- لرجى الانتظار...");
- let streamUrl = await extractStreamWithWebView(url);
- if (streamUrl) {
- await playStream(state, streamUrl);
- } else {
- await showAlert("فشل", "لم يتم العثور على رابط.");
- }
- } else if (idx === 1) {
- await showNotification("🚀 استخراج الرابط", "يرجى الانتظار...");
- let streamUrl = await extractStreamWithWebView(url);
- if (streamUrl) {
- Pasteboard.copy(streamUrl);
- await showNotification("تم", "تم نسخ الرابط");
- }
- } else if (idx === 2) {
- if (isFavorite(state, item)) {
- removeFromFavorites(state, item);
- ;
- row.height = 60;
- row.dismissOnSelect = true;
- // Icon await showNotification("تم", "تمت الإزالة من المفضلة");
- } else {
- addToFavorites(state, item);
- await showNotification("تم", "تمت الإضافة للمفضلة");
- }
- }
- }
- // --- Helper UI Components ---
- function addHeader(table, title, subtitle = null) {
- let row = new UITableRow();
- row.isHeader = true;
- let cell = row.addText(title, subtitle || "");
- cell.titleFont = Font.boldSystemFont(24);
- cell.subtitleFont = Font.systemFont(12);
- cell.subtitleColor = CONFIG.highlightColor;
- table.addRow(row);
- }
- function addMenuItem(table, title, iconName, action) {
- let row = new UITableRow(
- )
- let icon = SFSymbol.named(iconName);
- let imgCell = row.addImage(icon.image);
- imgCell.widthWeight = 15;
- imgCell.tintColor = CONFIG.highlightColor;
- // Title
- let textCell = row.addText(title);
- textCell.widthWeight = 85;
- textCell.titleFont = Font.systemFont(18);
- row.onSelect = action;
- table.addRow(row);
- }
- // --- Logic & Scraper ---
- async function searchFasel(query, isTrending = false) {
- let url = isTrending ? CONFIG.baseURL : `${CONFIG.baseURL}/?s=${encodeURIComponent(query)}`;
- let req = new Request(url);
- let html = await req.loadString();
- // Regex to extract: Link, Title, Image, Rating (optional)
- // <div class="postDiv ..."> ... <a href="..."> ... <img ... data-src="..."> ... <div class="h1">...</div> ... </div>
- let res = [];
- // Adjusted Regex to capture Image
- let regex = /<div class="postDiv[^"]*">[\s\S]*?<a href="([^"]+)">[\s\S]*?<img[^>]+data-src="([^"]+)"[^>]*>[\s\S]*?<div class="h1">([\s\S]*?)<\/div>/g;
- if (isTrending) {
- // Trending might have different structure or just use the same postDivs on home page
- // Usually home page has "postDiv" for recent items.
- // Let's try the same regex first.
- }
- let m;
- while ((m = regex.exec(html)) !== null) {
- let link = m[1].trim();
- let img = m[2].trim();
- let title = m[3].trim().replace(/<[^>]*>/g, "");
- title = title.replace(/&#(\d+);/g, (match, dec) => String.fromCharCode(dec));
- res.push({ href: link, title: title, img: img });
- }
- return res;
- }
- async function getDetails(url) {
- let req = new Request(url);
- let html = await req.loadString();
- // Seasons
- let seasons = [];
- // Updated regex for onclick seasons
- let seasonRegex = /<div[^>]+class="seasonDiv[^"]*"[^>]*onclick="window\.location\.href\s*=\s*['"]([^'"]+)['"][^>]*>[\s\S]*?<div class="title">([\s\S]*?)<\/div>/g;
- // Also capture image for seasons if possible? The regex above doesn't capture img.
- // Let's try to capture img inside seasonDiv if we want to show it.
- // For now, title is enough for the table.
- let sm;
- while ((sm = seasonRegex.exec(html)) !== null) {
- let sUrl = sm[1];
- if (sUrl.startsWith("/")) sUrl = CONFIG.baseURL + sUrl;
- seasons.push({ href: sUrl, title: sm[2].trim(), img: null }); /
- / Placeholder img
- }
- // Episodes
- let eps = [];
- let regex = /<a href="([^"]+)"[^>]*>\s*(?:<[^>]+>)*\s*(?:الحلقة|Episode)\s*(\d+)/gi;
- let m;
- while ((m = regex.exec(html)) !== null) {
- eps.push({ href: m[1], title: `الحلقة ${m[2]}` });
- }
- if (eps.length === 0) {
- eps.push({ title: "فيلم كامل / الحلقة", href: url });
- }
- // Sort episodes
- if (eps.length > 1 && eps[0].title.includes("الحلقة")) {
- let firstNum = parseInt(eps[0].title.match(/\d+/)[0]);
- let lastNum = parseInt(eps[eps.length - 1].title.match(/\d+/)[0]);
- if (firstNum > lastNum) eps.reverse();
- }
- return { seasons: seasons, episodes: eps };
- }
- async function extractStreamWithWebView(pageUrl) {
- // Same extraction logic as before
- let html = await new Request(pageUrl).loadString();
- if (window.jwplayer){
- let playerUrl = null;
- let m = html.match(/<iframe[^>]+name="player_iframe"[^>]+src="([^"]+)"/i) ||
- html.match(/player_iframe\.location\.href\s*=\s*['"]([^'"]+)['"]/);
- if (m) playerUrl = m[1];
- if (!playerUrl) {
- let m2 = html.match(/<iframe[^>]+src="([^"]+master\.m3u8[^"]+)"/);
- if (m2) return m2[1];
- }
- if (!playerUrl) return null;
- if (playerUrl.startsWith("//")) playerUrl = "https:" + playerUrl;
- let wv = new WebView();
- await wv.loadURL(playerUrl);
- let maxRetries = CONFIG.timeoutSeconds;
- for (let i = 0; i < maxRetries; i++) {
- let jsResult = await wv.evaluateJavaScript(`
- (function(){
- try{
- let v = document.querySelector('video');
- if (v && v.src && (v.src.includes('.m3u8') || v.src.includes('.mp4'))) return v.src;
- try{
- let p = window.jwplayer();
- if (p && p.getPlaylist){
- let list = p.getPlaylist();
- if (list && list.length > 0 && list[0].file) return list[0].file;
- }
- }catch(e){}
- }
- let html = document.body.innerHTML;
- let match = html.match(/(https?:\\/\\/[^"']+\\.m3u8)/);
- if (match) return match[1];
- }catch(e){}
- return null;
- })()
- `);
- if (jsResult) return jsResult;
- await new Promise(r => Timer.schedule(1000, false, r));
- }
- return null;
- }
- async function playStream(state, streamUrl) {
- let player = state.defaultPlayer;
- if (!player) {
- let options = Object.keys(PLAYERS);
- let idx = await presentMenu("اختر المشغل", options);
- if (idx === -1) return;
- player = options[idx];
- rn;
- }
- let schemeTemplate = PLAYERS[player];
- if (schemeTemplate === "copy") {
- Pasteboard.copy(streamUrl);
- await showNotification("تم", "تم النسخ");
- return;
- }
- let finalUrl;
- if (schemeTemplate.includes("{url}")) {
- finalUrl = schemeTemplate.replace("{url}", streamUrl);
- } else if (schemeTemplate.includes("{encoded}")) {
- finalUrl = schemeTemplate.replace("{encoded}", encodeURIComponent(streamUrl));
- } else {
- finalUrl = schemeTemplate + encodeURIComponent(streamUrl);
- }
- Safari.open(finalUrl);
- }
- // --- State & Settings ---
- async function handleSettings(state) {
- let players = Object.keys(PLAYERS);
- let menu = [
- `المشغل الافتراضي: ${state.defaultPlayer || "غير محدد"}`,
- "مسح البيانات المؤقتة"
- ];
- let idx = await presentMenu("الإعدادات", menu);
- if (idx === -1) ret
- u if (idx === 0) {
- let pIdx = await presentMenu("اختر المشغل الافتراضي", ["سؤالي كل مرة", ...players]);
- if (pIdx === -1) return;
- if (pIdx === 0) state.defaultPlayer = null;
- else state.defaultPlayer = players[pIdx - 1];
- saveState(state);
- await showAlert("تم", "تم حفظ الإعدادات");
- } else if (idx === 1) {
- // Clear cache logic
- let fm = FileManager.local();
- let path = getCachePath(fm);
- if (fm.fileExists(path)) fm.remove(path);
- await showAlert("تم", "تم مسح البيانات");
- }
- }
- function getCachePath(fm) {
- return fm.joinPath(fm.documentsDirectory(), CONFIG.cacheFileName);
- }
- function loadState() {
- let fm = FileManager.local();
- let path = getCachePath(fm);
- if (fm.fileExists(path)) {
- try {
- return JSON.parse(fm.readString(path));
- } catch (e) { return { history: [], favorites: [], defaultPlayer: null }; }
- .some }
- return { history: [], favorites: [], defaultPlayer: null };
- }
- function saveState(state) {
- let fm = FileManager.local();
- let path = getCachePath(fm);
- fm.writeString(path, JSON.stringify(state));
- }
- function addToHistory(state, query) {
- state.history = state.history || [];
- state.history = state.history.filter(h => h !== query);
- state.history.unshift(query);
- if (state.history.length > 10) state.history.pop();
- saveState(state);
- }
- function addToFavorites(state, item) {
- state.favorites = state.favorites || [];
- if (!state.favorites.find(f => f.href === item.href)) {
- state.favorites.push(item);
- saveState(state);
- }
- }
- function removeFromFavorites(state, item) {
- state.favorites = state.favorites || [];
- state.favorites = state.favorites.filter(f => f.href !== item.href);
- saveState(state);
- }
- function isFavorite(state, item) {
- return (state.favorites || []
- )(f => f.href === item.href);
- }
- // --- Standard UI Helpers ---
- async function presentPrompt(title, msg) {
- let a = new Alert();
- a.title = title;
- a.message = msg;
- a.addTextField("اكتب هنا...", "");
- a.addAction("بحث");
- a.addCancelAction("إلغاء");
- return (await a.present()) === -1 ? null : a.textFieldValue(0);
- }
- async function presentMenu(title, items) {
- let a = new Alert();
- a.title = title;
- items.forEach(i => a.addAction(i));
- a.addCancelAction("إلغاء");
- return await a.presentSheet();
- }
- async function showAlert(title, msg) {
- let a = new Alert();
- a.title = title;
- a.message = msg;
- a.addAction("موافق");
- await a.present();
- }
- async function showNotification(title, body) {
- let n = new Notification();
- n.title = title;
- n.body = body;
- n.schedule();
- }
Advertisement
Add Comment
Please, Sign In to add comment