initial commit

This commit is contained in:
2025-06-06 16:45:59 +02:00
commit 8dccbf25b8
18 changed files with 835 additions and 0 deletions

28
torrent_sort.go Normal file
View File

@ -0,0 +1,28 @@
package main
import (
"git.tordarus.net/nyaanime/model"
"git.tordarus.net/tordarus/slices"
)
func GetTorrentsWithMaxPrioByAnimeEp(torrents map[model.AnimeEpisode][]*model.ParsedTorrent) map[model.AnimeEpisode]*TorrentPriority {
torrentsWithPrio := map[model.AnimeEpisode]*TorrentPriority{}
for animeEp, torrentList := range torrents {
torrentPrioList := slices.Map(torrentList, NewTorrentPriority)
var maxPrio *TorrentPriority
for _, torrentPrio := range torrentPrioList {
if maxPrio == nil || torrentPrio.Priority > maxPrio.Priority {
maxPrio = torrentPrio
}
}
if maxPrio != nil {
torrentsWithPrio[animeEp] = maxPrio
}
}
return torrentsWithPrio
}