Add url to file info struct
parent
b05bfd0b8b
commit
d96fffabf8
13
search.go
13
search.go
|
|
@ -16,6 +16,7 @@ type XdccFileInfo struct {
|
||||||
Channel string
|
Channel string
|
||||||
BotName string
|
BotName string
|
||||||
Name string
|
Name string
|
||||||
|
Url string
|
||||||
Slot int
|
Slot int
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -110,15 +111,23 @@ func (p *XdccEuProvider) Search(fileName string) ([]XdccFileInfo, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fileInfos := make([]XdccFileInfo, 0)
|
fileInfos := make([]XdccFileInfo, 0)
|
||||||
doc.Find("tr").Each(func(i int, s *goquery.Selection) {
|
doc.Find("tr").Each(func(_ int, s *goquery.Selection) {
|
||||||
fields := make([]string, 0)
|
fields := make([]string, 0)
|
||||||
|
|
||||||
s.Find("td").Each(func(j int, si *goquery.Selection) {
|
var url string
|
||||||
|
s.Children().Each(func(i int, si *goquery.Selection) {
|
||||||
|
if i == 1 {
|
||||||
|
value, exists := si.Find("a").First().Attr("href")
|
||||||
|
if exists {
|
||||||
|
url = value
|
||||||
|
}
|
||||||
|
}
|
||||||
fields = append(fields, strings.TrimSpace(si.Text()))
|
fields = append(fields, strings.TrimSpace(si.Text()))
|
||||||
})
|
})
|
||||||
|
|
||||||
info, err := p.parseFields(fields)
|
info, err := p.parseFields(fields)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
info.Url = url + "/" + info.BotName + "/" + strconv.Itoa(info.Slot)
|
||||||
fileInfos = append(fileInfos, *info)
|
fileInfos = append(fileInfos, *info)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue