MageLord commited on
Commit
4c4bb79
·
verified ·
1 Parent(s): 103c617

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +107 -42
index.html CHANGED
@@ -3,10 +3,10 @@
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
- <title>PCoreX Bulut Aktarım İstasyonu</title>
7
  <style>
8
- body { font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; background: #f4f7f6; display: flex; justify-content: center; align-items: center; height: 100vh; margin: 0; }
9
- .card { background: white; padding: 30px; border-radius: 12px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); text-align: center; max-width: 450px; width: 100%; }
10
  h1 { color: #333; margin-bottom: 10px; }
11
  p { color: #666; font-size: 14px; margin-bottom: 25px; }
12
  button { width: 100%; padding: 12px; border: none; border-radius: 6px; font-size: 16px; font-weight: bold; cursor: pointer; margin-bottom: 15px; transition: 0.2s; }
@@ -14,32 +14,31 @@
14
  .btn-login:hover { background-color: #357ae8; }
15
  .btn-upload { background-color: #34a853; color: white; display: none; }
16
  .btn-upload:hover { background-color: #2d9247; }
17
- #status { margin-top: 15px; padding: 10px; border-radius: 6px; font-size: 14px; display: none; word-break: break-all; }
18
- .info { background: #e8f0fe; color: #1967d2; }
19
- .success { background: #e6f4ea; color: #137333; }
20
- .error { background: #fce8e6; color: #c5221f; }
 
21
  </style>
22
  </head>
23
  <body>
24
 
25
  <div class="card">
26
- <h1>🚀 PCoreX Aktarıcı</h1>
27
- <p>Kaggle verisini internetini harcamadan Drive'ına uçur.</p>
28
 
29
  <button id="loginBtn" class="btn-login" onclick="googleLogin()">🔑 Google ile Giriş Yap & Yetki Ver</button>
30
- <button id="uploadBtn" class="btn-upload" onclick="startUpload()">🚀 Drive'a Gönder (0 MB İnternet)</button>
31
 
32
  <div id="status"></div>
33
  </div>
34
 
35
  <script>
36
- // 🔑 ANAHTARLAR KODUN İÇİNE GÖMÜLDÜ ŞEF
37
  const SUPABASE_URL = "https://pesdklsmuuswzvqxyqed.supabase.co";
38
- const SUPABASE_ANON_KEY = "sb_publishable_ta2gVJfA149gbcAv3cdjtw_CJ91mjSc";
39
  const HF_SPACE_URL = "https://magelord-pcorex.hf.space";
 
40
  let googleToken = "";
41
 
42
- // Sayfa yüklendiğinde URL'de token var mı kontrol et
43
  window.onload = function() {
44
  const hash = window.location.hash;
45
  if (hash && hash.includes("access_token")) {
@@ -49,48 +48,114 @@
49
  if (googleToken) {
50
  document.getElementById("loginBtn").style.display = "none";
51
  document.getElementById("uploadBtn").style.display = "block";
52
- showStatus("🔑 Giriş başarılı! Jeton alındı. Şimdi Drive'a gönderebilirsin şef.", "success");
53
  }
54
  }
55
  }
56
 
57
  function googleLogin() {
58
  const scopes = "https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive";
59
- // Doğrudan gömülü URL ve anahtarla Supabase OAuth tetikleniyor
60
  window.location.href = `${SUPABASE_URL}/auth/v1/authorize?provider=google&scopes=${scopes}&redirect_to=${HF_SPACE_URL}`;
61
  }
62
 
63
- async function startUpload() {
64
- showStatus("⏳ Tünel açılıyor, dosya buluttan Drive'ına pompalanıyor...", "info");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  document.getElementById("uploadBtn").disabled = true;
66
 
67
- const hfFileUrl = "https://huggingface.co/datasets/MageLord/PCoreX-Backup-DataSet/resolve/main/data.txt";
68
-
69
  try {
70
- // 1. HF üzerindeki o dev dosyayı tarayıcıya akış (stream) olarak alıyoruz
71
- const response = await fetch(hfFileUrl);
72
- if (!response.ok) throw new Error("HF Kovasından dosya çekilemedi. Kaggle işlemi bitmemiş olabilir.");
73
- const fileBlob = await response.blob();
74
-
75
- // 2. Google Drive API Multipart Upload isteği hazırlıyoruz
76
- const metadata = { name: "PCoreX_data.txt", mimeType: "text/plain" };
77
- const form = new FormData();
78
- form.append("metadata", new Blob([JSON.stringify(metadata)], { type: "application/json" }));
79
- form.append("file", fileBlob);
80
-
81
- // 3. Google Drive'a doğrudan postalıyoruz
82
- const driveResponse = await fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", {
83
- method: "POST",
84
- headers: { "Authorization": `Bearer ${googleToken}` },
85
- body: form
86
- });
87
-
88
- if (driveResponse.ok) {
89
- showStatus("🔥 MUAZZAM! Dosya şu an Google Drive'ında seni bekliyor şef!", "success");
90
- } else {
91
- const errData = await driveResponse.text();
92
- throw new Error(errData);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
93
  }
 
 
 
 
94
  } catch (error) {
95
  showStatus("❌ Hata oluştu: " + error.message, "error");
96
  document.getElementById("uploadBtn").disabled = false;
 
3
  <head>
4
  <meta charset="UTF-8">
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>PCoreX Parçalı Bulut Aktarıcı</title>
7
  <style>
8
+ 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; }
9
+ .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%; }
10
  h1 { color: #333; margin-bottom: 10px; }
11
  p { color: #666; font-size: 14px; margin-bottom: 25px; }
12
  button { width: 100%; padding: 12px; border: none; border-radius: 6px; font-size: 16px; font-weight: bold; cursor: pointer; margin-bottom: 15px; transition: 0.2s; }
 
14
  .btn-login:hover { background-color: #357ae8; }
15
  .btn-upload { background-color: #34a853; color: white; display: none; }
16
  .btn-upload:hover { background-color: #2d9247; }
17
+ #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; }
18
+ .info { background: #e8f0fe; color: #1967d2; border-left: 5px solid #1967d2; }
19
+ .success { background: #e6f4ea; color: #137333; border-left: 5px solid #137333; }
20
+ .error { background: #fce8e6; color: #c5221f; border-left: 5px solid #c5221f; }
21
+ .file-log { font-family: monospace; font-size: 12px; margin-top: 5px; }
22
  </style>
23
  </head>
24
  <body>
25
 
26
  <div class="card">
27
+ <h1>🚀 PCoreX Klasörlü Aktarıcı</h1>
28
+ <p>Hugging Face veri setindeki tüm parçaları, Google Drive'ında özel bir klasör açarak içine tek tek uçurur.</p>
29
 
30
  <button id="loginBtn" class="btn-login" onclick="googleLogin()">🔑 Google ile Giriş Yap & Yetki Ver</button>
31
+ <button id="uploadBtn" class="btn-upload" onclick="startBatchUpload()">🚀 Klasör Oluştur & Tüm Parçaları Gönder</button>
32
 
33
  <div id="status"></div>
34
  </div>
35
 
36
  <script>
 
37
  const SUPABASE_URL = "https://pesdklsmuuswzvqxyqed.supabase.co";
 
38
  const HF_SPACE_URL = "https://magelord-pcorex.hf.space";
39
+ const DATASET_REPO = "MageLord/PCoreX-Backup-DataSet";
40
  let googleToken = "";
41
 
 
42
  window.onload = function() {
43
  const hash = window.location.hash;
44
  if (hash && hash.includes("access_token")) {
 
48
  if (googleToken) {
49
  document.getElementById("loginBtn").style.display = "none";
50
  document.getElementById("uploadBtn").style.display = "block";
51
+ showStatus("🔑 Giriş başarılı! Bağlantı hazır. Süreci başlatabiliriz şef.", "success");
52
  }
53
  }
54
  }
55
 
56
  function googleLogin() {
57
  const scopes = "https://www.googleapis.com/auth/drive.file https://www.googleapis.com/auth/drive";
 
58
  window.location.href = `${SUPABASE_URL}/auth/v1/authorize?provider=google&scopes=${scopes}&redirect_to=${HF_SPACE_URL}`;
59
  }
60
 
61
+ // 📁 Google Drive üzerinde klasör oluşturan sihirli fonksiyon
62
+ async function createDriveFolder(folderName) {
63
+ const metadata = {
64
+ name: folderName,
65
+ mimeType: "application/json",
66
+ mimeType: "application/vnd.google-apps.folder"
67
+ };
68
+
69
+ const response = await fetch("https://www.googleapis.com/drive/v3/files", {
70
+ method: "POST",
71
+ headers: {
72
+ "Authorization": `Bearer ${googleToken}`,
73
+ "Content-Type": "application/json"
74
+ },
75
+ body: JSON.stringify(metadata)
76
+ });
77
+
78
+ if (!response.ok) throw new Error("Google Drive'da hedef klasör oluşturulamadı!");
79
+ const data = await response.json();
80
+ return data.id; // Oluşturulan klasörün ID'sini döndürür
81
+ }
82
+
83
+ async function startBatchUpload() {
84
+ const statusEl = document.getElementById("status");
85
+ showStatus("⏳ Google Drive'da 'PCoreX_Backup' klasörü hazırlanıyor...", "info");
86
  document.getElementById("uploadBtn").disabled = true;
87
 
 
 
88
  try {
89
+ // 1. Önce klasörü oluşturup ID'sini kapıyoruz
90
+ const folderId = await createDriveFolder("PCoreX_Backup");
91
+
92
+ statusEl.innerHTML = `<strong>📁 Klasör başarıyla oluşturuldu!</strong><br>⏳ Hugging Face kovası taranıyor, dosya listesi alınıyor...`;
93
+
94
+ // 2. HF API kullanarak veri setindeki tüm dosyaların listesini çekiyoruz
95
+ const hfApiUrl = `https://huggingface.co/api/datasets/${DATASET_REPO}/tree/main`;
96
+ const hfResponse = await fetch(hfApiUrl);
97
+ if (!hfResponse.ok) throw new Error("Hugging Face veri seti listesi alınamadı!");
98
+
99
+ const filesList = await hfResponse.json();
100
+ const validFiles = filesList.filter(f => f.type === "file" && f.path !== ".gitattributes");
101
+
102
+ if (validFiles.length === 0) {
103
+ throw new Error("Veri setinde aktarılacak dosya bulunamadı şef!");
104
+ }
105
+
106
+ statusEl.innerHTML = `<strong>⏳ Klasör Hazır. Toplam ${validFiles.length} parça yeni klasöre pompalanıyor...</strong>`;
107
+
108
+ // 3. Her dosyayı sırayla indirip Drive'daki klasöre yüklüyoruz
109
+ for (let i = 0; i < validFiles.length; i++) {
110
+ const file = validFiles[i];
111
+ const fileLogId = `file-${i}`;
112
+
113
+ statusEl.innerHTML += `<div id="${fileLogId}" class="file-log">⏳ [${i+1}/${validFiles.length}] ${file.path} buluttan çekiliyor...</div>`;
114
+ statusEl.scrollTop = statusEl.scrollHeight;
115
+
116
+ const downloadUrl = `https://huggingface.co/datasets/${DATASET_REPO}/resolve/main/${file.path}`;
117
+
118
+ // Parçayı indir
119
+ const fileResponse = await fetch(downloadUrl);
120
+ if (!fileResponse.ok) {
121
+ document.getElementById(fileLogId).innerText = `❌ [${i+1}/${validFiles.length}] ${file.path} indirilemedi, atlanıyor.`;
122
+ continue;
123
+ }
124
+ const fileBlob = await fileResponse.blob();
125
+
126
+ document.getElementById(fileLogId).innerText = `🚀 [${i+1}/${validFiles.length}] ${file.path} yeni klasöre yükleniyor...`;
127
+
128
+ // 📁 KRİTİK AYAR: Dosya metadata'sına parents (ebeveyn klasör) olarak oluşturduğumuz klasörün ID'sini ekliyoruz
129
+ const metadata = {
130
+ name: file.path,
131
+ mimeType: fileBlob.type || "text/plain",
132
+ parents: [folderId]
133
+ };
134
+
135
+ const form = new FormData();
136
+ form.append("metadata", new Blob([JSON.stringify(metadata)], { type: "application/json" }));
137
+ form.append("file", fileBlob);
138
+
139
+ // Google Drive'a fırlat
140
+ const driveResponse = await fetch("https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart", {
141
+ method: "POST",
142
+ headers: { "Authorization": `Bearer ${googleToken}` },
143
+ body: form
144
+ });
145
+
146
+ if (driveResponse.ok) {
147
+ document.getElementById(fileLogId).innerText = `✅ [${i+1}/${validFiles.length}] ${file.path} klasöre uçtu!`;
148
+ document.getElementById(fileLogId).style.color = "#137333";
149
+ } else {
150
+ document.getElementById(fileLogId).innerText = `❌ [${i+1}/${validFiles.length}] ${file.path} yüklenemedi!`;
151
+ document.getElementById(fileLogId).style.color = "#c5221f";
152
+ }
153
+ statusEl.scrollTop = statusEl.scrollHeight;
154
  }
155
+
156
+ statusEl.innerHTML += `<br><strong>🔥 MUHTEŞEM! Tüm parçalar 'PCoreX_Backup' klasörünün içine tıkır tıkır yüklendi şef!</strong>`;
157
+ statusEl.className = "success";
158
+
159
  } catch (error) {
160
  showStatus("❌ Hata oluştu: " + error.message, "error");
161
  document.getElementById("uploadBtn").disabled = false;