2017-06-16 15:07:30 +08:00
|
|
|
package metainfo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/anacrolix/torrent/bencode"
|
|
|
|
)
|
|
|
|
|
|
|
|
type UrlList []string
|
|
|
|
|
2021-11-08 11:47:01 +08:00
|
|
|
var _ bencode.Unmarshaler = (*UrlList)(nil)
|
2017-06-16 15:07:30 +08:00
|
|
|
|
|
|
|
func (me *UrlList) UnmarshalBencode(b []byte) error {
|
|
|
|
if len(b) == 0 {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
if b[0] == 'l' {
|
|
|
|
var l []string
|
|
|
|
err := bencode.Unmarshal(b, &l)
|
|
|
|
*me = l
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
var s string
|
|
|
|
err := bencode.Unmarshal(b, &s)
|
|
|
|
*me = []string{s}
|
|
|
|
return err
|
|
|
|
}
|