Update index.html
Browse files- index.html +138 -82
index.html
CHANGED
|
@@ -3,119 +3,175 @@
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
-
<title>یوتیوب دانلودر
|
|
|
|
| 7 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
<style>
|
| 9 |
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;700&display=swap');
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 13 |
</style>
|
| 14 |
</head>
|
| 15 |
-
<body class="flex items-center justify-center
|
| 16 |
|
| 17 |
-
<div class="
|
| 18 |
-
<
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
<
|
| 22 |
-
|
| 23 |
-
<input type="text" id="youtubeUrl" placeholder="https://youtube.com/watch?v=..."
|
| 24 |
-
class="w-full p-3 rounded-lg bg-slate-900 border border-slate-600 focus:ring-2 focus:ring-blue-500 outline-none text-left" dir="ltr">
|
| 25 |
-
</div>
|
| 26 |
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
<
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
</button>
|
| 34 |
</div>
|
| 35 |
-
|
| 36 |
-
<div id="status" class="hidden mt-4 p-4 rounded-lg text-center text-sm"></div>
|
| 37 |
|
| 38 |
-
<
|
| 39 |
-
|
| 40 |
-
<
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
</div>
|
| 42 |
</div>
|
| 43 |
|
| 44 |
-
<
|
| 45 |
-
|
| 46 |
-
|
|
|
|
|
|
|
| 47 |
</div>
|
| 48 |
</div>
|
| 49 |
|
| 50 |
<script>
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
const statusDiv = document.getElementById('status');
|
| 54 |
-
const loadingBox = document.getElementById('loadingBox');
|
| 55 |
-
const btnMp3 = document.getElementById('btnMp3');
|
| 56 |
-
const btnMp4 = document.getElementById('btnMp4');
|
| 57 |
-
|
| 58 |
-
if (!urlInput) {
|
| 59 |
-
showStatus("لطفا لینک یوتیوب را وارد کنید!", "bg-red-900/50 text-red-300");
|
| 60 |
-
return;
|
| 61 |
-
}
|
| 62 |
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
const
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
|
|
|
| 72 |
}
|
| 73 |
|
| 74 |
-
//
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
|
| 80 |
try {
|
| 81 |
-
|
| 82 |
-
|
| 83 |
-
|
| 84 |
-
});
|
| 85 |
|
| 86 |
-
if (
|
| 87 |
-
throw new Error(
|
| 88 |
}
|
| 89 |
|
| 90 |
-
//
|
| 91 |
-
|
| 92 |
-
|
| 93 |
|
| 94 |
-
// ا
|
| 95 |
-
const
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 103 |
|
| 104 |
} catch (error) {
|
| 105 |
-
|
| 106 |
-
showStatus("خطا: " + error.message, "bg-red-900/50 text-red-300");
|
| 107 |
} finally {
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
btnMp4.disabled = false;
|
| 111 |
}
|
| 112 |
}
|
| 113 |
|
| 114 |
-
function
|
| 115 |
-
const
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 119 |
}
|
| 120 |
</script>
|
| 121 |
</body>
|
|
|
|
| 3 |
<head>
|
| 4 |
<meta charset="UTF-8">
|
| 5 |
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>یوتیوب دانلودر اختصاصی</title>
|
| 7 |
+
<!-- استفاده از Tailwind CSS برای ظاهر مدرن -->
|
| 8 |
<script src="https://cdn.tailwindcss.com"></script>
|
| 9 |
<style>
|
| 10 |
@import url('https://fonts.googleapis.com/css2?family=Vazirmatn:wght@300;400;700&display=swap');
|
| 11 |
+
|
| 12 |
+
body {
|
| 13 |
+
font-family: 'Vazirmatn', sans-serif;
|
| 14 |
+
background-color: #0f172a;
|
| 15 |
+
color: #f8fafc;
|
| 16 |
+
}
|
| 17 |
+
|
| 18 |
+
.glass-card {
|
| 19 |
+
background: rgba(30, 41, 59, 0.7);
|
| 20 |
+
backdrop-filter: blur(10px);
|
| 21 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 22 |
+
}
|
| 23 |
+
|
| 24 |
+
.loader {
|
| 25 |
+
border: 3px solid rgba(255, 255, 255, 0.1);
|
| 26 |
+
border-top: 3px solid #ef4444;
|
| 27 |
+
border-radius: 50%;
|
| 28 |
+
width: 24px;
|
| 29 |
+
height: 24px;
|
| 30 |
+
animation: spin 1s linear infinite;
|
| 31 |
+
display: inline-block;
|
| 32 |
+
}
|
| 33 |
+
|
| 34 |
+
@keyframes spin {
|
| 35 |
+
0% { transform: rotate(0deg); }
|
| 36 |
+
100% { transform: rotate(360deg); }
|
| 37 |
+
}
|
| 38 |
</style>
|
| 39 |
</head>
|
| 40 |
+
<body class="min-h-screen flex items-center justify-center p-4">
|
| 41 |
|
| 42 |
+
<div class="glass-card w-full max-w-xl p-8 rounded-3xl shadow-2xl">
|
| 43 |
+
<!-- هدر -->
|
| 44 |
+
<div class="text-center mb-8">
|
| 45 |
+
<h1 class="text-3xl font-extrabold text-red-500 mb-2">YouTube Grabber</h1>
|
| 46 |
+
<p class="text-slate-400 text-sm">متصل به API اختصاصی Akashh89</p>
|
| 47 |
+
</div>
|
|
|
|
|
|
|
|
|
|
| 48 |
|
| 49 |
+
<!-- بخش ورودی -->
|
| 50 |
+
<div class="space-y-4">
|
| 51 |
+
<div class="relative">
|
| 52 |
+
<input type="text" id="videoUrl"
|
| 53 |
+
class="w-full bg-slate-900 border border-slate-700 p-4 pr-4 rounded-2xl outline-none focus:ring-2 focus:ring-red-500 transition-all text-left"
|
| 54 |
+
placeholder="https://www.youtube.com/watch?v=..." dir="ltr">
|
|
|
|
| 55 |
</div>
|
|
|
|
|
|
|
| 56 |
|
| 57 |
+
<button onclick="fetchVideoInfo()" id="btnFetch"
|
| 58 |
+
class="w-full bg-red-600 hover:bg-red-700 py-4 rounded-2xl font-bold text-lg transition-all transform active:scale-95 flex justify-center items-center gap-2">
|
| 59 |
+
<span id="btnText">دریافت اطلاعات ویدیو</span>
|
| 60 |
+
<div id="btnLoader" class="loader hidden"></div>
|
| 61 |
+
</button>
|
| 62 |
+
</div>
|
| 63 |
+
|
| 64 |
+
<!-- بخش نمایش نتیجه (در ابتدا مخفی است) -->
|
| 65 |
+
<div id="videoCard" class="hidden mt-8 border-t border-slate-700 pt-6">
|
| 66 |
+
<div class="flex flex-col sm:flex-row gap-4">
|
| 67 |
+
<img id="thumbnail" src="" alt="Thumbnail" class="w-full sm:w-48 rounded-xl shadow-lg object-cover">
|
| 68 |
+
<div class="flex-1">
|
| 69 |
+
<h2 id="videoTitle" class="text-lg font-bold mb-4 leading-tight"></h2>
|
| 70 |
+
|
| 71 |
+
<div class="grid grid-cols-1 gap-2">
|
| 72 |
+
<!-- دکمههای دانلود که توسط جاوااسکریپت ساخته میشوند -->
|
| 73 |
+
<div id="downloadOptions" class="space-y-2"></div>
|
| 74 |
+
</div>
|
| 75 |
+
</div>
|
| 76 |
</div>
|
| 77 |
</div>
|
| 78 |
|
| 79 |
+
<!-- نمایش وضعیت و خطاها -->
|
| 80 |
+
<div id="statusMessage" class="hidden mt-4 p-3 rounded-xl text-center text-sm"></div>
|
| 81 |
+
|
| 82 |
+
<div class="mt-8 text-center text-xs text-slate-500 italic">
|
| 83 |
+
توجه: این پنل فقط با لینک مستقیم کار میکند و قابلیت جستجو ندارد.
|
| 84 |
</div>
|
| 85 |
</div>
|
| 86 |
|
| 87 |
<script>
|
| 88 |
+
// آدرس API که شما پیدا کردید
|
| 89 |
+
const API_BASE = "https://akashh89-ytgrab-new.hf.space";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 90 |
|
| 91 |
+
async function fetchVideoInfo() {
|
| 92 |
+
const url = document.getElementById('videoUrl').value;
|
| 93 |
+
const btnText = document.getElementById('btnText');
|
| 94 |
+
const btnLoader = document.getElementById('btnLoader');
|
| 95 |
+
const videoCard = document.getElementById('videoCard');
|
| 96 |
+
const statusMessage = document.getElementById('statusMessage');
|
| 97 |
+
|
| 98 |
+
if (!url) {
|
| 99 |
+
showMessage("لطفاً ابتدا لینک ویدیو را وارد کنید", "bg-yellow-900/50 text-yellow-200");
|
| 100 |
+
return;
|
| 101 |
}
|
| 102 |
|
| 103 |
+
// ریست کردن ظاهر
|
| 104 |
+
statusMessage.classList.add('hidden');
|
| 105 |
+
videoCard.classList.add('hidden');
|
| 106 |
+
btnText.innerText = "در حال ارتباط با سرور...";
|
| 107 |
+
btnLoader.classList.remove('hidden');
|
| 108 |
|
| 109 |
try {
|
| 110 |
+
// مرحله 1: فراخوانی Info API
|
| 111 |
+
const response = await fetch(`${API_BASE}/info?url=${encodeURIComponent(url)}`);
|
| 112 |
+
const data = await response.json();
|
|
|
|
| 113 |
|
| 114 |
+
if (data.error) {
|
| 115 |
+
throw new Error(data.error);
|
| 116 |
}
|
| 117 |
|
| 118 |
+
// نمایش اطلاعات ویدیو
|
| 119 |
+
document.getElementById('thumbnail').src = data.thumbnail;
|
| 120 |
+
document.getElementById('videoTitle').innerText = data.title;
|
| 121 |
|
| 122 |
+
// ساخت دکمههای دانلود بر اساس فرمتهای API
|
| 123 |
+
const optionsContainer = document.getElementById('downloadOptions');
|
| 124 |
+
optionsContainer.innerHTML = ''; // پاک کردن دکمههای قبلی
|
| 125 |
+
|
| 126 |
+
// اضافه کردن کیفیتهای ویدیو (360p و 720p)
|
| 127 |
+
data.video_formats.forEach(fmt => {
|
| 128 |
+
createDownloadBtn(optionsContainer, url, fmt.format_id, `دانلود ویدیو (${fmt.quality})`, 'bg-blue-600');
|
| 129 |
+
});
|
| 130 |
+
|
| 131 |
+
// اضافه کردن کیفیت صدا
|
| 132 |
+
data.audio_formats.forEach(fmt => {
|
| 133 |
+
createDownloadBtn(optionsContainer, url, fmt.format_id, `دانلود صوتی (MP3 - ${fmt.quality}kbps)`, 'bg-green-600');
|
| 134 |
+
});
|
| 135 |
+
|
| 136 |
+
videoCard.classList.remove('hidden');
|
| 137 |
+
showMessage("اطلاعات با موفقیت دریافت شد", "bg-green-900/50 text-green-200");
|
| 138 |
|
| 139 |
} catch (error) {
|
| 140 |
+
showMessage("خطا: " + error.message, "bg-red-900/50 text-red-200");
|
|
|
|
| 141 |
} finally {
|
| 142 |
+
btnText.innerText = "دریافت اطلاعات ویدیو";
|
| 143 |
+
btnLoader.classList.add('hidden');
|
|
|
|
| 144 |
}
|
| 145 |
}
|
| 146 |
|
| 147 |
+
function createDownloadBtn(container, url, formatId, text, colorClass) {
|
| 148 |
+
const btn = document.createElement('button');
|
| 149 |
+
btn.className = `w-full ${colorClass} hover:opacity-90 py-2 px-4 rounded-lg font-bold text-sm transition-all mb-2 flex justify-between items-center`;
|
| 150 |
+
|
| 151 |
+
// لینک نهایی دانلود
|
| 152 |
+
const downloadUrl = `${API_BASE}/download?url=${encodeURIComponent(url)}&format_id=${formatId}`;
|
| 153 |
+
|
| 154 |
+
btn.innerHTML = `
|
| 155 |
+
<span>${text}</span>
|
| 156 |
+
<svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4" fill="none" viewBox="0 0 24 24" stroke="currentColor">
|
| 157 |
+
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" />
|
| 158 |
+
</svg>
|
| 159 |
+
`;
|
| 160 |
+
|
| 161 |
+
btn.onclick = () => {
|
| 162 |
+
// باز کردن لینک دانلود در یک برگه جدید برای شروع دانلود خودکار
|
| 163 |
+
window.open(downloadUrl, '_blank');
|
| 164 |
+
showMessage("درخواست دانلود به سرور فرستاده شد. لطفا صبر کنید...", "bg-blue-900/50 text-blue-200");
|
| 165 |
+
};
|
| 166 |
+
|
| 167 |
+
container.appendChild(btn);
|
| 168 |
+
}
|
| 169 |
+
|
| 170 |
+
function showMessage(text, classes) {
|
| 171 |
+
const statusMessage = document.getElementById('statusMessage');
|
| 172 |
+
statusMessage.innerText = text;
|
| 173 |
+
statusMessage.className = `mt-4 p-3 rounded-xl text-center text-sm ${classes}`;
|
| 174 |
+
statusMessage.classList.remove('hidden');
|
| 175 |
}
|
| 176 |
</script>
|
| 177 |
</body>
|