Spaces:
Running
Running
| <html lang="tr"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>PCoreX Parçalı Bulut Aktarıcı</title> | |
| <style> | |
| body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f4f7f6; display: flex; justify-content: center; align-items: center; min-height: 100vh; margin: 0; } | |
| .card { background: white; padding: 30px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-align: center; max-width: 500px; width: 100%; } | |
| h1 { color: #333; margin-bottom: 10px; } | |
| p { color: #666; font-size: 14px; margin-bottom: 25px; } | |
| button { width: 100%; padding: 12px; border: none; border-radius: 6px; font-size: 16px; font-weight: bold; cursor: pointer; margin-bottom: 15px; transition: 0.2s; } | |
| .btn-login { background-color: #4285F4; color: white; } | |
| .btn-login:hover { background-color: #357ae8; } | |
| .btn-upload { background-color: #34a853; color: white; display: none; } | |
| .btn-upload:hover { background-color: #2d9247; } | |
| #status { margin-top: 15px; padding: 15px; border-radius: 6px; font-size: 14px; display: none; text-align: left; max-height: 200px; overflow-y: auto; box-sizing: border-box; } | |
| .info { background: #e8f0fe; color: #1967d2; border-left: 5px solid #1967d2; } | |
| .success { background: #e6f4ea; color: #137333; border-left: 5px solid #137333; } | |
| .error { background: #fce8e6; color: #c5221f; border-left: 5px solid #c5221f; } | |
| .file-log { font-family: monospace; font-size: 12px; margin-top: 5px; } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="card"> | |
| <h1>🚀 PCoreX Klasörlü Aktarıcı</h1> | |
| <p>Hugging Face veri setindeki tüm parçaları, Google Drive'ındaki belirlediğin klasöre tek tek uçurur.</p> | |
| <button id="loginBtn" class="btn-login" onclick="googleLogin()">🔑 Google ile Giriş Yap & Yetki Ver</button> | |
| <button id="uploadBtn" class="btn-upload" onclick="startBatchUpload()">🚀 Tüm Parçaları Klasöre Gönder</button> | |
| <div id="status"></div> | |
| </div> | |
| <script> | |
| const SUPABASE_URL = "https://pesdklsmuuswzvqxyqed.supabase.co"; | |
| const HF_SPACE_URL = "https://magelord-pcorex.hf.space"; | |
| const DATASET_REPO = "MageLord/PCoreX-Backup-DataSet"; | |
| // 📁 🔑 MANUEL OLUŞTURDUĞUN KLASÖRÜN ID'SİNİ BURAYA YAPIŞTIR ŞEF | |
| const TARGET_FOLDER_ID = "1yX0MVX7MelHVXXXU3gL3_QMGPuNAogBT"; | |
| let googleToken = ""; | |
| window.onload = function() { | |
| const hash = window.location.hash; | |
| if (hash && hash.includes("access_token")) { | |
| const params = new URLSearchParams(hash.replace("#", "?")); | |
| googleToken = params.get("access_token"); | |
| if (googleToken) { | |
| document.getElementById("loginBtn").style.display = "none"; | |
| document.getElementById("uploadBtn").style.display = "block"; | |
| showStatus("🔑 Giriş başarılı! Sabit klasör bağlantısı kuruldu. Süreci başlatabiliriz şef.", "success"); | |
| } | |
| } | |
| } | |
| function googleLogin() { | |
| const scopes = "https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive"; | |
| window.location.href = `${SUPABASE_URL}/auth/v1/authorize?provider=google&scopes={scopes}&redirect_to={HF_SPACE_URL}`; | |
| } | |
| async function startBatchUpload() { | |
| const statusEl = document.getElementById("status"); | |
| showStatus("⏳ Hugging Face kovası taranıyor, dosya listesi alınıyor...", "info"); | |
| document.getElementById("uploadBtn").disabled = true; | |
| try { | |
| // HF API kullanarak veri setindeki tüm dosyaların listesini çekiyoruz | |
| const hfApiUrl = `https://huggingface.co/api/datasets/${DATASET_REPO}/tree/main`; | |
| const hfResponse = await fetch(hfApiUrl); | |
| if (!hfResponse.ok) throw new Error("Hugging Face veri seti listesi alınamadı!"); | |
| const filesList = await hfResponse.json(); | |
| const validFiles = filesList.filter(f => f.type === "file" && f.path !== ".gitattributes"); | |
| if (validFiles.length === 0) { | |
| throw new Error("Veri setinde aktarılacak dosya bulunamadı şef!"); | |
| } | |
| statusEl.innerHTML = `<strong>⏳ Toplam ${validFiles.length} parça hedef klasöre pompalanıyor...</strong>`; | |
| // Her dosyayı sırayla indirip Drive'daki sabit klasöre yüklüyoruz | |
| for (let i = 0; i < validFiles.length; i++) { | |
| const file = validFiles[i]; | |
| const fileLogId = `file-${i}`; | |
| statusEl.innerHTML += `<div id="${fileLogId}" class="file-log">⏳ [${i+1}/${validFiles.length}] ${file.path} buluttan çekiliyor...</div>`; | |
| statusEl.scrollTop = statusEl.scrollHeight; | |
| const downloadUrl = `https://huggingface.co/datasets/${DATASET_REPO}/resolve/main/${file.path}`; | |
| // Parçayı indir | |
| const fileResponse = await fetch(downloadUrl); | |
| if (!fileResponse.ok) { | |
| document.getElementById(fileLogId).innerText = `❌ [${i+1}/${validFiles.length}] ${file.path} indirilemedi, atlanıyor.`; | |
| continue; | |
| } | |
| const fileBlob = await fileResponse.blob(); | |
| document.getElementById(fileLogId).innerText = `🚀 [${i+1}/${validFiles.length}] ${file.path} hedef klasöre yükleniyor...`; | |
| // Dosya metadata'sına parents olarak senin manuel klasör ID'ni veriyoruz | |
| const metadata = { | |
| name: file.path, | |
| mimeType: fileBlob.type || "text/plain", | |
| parents: [TARGET_FOLDER_ID] | |
| }; | |
| const form = new FormData(); | |
| form.append("metadata", new Blob([JSON.stringify(metadata)], { type: "application/json" })); | |
| form.append("file", fileBlob); | |
| // Google Drive'a gönder | |
| const driveResponse = await fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", { | |
| method: "POST", | |
| headers: { "Authorization": `Bearer ${googleToken}` }, | |
| body: form | |
| }); | |
| if (driveResponse.ok) { | |
| document.getElementById(fileLogId).innerText = `✅ [${i+1}/${validFiles.length}] ${file.path} klasöre başarıyla uçtu!`; | |
| document.getElementById(fileLogId).style.color = "#137333"; | |
| } else { | |
| document.getElementById(fileLogId).innerText = `❌ [${i+1}/${validFiles.length}] ${file.path} yüklenemedi!`; | |
| document.getElementById(fileLogId).style.color = "#c5221f"; | |
| } | |
| statusEl.scrollTop = statusEl.scrollHeight; | |
| } | |
| statusEl.innerHTML += `<br><strong>🔥 İŞLEM TAMAMLANDI! Tüm parçalar manuel açtığın klasörde seni bekliyor şef!</strong>`; | |
| statusEl.className = "success"; | |
| } catch (error) { | |
| showStatus("❌ Hata oluştu: " + error.message, "error"); | |
| document.getElementById("uploadBtn").disabled = false; | |
| } | |
| } | |
| function showStatus(text, type) { | |
| const el = document.getElementById("status"); | |
| el.style.display = "block"; | |
| el.className = type; | |
| el.innerText = text; | |
| } | |
| </script> | |
| </body> | |
| </html> | |