2017-02-15 17:05:28 +08:00
|
|
|
package metainfo
|
|
|
|
|
|
|
|
type AnnounceList [][]string
|
|
|
|
|
2020-04-15 11:07:17 +08:00
|
|
|
func (al AnnounceList) Clone() (ret AnnounceList) {
|
|
|
|
for _, tier := range al {
|
|
|
|
ret = append(ret, append([]string(nil), tier...))
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2017-02-15 17:05:28 +08:00
|
|
|
// Whether the AnnounceList should be preferred over a single URL announce.
|
|
|
|
func (al AnnounceList) OverridesAnnounce(announce string) bool {
|
|
|
|
for _, tier := range al {
|
|
|
|
for _, url := range tier {
|
|
|
|
if url != "" || announce == "" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2021-03-25 06:51:49 +08:00
|
|
|
func (al AnnounceList) DistinctValues() (ret []string) {
|
|
|
|
seen := make(map[string]struct{})
|
2017-02-15 17:05:28 +08:00
|
|
|
for _, tier := range al {
|
|
|
|
for _, v := range tier {
|
2021-03-25 06:51:49 +08:00
|
|
|
if _, ok := seen[v]; !ok {
|
|
|
|
seen[v] = struct{}{}
|
|
|
|
ret = append(ret, v)
|
2017-02-15 17:05:28 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return
|
|
|
|
}
|