@@ -5,7 +5,7 @@ import { movieCount } from "../stores/movieStore.js";
|
|||||||
import { tvShowCount } from "../stores/tvStore.js";
|
import { tvShowCount } from "../stores/tvStore.js";
|
||||||
import { musicCount } from "../stores/musicStore.js";
|
import { musicCount } from "../stores/musicStore.js";
|
||||||
import { trashCount } from "../stores/trashStore.js";
|
import { trashCount } from "../stores/trashStore.js";
|
||||||
import { API, apiFetch, authHeaders } from "../utils/api.js";
|
import { apiFetch } from "../utils/api.js";
|
||||||
|
|
||||||
export let menuOpen = false;
|
export let menuOpen = false;
|
||||||
const dispatch = createEventDispatcher();
|
const dispatch = createEventDispatcher();
|
||||||
@@ -13,7 +13,6 @@ import { API, apiFetch, authHeaders } from "../utils/api.js";
|
|||||||
let hasShows = false;
|
let hasShows = false;
|
||||||
let hasTrash = false;
|
let hasTrash = false;
|
||||||
let hasMusic = false;
|
let hasMusic = false;
|
||||||
let cookieMessage = "";
|
|
||||||
// Svelte store kullanarak reaktivite sağla
|
// Svelte store kullanarak reaktivite sağla
|
||||||
import { writable } from 'svelte/store';
|
import { writable } from 'svelte/store';
|
||||||
const diskSpaceStore = writable({ totalGB: '0', usedGB: '0', usedPercent: 0 });
|
const diskSpaceStore = writable({ totalGB: '0', usedGB: '0', usedPercent: 0 });
|
||||||
@@ -88,11 +87,14 @@ const unsubscribeMusic = musicCount.subscribe((count) => {
|
|||||||
|
|
||||||
// WebSocket bağlantısı kur
|
// WebSocket bağlantısı kur
|
||||||
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
const wsProtocol = window.location.protocol === 'https:' ? 'wss:' : 'ws:';
|
||||||
|
// Server port'unu doğru almak için
|
||||||
const currentHost = window.location.host;
|
const currentHost = window.location.host;
|
||||||
|
// Eğer client farklı portta çalışıyorsa, server port'unu manuel belirt
|
||||||
const wsHost = currentHost.includes(':3000') ? currentHost.replace(':3000', ':3001') : currentHost;
|
const wsHost = currentHost.includes(':3000') ? currentHost.replace(':3000', ':3001') : currentHost;
|
||||||
const wsUrl = `${wsProtocol}//${wsHost}`;
|
const wsUrl = `${wsProtocol}//${wsHost}`;
|
||||||
console.log('🔌 Connecting to WebSocket at:', wsUrl);
|
console.log('🔌 Connecting to WebSocket at:', wsUrl);
|
||||||
|
|
||||||
|
// WebSocket bağlantısını global olarak saklayalım
|
||||||
window.diskSpaceWs = new WebSocket(wsUrl);
|
window.diskSpaceWs = new WebSocket(wsUrl);
|
||||||
|
|
||||||
window.diskSpaceWs.onmessage = (event) => {
|
window.diskSpaceWs.onmessage = (event) => {
|
||||||
@@ -120,41 +122,12 @@ const unsubscribeMusic = musicCount.subscribe((count) => {
|
|||||||
console.log('WebSocket disconnected');
|
console.log('WebSocket disconnected');
|
||||||
};
|
};
|
||||||
|
|
||||||
return () => {
|
onDestroy(() => {
|
||||||
if (window.diskSpaceWs && (window.diskSpaceWs.readyState === WebSocket.OPEN || window.diskSpaceWs.readyState === WebSocket.CONNECTING)) {
|
if (window.diskSpaceWs && (window.diskSpaceWs.readyState === WebSocket.OPEN || window.diskSpaceWs.readyState === WebSocket.CONNECTING)) {
|
||||||
window.diskSpaceWs.close();
|
window.diskSpaceWs.close();
|
||||||
}
|
}
|
||||||
};
|
|
||||||
});
|
});
|
||||||
|
|
||||||
async function uploadCookies(file) {
|
|
||||||
if (!file) return;
|
|
||||||
cookieMessage = "Yükleniyor...";
|
|
||||||
try {
|
|
||||||
const form = new FormData();
|
|
||||||
form.append("cookies", file);
|
|
||||||
const res = await fetch(`${API}/api/cookies/upload`, {
|
|
||||||
method: "POST",
|
|
||||||
headers: authHeaders(),
|
|
||||||
body: form
|
|
||||||
});
|
});
|
||||||
if (!res.ok) {
|
|
||||||
const data = await res.json().catch(() => ({}));
|
|
||||||
throw new Error(data?.error || `HTTP ${res.status}`);
|
|
||||||
}
|
|
||||||
cookieMessage = "Cookie yüklendi.";
|
|
||||||
} catch (err) {
|
|
||||||
console.error("🍪 Cookie yükleme hatası:", err);
|
|
||||||
cookieMessage = "Yükleme başarısız.";
|
|
||||||
} finally {
|
|
||||||
setTimeout(() => (cookieMessage = ""), 2500);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function triggerCookieUpload() {
|
|
||||||
const input = document.getElementById("cookie-file-input");
|
|
||||||
if (input) input.click();
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="sidebar" class:open={menuOpen}>
|
<div class="sidebar" class:open={menuOpen}>
|
||||||
@@ -287,53 +260,4 @@ const unsubscribeMusic = musicCount.subscribe((count) => {
|
|||||||
</style>
|
</style>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="cookie-upload">
|
|
||||||
<input
|
|
||||||
id="cookie-file-input"
|
|
||||||
type="file"
|
|
||||||
accept=".txt"
|
|
||||||
style="display: none"
|
|
||||||
on:change={(e) => uploadCookies(e.target.files?.[0])}
|
|
||||||
/>
|
|
||||||
<button class="cookie-btn" type="button" on:click={triggerCookieUpload}>
|
|
||||||
<i class="fa-solid fa-cookie-bite"></i>
|
|
||||||
Cookie Yükle
|
|
||||||
</button>
|
|
||||||
{#if cookieMessage}
|
|
||||||
<div class="cookie-msg">{cookieMessage}</div>
|
|
||||||
{/if}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.cookie-upload {
|
|
||||||
margin: 12px 10px 0 10px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 6px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cookie-btn {
|
|
||||||
width: 100%;
|
|
||||||
border: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
padding: 8px 10px;
|
|
||||||
background: #2c3e50;
|
|
||||||
color: #fff;
|
|
||||||
cursor: pointer;
|
|
||||||
display: inline-flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
gap: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cookie-btn:hover {
|
|
||||||
background: #243544;
|
|
||||||
}
|
|
||||||
|
|
||||||
.cookie-msg {
|
|
||||||
font-size: 12px;
|
|
||||||
color: #e0e0e0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -73,7 +73,6 @@ const INFO_FILENAME = "info.json";
|
|||||||
const YT_ID_REGEX = /^[A-Za-z0-9_-]{11}$/;
|
const YT_ID_REGEX = /^[A-Za-z0-9_-]{11}$/;
|
||||||
const YT_DLP_BIN = process.env.YT_DLP_BIN || null;
|
const YT_DLP_BIN = process.env.YT_DLP_BIN || null;
|
||||||
let resolvedYtDlpBinary = null;
|
let resolvedYtDlpBinary = null;
|
||||||
const COOKIES_FILE = path.join(__dirname, "cookies.txt");
|
|
||||||
const TMDB_API_KEY = process.env.TMDB_API_KEY;
|
const TMDB_API_KEY = process.env.TMDB_API_KEY;
|
||||||
const TMDB_BASE_URL = "https://api.themoviedb.org/3";
|
const TMDB_BASE_URL = "https://api.themoviedb.org/3";
|
||||||
const TMDB_IMG_BASE =
|
const TMDB_IMG_BASE =
|
||||||
@@ -620,9 +619,6 @@ function launchYoutubeJob(job) {
|
|||||||
"--write-info-json",
|
"--write-info-json",
|
||||||
job.url
|
job.url
|
||||||
];
|
];
|
||||||
if (fs.existsSync(COOKIES_FILE)) {
|
|
||||||
args.splice(-1, 0, "--cookies", COOKIES_FILE);
|
|
||||||
}
|
|
||||||
const child = spawn(binary, args, {
|
const child = spawn(binary, args, {
|
||||||
cwd: job.savePath,
|
cwd: job.savePath,
|
||||||
env: process.env
|
env: process.env
|
||||||
@@ -5711,32 +5707,6 @@ app.post("/api/youtube/download", requireAuth, async (req, res) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// --- Cookie yükleme (YouTube için) ---
|
|
||||||
app.post(
|
|
||||||
"/api/cookies/upload",
|
|
||||||
requireAuth,
|
|
||||||
upload.single("cookies"),
|
|
||||||
async (req, res) => {
|
|
||||||
try {
|
|
||||||
if (!req.file) {
|
|
||||||
return res.status(400).json({ error: "cookies dosyası gerekli." });
|
|
||||||
}
|
|
||||||
const target = COOKIES_FILE;
|
|
||||||
try {
|
|
||||||
fs.renameSync(req.file.path, target);
|
|
||||||
} catch (err) {
|
|
||||||
// fallback: kopyala, sonra geçici dosyayı sil
|
|
||||||
fs.copyFileSync(req.file.path, target);
|
|
||||||
fs.rmSync(req.file.path, { force: true });
|
|
||||||
}
|
|
||||||
res.json({ ok: true });
|
|
||||||
} catch (err) {
|
|
||||||
console.error("🍪 Cookie yükleme hatası:", err?.message || err);
|
|
||||||
res.status(500).json({ error: "Cookie yüklenemedi." });
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
// --- 📺 TV dizileri listesi ---
|
// --- 📺 TV dizileri listesi ---
|
||||||
app.get("/api/tvshows", requireAuth, (req, res) => {
|
app.get("/api/tvshows", requireAuth, (req, res) => {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user