simplify: remove complex episode fetching, use simple sequential pagination

This commit is contained in:
2026-05-03 14:22:58 +02:00
committed by Mikkel Elvers
parent 4ba4e51d95
commit f2afa6a4e5
3 changed files with 80 additions and 391 deletions

View File

@@ -4,54 +4,30 @@
{{$episodes := .Episodes}}
{{$currentEpID := .CurrentEpID}}
<div class="flex flex-col gap-8 pb-12">
<div id="video-player-container">
{{template "video_player" dict "WatchData" .WatchData "TotalEpisodes" $anime.Episodes}}
<div class="flex flex-col gap-8 pb-12 lg:flex-row lg:gap-6">
<div class="flex-1 min-w-0">
<div id="video-player-container">
{{template "video_player" dict "WatchData" .WatchData "TotalEpisodes" $anime.Episodes}}
</div>
</div>
{{if eq (len $episodes) 0}}
<div class="flex flex-col items-center justify-center gap-2 py-24 text-neutral-400">
<svg class="h-12 w-12 opacity-30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>
<p class="text-lg">No episodes found for this anime.</p>
</div>
{{else}}
{{$totalEps := $anime.Episodes}}
{{$fallbackSub := .WatchData.FallbackEpisodes.sub}}
{{if gt $fallbackSub $totalEps}}
{{$totalEps = $fallbackSub}}
<div class="w-full lg:w-80 xl:w-96 flex-shrink-0">
{{if eq (len $episodes) 0}}
<div class="flex flex-col items-center justify-center gap-2 py-12 text-neutral-400">
<svg class="h-10 w-10 opacity-30" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5"><path stroke-linecap="round" stroke-linejoin="round" d="M15 10l4.553-2.276A1 1 0 0121 8.618v6.764a1 1 0 01-1.447.894L15 14M5 18h8a2 2 0 002-2V8a2 2 0 00-2-2H5a2 2 0 00-2 2v8a2 2 0 002 2z" /></svg>
<p class="text-sm">No episodes found</p>
</div>
{{else}}
<div class="flex flex-col gap-1 overflow-y-auto max-h-[70vh] lg:max-h-[calc(100vh-8rem)] pr-2 scrollbar-hide" data-episode-list>
{{range $episodes}}
{{$isCurrent := eq (printf "%v" .MalID) $currentEpID}}
<a href="/anime/{{$anime.MalID}}/watch?ep={{.MalID}}" class="flex items-center gap-3 px-3 py-2 transition-colors hover:bg-white/5 text-left {{if $isCurrent}}bg-accent/20{{end}}" data-episode-id="{{.MalID}}">
<span class="w-10 flex-shrink-0 text-xs font-medium text-neutral-500 tabular-nums">EP{{.MalID}}</span>
<span class="truncate text-sm text-neutral-300" data-episode-title>{{.Title}}</span>
</a>
{{end}}
</div>
{{end}}
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5" data-episode-list>
{{range $episodes}}
{{$isCurrent := eq (printf "%v" .MalID) $currentEpID}}
<a href="/anime/{{$anime.MalID}}/watch?ep={{.MalID}}" class="group flex flex-col overflow-hidden bg-white/5 transition-colors hover:bg-white/10 {{if $isCurrent}}ring-accent ring-2{{end}}" data-episode-id="{{.MalID}}">
<div class="relative aspect-video w-full overflow-hidden bg-black/50">
{{if .Images}}
{{if .Images.Jpg.ImageURL}}
<img src="{{.Images.Jpg.ImageURL}}" alt="{{.Title}}" class="h-full w-full object-cover transition-transform group-hover:scale-105" loading="lazy" />
{{else}}
<div class="flex h-full w-full items-center justify-center text-neutral-600">
<svg class="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/></svg>
</div>
{{end}}
{{else}}
<div class="flex h-full w-full items-center justify-center text-neutral-600">
<svg class="h-8 w-8" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path stroke-linecap="round" stroke-linejoin="round" d="M4 16l4.586-4.586a2 2 0 012.828 0L16 16m-2-2l1.586-1.586a2 2 0 012.828 0L20 14m-6-6h.01M6 20h12a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v12a2 2 0 002 2z"/></svg>
</div>
{{end}}
<div class="absolute inset-0 flex items-center justify-center bg-black/40 opacity-0 transition-opacity group-hover:opacity-100">
<div class="bg-accent flex h-12 w-12 items-center justify-center rounded-full text-white shadow-lg">
<svg class="ml-1 h-6 w-6" viewBox="0 0 24 24" fill="currentColor"><path d="M8 5v14l11-7z" /></svg>
</div>
</div>
</div>
<div class="flex flex-col gap-1 p-3">
<span class="text-accent text-xs font-semibold">Episode {{.MalID}}</span>
<span class="line-clamp-2 text-sm font-medium text-neutral-200" data-episode-title>{{.Title}}</span>
</div>
</a>
{{end}}
</div>
{{end}}
</div>
</div>
{{end}}
{{end}}