mirror of
https://github.com/NohamR/papeer.git
synced 2026-05-25 12:27:20 +00:00
json output for list command
This commit is contained in:
12
book/link.go
12
book/link.go
@@ -1,18 +1,10 @@
|
||||
package book
|
||||
|
||||
type link struct {
|
||||
href string
|
||||
text string
|
||||
Href string `json:"href"`
|
||||
Text string `json:"name"`
|
||||
}
|
||||
|
||||
func NewLink(href, text string) link {
|
||||
return link{href, text}
|
||||
}
|
||||
|
||||
func (c link) Href() string {
|
||||
return c.href
|
||||
}
|
||||
|
||||
func (c link) Text() string {
|
||||
return c.text
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ func NewProgress(links []link, parent string, depth int) progress {
|
||||
if len(links) <= 50 {
|
||||
for index, link := range links {
|
||||
bar := uiprogress.AddBar(1)
|
||||
barText := fmt.Sprintf("%v#%v %v", indent, index+1, link.Text())
|
||||
barText := fmt.Sprintf("%v#%v %v", indent, index+1, link.Text)
|
||||
bar.AppendFunc(func(b *uiprogress.Bar) string {
|
||||
return barText
|
||||
})
|
||||
|
||||
@@ -156,12 +156,12 @@ func NewChapterFromURL(url, linkName string, configs []*ScrapeConfig, index int,
|
||||
// synchronous mode
|
||||
for index, link := range links {
|
||||
// and then use it to parse relative URLs
|
||||
u, err := base.Parse(link.href)
|
||||
u, err := base.Parse(link.Href)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
sc := NewChapterFromURL(u.String(), link.text, configs[1:], index, p.UpdateName)
|
||||
sc := NewChapterFromURL(u.String(), link.Text, configs[1:], index, p.UpdateName)
|
||||
subchapters[index] = sc
|
||||
if config.Quiet == false {
|
||||
p.Increment(index)
|
||||
@@ -189,12 +189,12 @@ func NewChapterFromURL(url, linkName string, configs []*ScrapeConfig, index int,
|
||||
defer wg.Done()
|
||||
|
||||
// and then use it to parse relative URLs
|
||||
u, err := base.Parse(l.href)
|
||||
u, err := base.Parse(l.Href)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
sc := NewChapterFromURL(u.String(), l.text, configs[1:], index, p.UpdateName)
|
||||
sc := NewChapterFromURL(u.String(), l.Text, configs[1:], index, p.UpdateName)
|
||||
subchapters[index] = sc
|
||||
|
||||
if config.Quiet == false {
|
||||
@@ -279,12 +279,12 @@ func tableOfContent(url string, config *ScrapeConfig, subConfig *ScrapeConfig, q
|
||||
|
||||
for index, l := range links {
|
||||
// and then use it to parse relative URLs
|
||||
u, err := base.Parse(l.href)
|
||||
u, err := base.Parse(l.Href)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
chapters[index] = NewChapterFromURL(u.String(), l.text, []*ScrapeConfig{subConfig}, 0, func(index int, name string) {})
|
||||
chapters[index] = NewChapterFromURL(u.String(), l.Text, []*ScrapeConfig{subConfig}, 0, func(index int, name string) {})
|
||||
|
||||
if quiet == false {
|
||||
p.Increment(index)
|
||||
@@ -317,12 +317,12 @@ func tableOfContent(url string, config *ScrapeConfig, subConfig *ScrapeConfig, q
|
||||
defer wg.Done()
|
||||
|
||||
// and then use it to parse relative URLs
|
||||
u, err := base.Parse(l.href)
|
||||
u, err := base.Parse(l.Href)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
chapters[index] = NewChapterFromURL(u.String(), l.text, []*ScrapeConfig{subConfig}, 0, func(index int, name string) {})
|
||||
chapters[index] = NewChapterFromURL(u.String(), l.Text, []*ScrapeConfig{subConfig}, 0, func(index int, name string) {})
|
||||
|
||||
if quiet == false {
|
||||
p.Increment(index)
|
||||
@@ -361,8 +361,6 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
|
||||
parser := gofeed.NewParser()
|
||||
feed, err := parser.ParseURL(url.String())
|
||||
|
||||
fmt.Println(feed, url.String(), err)
|
||||
|
||||
if err == nil {
|
||||
// RSS feed
|
||||
|
||||
|
||||
Reference in New Issue
Block a user