initial commit
This commit is contained in:
28
torrent_sort.go
Normal file
28
torrent_sort.go
Normal 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
|
||||
}
|
Reference in New Issue
Block a user