mirror of
https://github.com/NohamR/papeer.git
synced 2026-05-25 20:00:47 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
73f254f6e5 | ||
|
|
8fd0a12620 |
@@ -141,7 +141,7 @@ go install github.com/lapwat/papeer@latest
|
|||||||
```sh
|
```sh
|
||||||
# use platform=darwin for MacOS
|
# use platform=darwin for MacOS
|
||||||
platform=linux
|
platform=linux
|
||||||
release=0.6.1
|
release=0.6.3
|
||||||
|
|
||||||
# download and extract
|
# download and extract
|
||||||
curl -L https://github.com/lapwat/papeer/releases/download/v$release/papeer-v$release-$platform-amd64.tar.gz > papeer.tar.gz
|
curl -L https://github.com/lapwat/papeer/releases/download/v$release/papeer-v$release-$platform-amd64.tar.gz > papeer.tar.gz
|
||||||
@@ -154,7 +154,7 @@ sudo mv papeer /usr/local/bin
|
|||||||
|
|
||||||
### Windows
|
### Windows
|
||||||
|
|
||||||
Download [latest release](https://github.com/lapwat/papeer/releases/download/v0.6.0/papeer-v0.6.0-windows-amd64.zip).
|
Download [latest release](https://github.com/lapwat/papeer/releases/download/v0.6.3/papeer-v0.6.3-windows-amd64.zip).
|
||||||
|
|
||||||
## MOBI support
|
## MOBI support
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package book
|
package book
|
||||||
|
|
||||||
type link struct {
|
type link struct {
|
||||||
Href string `json:"href"`
|
Href string `json:"url"`
|
||||||
Text string `json:"name"`
|
Text string `json:"name"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -365,7 +365,12 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
|
|||||||
// RSS feed
|
// RSS feed
|
||||||
|
|
||||||
for _, item := range feed.Items {
|
for _, item := range feed.Items {
|
||||||
links = append(links, NewLink(item.Link, item.Title))
|
u, err := url.Parse(item.Link)
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
links = append(links, NewLink(u.String(), item.Title))
|
||||||
}
|
}
|
||||||
|
|
||||||
pathMax = "RSS"
|
pathMax = "RSS"
|
||||||
@@ -385,11 +390,16 @@ func GetLinks(url *urllib.URL, selector string, limit, offset int, reverse, incl
|
|||||||
// visit and count link classes
|
// visit and count link classes
|
||||||
c := colly.NewCollector()
|
c := colly.NewCollector()
|
||||||
c.OnHTML(selector, func(e *colly.HTMLElement) {
|
c.OnHTML(selector, func(e *colly.HTMLElement) {
|
||||||
href := e.Attr("href")
|
|
||||||
text := strings.TrimSpace(e.Text)
|
text := strings.TrimSpace(e.Text)
|
||||||
path := GetPath(e.DOM)
|
path := GetPath(e.DOM)
|
||||||
key := path
|
key := path
|
||||||
|
|
||||||
|
u, err := url.Parse(e.Attr("href"))
|
||||||
|
if err != nil {
|
||||||
|
log.Fatal(err)
|
||||||
|
}
|
||||||
|
href := u.String()
|
||||||
|
|
||||||
if selectorSet {
|
if selectorSet {
|
||||||
|
|
||||||
// if selector is set, we use the selector specified by the user
|
// if selector is set, we use the selector specified by the user
|
||||||
|
|||||||
24
cmd/list.go
24
cmd/list.go
@@ -88,6 +88,14 @@ var listCmd = &cobra.Command{
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// format selector path
|
||||||
|
pathArray := strings.Split(path, "<")
|
||||||
|
// reverse path
|
||||||
|
for i, j := 0, len(pathArray)-1; i < j; i, j = i+1, j-1 {
|
||||||
|
pathArray[i], pathArray[j] = pathArray[j], pathArray[i]
|
||||||
|
}
|
||||||
|
pathFormatted := strings.Join(pathArray, ">")
|
||||||
|
|
||||||
switch listOpts.output {
|
switch listOpts.output {
|
||||||
|
|
||||||
// render as table
|
// render as table
|
||||||
@@ -99,15 +107,6 @@ var listCmd = &cobra.Command{
|
|||||||
t.Style().Options.SeparateHeader = false
|
t.Style().Options.SeparateHeader = false
|
||||||
|
|
||||||
t.SetTitle(home.Name())
|
t.SetTitle(home.Name())
|
||||||
|
|
||||||
// format selector path
|
|
||||||
pathArray := strings.Split(path, "<")
|
|
||||||
// reverse path
|
|
||||||
for i, j := 0, len(pathArray)-1; i < j; i, j = i+1, j-1 {
|
|
||||||
pathArray[i], pathArray[j] = pathArray[j], pathArray[i]
|
|
||||||
}
|
|
||||||
pathFormatted := strings.Join(pathArray, ">")
|
|
||||||
|
|
||||||
t.AppendHeader(table.Row{"#", "Name", fmt.Sprintf("Url [%s]", pathFormatted)})
|
t.AppendHeader(table.Row{"#", "Name", fmt.Sprintf("Url [%s]", pathFormatted)})
|
||||||
|
|
||||||
for index, link := range links {
|
for index, link := range links {
|
||||||
@@ -124,6 +123,13 @@ var listCmd = &cobra.Command{
|
|||||||
// render as json
|
// render as json
|
||||||
case "json":
|
case "json":
|
||||||
book := make(map[string]interface{})
|
book := make(map[string]interface{})
|
||||||
|
book["url"] = base.String()
|
||||||
|
if pathFormatted == "RSS" {
|
||||||
|
book["type"] = "RSS"
|
||||||
|
} else {
|
||||||
|
book["type"] = "HTML"
|
||||||
|
}
|
||||||
|
book["path"] = pathFormatted
|
||||||
book["name"] = home.Name()
|
book["name"] = home.Name()
|
||||||
book["chapters"] = links
|
book["chapters"] = links
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ var versionCmd = &cobra.Command{
|
|||||||
Use: "version",
|
Use: "version",
|
||||||
Short: "Print the version number of papeer",
|
Short: "Print the version number of papeer",
|
||||||
Run: func(cmd *cobra.Command, args []string) {
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
fmt.Println("papeer v0.6.1")
|
fmt.Println("papeer v0.6.3")
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user