use first found link for chapter id

This commit is contained in:
milarin 2023-03-10 21:38:47 +01:00
parent eafaeb43a4
commit 8f3739a8ea

4
api.go
View File

@ -37,7 +37,7 @@ func (api *Api) GetReadingList(ctx context.Context, listIndex int) (*ReadingList
selection := doc.Find("table tbody tr") selection := doc.Find("table tbody tr")
entries := make([]ReadingListEntry, 0, selection.Length()) entries := make([]ReadingListEntry, 0, selection.Length())
selection.Each(func(i int, s *goquery.Selection) { selection.Each(func(i int, s *goquery.Selection) {
link := s.Find("td:nth-child(2) a") link := s.Find("td:nth-child(2) a:first-child")
href, ok := link.Attr("href") href, ok := link.Attr("href")
if !ok { if !ok {
return return
@ -200,7 +200,7 @@ func (api *Api) getChapterEntriesByPageIndex(ctx context.Context, novelID NovelI
entryElems.Each(func(i int, s *goquery.Selection) { entryElems.Each(func(i int, s *goquery.Selection) {
td3 := s.Find("td:nth-child(3) a.chp-release") td3 := s.Find("td:nth-child(3) a.chp-release")
chapterID := td3.Text() chapterID := strings.TrimSpace(td3.Text())
groupID := path.Base(s.Find("td:nth-child(2) a").AttrOr("href", "")) groupID := path.Base(s.Find("td:nth-child(2) a").AttrOr("href", ""))
link := "https:" + td3.AttrOr("href", "") link := "https:" + td3.AttrOr("href", "")