arama özelliği eklendi

This commit is contained in:
2025-11-01 15:39:01 +03:00
parent ebe00fb6f7
commit 1eef5d232f
6 changed files with 225 additions and 30 deletions

View File

@@ -3,6 +3,10 @@
import { API, apiFetch } from "../utils/api.js";
import { cleanFileName } from "../utils/filename.js";
import { tvShowCount } from "../stores/tvStore.js";
import {
activeSearchTerm,
setSearchScope
} from "../stores/searchStore.js";
let shows = [];
let loading = true;
@@ -28,6 +32,9 @@ let seasonPlaylist = [];
let seasonPlaylistIndex = -1;
let canPlayPrev = false;
let canPlayNext = false;
let searchTerm = "";
let hasSearch = false;
let filteredShows = [];
function runtimeToText(runtime) {
if (!runtime || Number.isNaN(runtime)) return null;
@@ -190,6 +197,25 @@ let canPlayNext = false;
}
}
$: searchTerm = $activeSearchTerm;
$: hasSearch = searchTerm.trim().length > 0;
$: filteredShows = (() => {
const query = searchTerm.trim().toLowerCase();
if (!query) return shows;
return shows.filter((show) => {
const fields = [
show.title,
show.originalTitle,
show.metadata?.matched_title,
show.metadata?.original_name,
show.folder
];
return fields
.filter(Boolean)
.some((value) => String(value).toLowerCase().includes(query));
});
})();
async function refreshShows() {
try {
refreshing = true;
@@ -542,6 +568,7 @@ async function openVideoAtIndex(index) {
}
onMount(() => {
setSearchScope("tv");
loadShows();
const handleKey = (event) => {
if (!showPlayerModal) return;
@@ -588,9 +615,11 @@ async function openVideoAtIndex(index) {
<div class="state-placeholder error">{error}</div>
{:else if shows.length === 0}
<div class="state-placeholder">No TV metadata found yet.</div>
{:else if hasSearch && filteredShows.length === 0}
<div class="state-placeholder">Aramanıza uyan dizi bulunamadı.</div>
{:else}
<div class="tv-grid">
{#each shows as show}
{#each filteredShows as show}
<div class="tv-card" on:click={() => openShow(show)}>
{#if show.poster}
<div class="poster-wrapper">