منصه اكاوم للمسلسلات و الافلام
javascriptv1MITنُشر ٢٠ أكتوبر ٢٠٢٦· ♥ 0 · ⬇ 3 · 💬 0
بحث و تحميل افلام و مسلسلات عدل الامر كسلان أصلح عيبو بس السكراب تمام
code-55.js
import axios from 'axios';
import * as cheerio from 'cheerio';
import { generateWAMessageFromContent, proto } from '@whiskeysockets/baileys';
const BASE = 'https://akwam.ss';
const UA = 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 Chrome/135.0.0.0 Mobile Safari/537.36';
const sessions = new Map();
const TTL = 15 * 60 * 1000;
const http = axios.create({
baseURL: BASE,
timeout: 30000,
responseType: 'text',
headers: {
'User-Agent': UA,
Accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'ar,en;q=0.8'
},
maxRedirects: 5,
validateStatus: s => s >= 200 && s < 400
});
const clean = value => String(value ?? '').replace(/\s+/g, ' ').trim();
const abs = value => {
try { return new URL(value, BASE).href; } catch { return ''; }
};
const enc = value => Buffer.from(String(value)).toString('base64url');
const dec = value => Buffer.from(String(value), 'base64url').toString('utf8');
const esc = value => String(value ?? '').replace(/[|\n\r]/g, ' ').trim();
function imageOf($, root = $.root()) {
const img = root.find('img').first();
return abs(img.attr('data-src') || img.attr('data-original') || img.attr('src') || '');
}
function textOf(root, selector) {
return clean(root.find(selector).first().text());
}
function parseSearch(html, limit = 15) {
const $ = cheerio.load(html);
const results = [];
const seen = new Set();
$('div.entry-box').each((_, element) => {
const root = $(element);
const link = root.find('h3.entry-title a[href], a.box[href]').first().attr('href');
if (!link || seen.has(link)) return;
seen.add(link);
const title = textOf(root, 'h3.entry-title a') || clean(root.find('img').attr('alt'));
const rating = clean(root.find('.label.rating').text()).replace(/[^0-9.]/g, '') || 'غير معروف';
const quality = clean(root.find('.label.quality').text()) || 'غير معروف';
const badges = root.find('.entry-body .badge').map((_, x) => clean($(x).text())).get();
const year = badges.find(x => /^\d{4}$/.test(x)) || 'غير معروف';
const type = /\/series\//.test(link) ? 'series' : /\/movie\//.test(link) ? 'movie' : 'show';
results.push({
title: title || 'بدون عنوان',
url: abs(link),
image: imageOf($, root),
rating,
quality,
year,
type
});
});
return results.slice(0, limit);
}
function parseInfo(html, url) {
const $ = cheerio.load(html);
const mainImage = imageOf($, $('.entry-image').first().length ? $('.entry-image').first() : $('main').first());
const title = clean($('h1').first().text()) || 'بدون عنوان';
const pageText = clean($('body').text());
const type = /\/series\//.test(url) ? 'series' : /\/movie\//.test(url) ? 'movie' : 'episode';
const valueAfter = label => {
const match = pageText.match(new RegExp(`(?:${label})\\s*:\\s*([^:،\\n]+)`, 'i'));
return clean(match?.[1] || 'غير متوفر');
};
const rating = clean(pageText.match(/10\s*\/\s*([0-9.]+)/)?.[1] || 'غير متوفر');
const year = clean(pageText.match(/السنة\s*:\s*(\d{4})/)?.[1] || pageText.match(/\b(19|20)\d{2}\b/)?.[0] || 'غير متوفر');
const language = valueAfter('اللغة');
const quality = valueAfter('الجودة|جودة الفيلم');
const country = valueAfter('انتاج');
const duration = valueAfter('مدة الفيلم|مدة المسلسل');
let story = '';
const storyHeading = $('h2').filter((_, x) => /قصة الفيلم|قصة المسلسل/i.test($(x).text())).first();
if (storyHeading.length) {
let node = storyHeading.next();
while (node.length && story.length < 1200) {
const value = clean(node.text());
if (value && !/فريق العمل|مشاهدة وتحميل|الحلقات|شاهد المزيد/i.test(value)) story += `${value} `;
node = node.next();
}
}
if (!story) story = clean($('h2').filter((_, x) => /قصة/i.test($(x).text())).parent().text()).replace(/^.*?قصة[^:]*:?/i, '').slice(0, 1200);
const downloads = [];
$('a[href*="/download/"]').each((_, x) => {
const href = abs($(x).attr('href'));
if (!href || downloads.some(d => d.url === href)) return;
downloads.push({ title: clean($(x).text()) || 'تحميل', url: href });
});
const episodes = [];
$('a[href*="/episode/"]').each((_, x) => {
const href = abs($(x).attr('href'));
const label = clean($(x).text());
if (!href || episodes.some(e => e.url === href)) return;
const number = label.match(/(?:حلقة|الحلقة)\s*:?\s*(\d+)/i)?.[1] || label.match(/(\d+)\s*$/)?.[1] || '';
episodes.push({ title: label || `الحلقة ${number}`, number, url: href });
});
return { title, url, image: mainImage, type, rating, year, language, quality, country, duration, story: story || 'لا توجد قصة متاحة.', downloads, episodes };
}
function detailsCaption(info, episode = false) {
return [
`🎬 *${info.title}*`,
episode ? `🎞️ *النوع:* حلقة ${info.episode || ''}` : `📁 *النوع:* ${info.type === 'series' ? 'مسلسل' : 'فيلم'}`,
`📅 *السنة:* ${info.year}`,
`🗣️ *اللغة:* ${info.language}`,
`⭐ *التقييم:* ${info.rating}`,
`🎞️ *الجودة:* ${info.quality}`,
`🌍 *الإنتاج:* ${info.country}`,
`⏱️ *المدة:* ${info.duration}`,
`📝 *القصة:* ${info.story}`
].join('\n');
}
async function sendInteractiveList(conn, m, text, rows, title, footer = 'ᯓ 𖥻 ׁ ׅ NEZUKO BOT ׁ') {
if (!rows || rows.length === 0) return;
const sections = [];
for (let i = 0; i < rows.length; i += 10) {
sections.push({
title: `${title} ${i + 1}-${Math.min(i + 10, rows.length)}`,
rows: rows.slice(i, i + 10)
});
}
const buttons = [{
name: 'single_select',
buttonParamsJson: JSON.stringify({
title: title.length > 20 ? 'اختر من القائمة' : title,
sections: sections
})
}];
const msg = generateWAMessageFromContent(m.chat, {
viewOnceMessage: { message: { interactiveMessage: proto.Message.InteractiveMessage.fromObject({
body: { text: text },
footer: { text: footer },
nativeFlowMessage: { buttons: buttons }
})}}
}, { quoted: m });
await conn.relayMessage(m.chat, msg.message, {
messageId: msg.key.id,
additionalNodes: [
{
tag: 'biz',
attrs: {},
content: [
{
tag: 'interactive',
attrs: { type: 'native_flow', v: '1' },
content: [{ tag: 'native_flow', attrs: { v: '9', name: 'mixed' } }]
}
]
}
]
});
}
async function sendCover(conn, m, image, caption) {
if (image) {
try {
await conn.sendMessage(m.chat, { image: { url: image }, caption }, { quoted: m });
return;
} catch (e) {
console.error('Error sending image:', e.message);
}
}
await m.reply(caption);
}
const handler = async (m, { conn, text, usedPrefix, command }) => {
const [token, encodedUrl] = String(text || '').trim().split('|');
if (command === 'ak_result') {
const session = sessions.get(token);
if (!session || Date.now() - session.created > TTL) return m.reply('❌ انتهت النتائج، أعد البحث.');
const item = session.results.find(x => x.url === dec(encodedUrl));
if (!item) return m.reply('❌ النتيجة غير موجودة.');
await m.react('⏳');
try {
const { data } = await http.get(item.url);
const info = parseInfo(data, item.url);
const detailToken = enc(item.url);
sessions.set(detailToken, { info, created: Date.now() });
const caption = detailsCaption(info);
await sendCover(conn, m, info.image || item.image, caption);
if (info.type === 'series') {
const rows = info.episodes.map((ep, i) => ({
header: `${i + 1}`,
title: `الحلقة ${ep.number || i + 1}`,
description: ep.title.substring(0, 60),
id: `${usedPrefix}ak_episode ${detailToken}|${enc(ep.url)}`
}));
if (rows.length) {
await sendInteractiveList(conn, m, `📺 *الحلقات المتاحة:* ${rows.length}\n\nاختر الحلقة المطلوبة من القائمة أدناه:`, rows, 'الحلقات المتاحة');
} else {
await m.reply('⚠️ لم أجد حلقات معلنة في الصفحة.');
}
} else if (info.downloads.length) {
const rows = info.downloads.map((x, i) => ({
header: `${i + 1}`,
title: x.title.substring(0, 50),
description: 'صفحة التنزيل العامة',
id: `${usedPrefix}ak_download ${detailToken}|${enc(x.url)}`
}));
await sendInteractiveList(conn, m, '🔽 *اختر صفحة الجودة المطلوبة:*', rows, 'الجودات المتاحة');
} else {
await m.reply(`🔗 صفحة العمل الأصلية:\n${info.url}`);
}
await m.react('✅');
} catch (e) {
await m.react('❌');
await m.reply(`❌ حدث خطأ أثناء جلب التفاصيل: ${e.message}`);
}
return;
}
if (command === 'ak_episode') {
const session = sessions.get(token);
if (!session || Date.now() - session.created > TTL) return m.reply('❌ انتهت الجلسة، أعد البحث.');
const episodeUrl = dec(encodedUrl);
await m.react('⏳');
try {
const { data } = await http.get(episodeUrl);
const info = parseInfo(data, episodeUrl);
info.episode = info.title.match(/(?:الحلقة|حلقة)\s*(\d+)/i)?.[1] || '';
const caption = detailsCaption(info, true);
await sendCover(conn, m, info.image, caption);
if (info.downloads.length) {
const rows = info.downloads.map((x, i) => ({
header: `${i + 1}`,
title: x.title.substring(0, 50),
description: 'صفحة التنزيل العامة',
id: `${usedPrefix}ak_download ${token}|${enc(x.url)}`
}));
await sendInteractiveList(conn, m, '🔽 *اختر صفحة تنزيل الحلقة:*', rows, 'جودات الحلقة');
} else {
await m.reply(`🔗 صفحة الحلقة الأصلية:\n${episodeUrl}`);
}
await m.react('✅');
} catch (e) {
await m.react('❌');
await m.reply(`❌ حدث خطأ: ${e.message}`);
}
return;
}
// 🎯 هنا التعديل: استخراج الرابط المباشر من صفحة التحميل
if (command === 'ak_download') {
const downloadPageUrl = dec(encodedUrl);
await m.react('⏳');
try {
const { data } = await http.get(downloadPageUrl);
const $ = cheerio.load(data);
// البحث عن رابط التحميل المباشر
let directUrl = $('a.download').attr('href') || $('a.link.btn').attr('href');
// إذا لم يوجد، نجرب البحث في السكربت الذي يقوم بتحديث الرابط
if (!directUrl) {
const scriptContent = $('script').text();
const match = scriptContent.match(/https?:\/\/[^\s"']+\.(mkv|mp4|avi)/i);
if (match) directUrl = match[0];
}
if (directUrl) {
const cleanUrl = directUrl.trim();
const fileName = cleanUrl.split('/').pop() || 'download';
await conn.sendMessage(m.chat, {
document: { url: cleanUrl },
mimetype: 'video/mp4', // يمكن تغييره حسب الامتداد
fileName: fileName,
caption: `✅ *تم استخراج الرابط المباشر بنجاح!*\n\n📁 *اسم الملف:* ${fileName}\n🔗 *الرابط:* ${cleanUrl}`
}, { quoted: m });
await m.react('✅');
} else {
await m.reply(`⚠️ لم أتمكن من العثور على رابط مباشر.\nقد تكون الصفحة محمية أو بحاجة لتسجيل دخول.\n\n🔗 صفحة التنزيل:\n${downloadPageUrl}`);
await m.react('❌');
}
} catch (e) {
await m.react('❌');
await m.reply(`❌ حدث خطأ أثناء محاولة استخراج الرابط المباشر: ${e.message}`);
}
return;
}
// أوامر البحث الرئيسية
if (command !== 'فيلم' && command !== 'مسلسل') return;
const query = String(text || '').trim();
if (!query) return m.reply(`⚠️ اكتب اسم الفيلم أو المسلسل.\nمثال: ${usedPrefix}${command} Spider-Man`);
await m.react('🔍');
try {
const { data } = await http.get('/search', { params: { q: query } });
let results = parseSearch(data, 15);
if (command === 'فيلم') results = results.filter(x => x.type === 'movie' || x.type === 'series');
if (command === 'مسلسل') results = results.filter(x => x.type === 'series');
if (!results.length) return m.reply('❌ لم أجد نتائج مطابقة.');
const searchToken = enc(`${query}:${Date.now()}`);
sessions.set(searchToken, { results, created: Date.now() });
const first = results[0];
const summary = `🔎 *نتائج البحث عن:* ${query}\n📊 *عدد النتائج المتوفرة:* ${results.length}\n\n🖼️ هذه صورة أول نتيجة، اختر العمل من الأزرار أدناه:`;
await sendCover(conn, m, first.image, summary);
const rows = results.map((item, i) => ({
header: `${i + 1}`,
title: item.title.substring(0, 50),
description: `⭐ ${item.rating} | 📅 ${item.year} | ${item.type === 'series' ? 'مسلسل' : 'فيلم'}`,
id: `${usedPrefix}ak_result ${searchToken}|${enc(item.url)}`
}));
await sendInteractiveList(conn, m, 'اختر الفيلم أو المسلسل المطلوب:', rows, 'نتائج البحث');
await m.react('✅');
} catch (error) {
console.error('Akwam error:', error.response?.status, error.message);
await m.react('❌');
await m.reply(`❌ حدث خطأ أثناء قراءة Akwam:\n${error.message}`);
}
};
handler.command = /^(فيلم|مسلسل|ak_result|ak_episode|ak_download)$/i;
handler.help = ['فيلم <اسم العمل>', 'مسلسل <اسم العمل>'];
handler.tags = ['downloader'];
export default handler;سجّل الدخول لتشغيل الكود على خدمة التشغيل المعزولة.
التعليقات (1)
الكود نازل مرتين
سجّل الدخول للتعليق.