package templates import "mal/internal/jikan" import "mal/internal/nyaa" import "fmt" // WatchPage renders the video player page templ WatchPage(anime jikan.Anime, episode int, torrents []nyaa.Torrent) { @Layout(fmt.Sprintf("Watch %s - Episode %d", anime.DisplayTitle(), episode)) {
back to { anime.DisplayTitle() }

Episode { fmt.Sprintf("%d", episode) }

select a source to start streaming

available sources

if len(torrents) == 0 {

no torrents found for this episode

try searching manually

} else {
for _, t := range torrents { if t.Magnet != "" { @TorrentSource(t) } }
}
if episode > 1 { } else { previous } if anime.Episodes == 0 || episode < anime.Episodes { } else { next }
} } // TorrentSource renders a single torrent source option templ TorrentSource(t nyaa.Torrent) {
{ truncateTitle(t.Title, 60) }
{ t.Size } { fmt.Sprintf("%d", t.Seeders) } seeds
} func truncateTitle(s string, max int) string { if len(s) <= max { return s } return s[:max-3] + "..." }