2018-01-05 17:43:36 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/xml"
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Make up some data structures into which we can put our feed.
|
|
|
|
|
|
|
|
// Bookmark defines the fundamental structure of the items to be archived.
|
|
|
|
type Bookmark struct {
|
|
|
|
// Required
|
|
|
|
Title string `xml:"title"`
|
2023-01-03 02:13:08 +00:00
|
|
|
URL string `xml:"guid"`
|
2018-01-05 17:43:36 +00:00
|
|
|
// Optional
|
2023-01-03 02:13:08 +00:00
|
|
|
Domain string
|
|
|
|
Author string
|
|
|
|
SaveDate string
|
|
|
|
PubDate string
|
|
|
|
Comments string `xml:"comments"`
|
|
|
|
MercuryContent string
|
|
|
|
PDFpath string
|
|
|
|
Tags string
|
2018-01-05 17:43:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Feed defines the structure of the RSS feed exported from Pocket
|
|
|
|
type Feed struct {
|
|
|
|
XMLName xml.Name `xml:"rss"`
|
|
|
|
Version string `xml:"version,attr"`
|
|
|
|
// Required
|
|
|
|
Title string `xml:"channel>title"`
|
|
|
|
Link string `xml:"channel>link"`
|
|
|
|
Description string `xml:"channel>description"`
|
|
|
|
// Optional
|
|
|
|
PubDate string `xml:"channel>pubDate"`
|
|
|
|
BookmarkList []Bookmark `xml:"channel>item"`
|
|
|
|
}
|
|
|
|
|
2023-01-03 02:13:08 +00:00
|
|
|
// Mercury is a data structure to manage hte output of the mercury parsing
|
|
|
|
type Mercury struct {
|
|
|
|
Title string
|
|
|
|
Author string
|
|
|
|
DatePublished string
|
|
|
|
Dek string
|
|
|
|
LeadImageURL string
|
|
|
|
Content string
|
|
|
|
NextPageURL string
|
|
|
|
URL string
|
|
|
|
Domain string
|
|
|
|
Excerpt string
|
|
|
|
WordCount int
|
|
|
|
Direction string
|
|
|
|
TotalPages int
|
|
|
|
RenderedPages int
|
|
|
|
}
|
|
|
|
|
2018-01-05 17:43:36 +00:00
|
|
|
func main() {
|
|
|
|
fmt.Println("Launching Pocket Archive...")
|
|
|
|
|
|
|
|
db, err := getDB("./bookmarks.db")
|
|
|
|
if err != nil {
|
|
|
|
fmt.Println("Could not open or create db")
|
|
|
|
panic(err)
|
|
|
|
}
|
|
|
|
defer db.Close()
|
|
|
|
|
2023-01-03 02:13:08 +00:00
|
|
|
//pullPocket(db)
|
|
|
|
|
|
|
|
runIngest(db)
|
2018-01-05 17:43:36 +00:00
|
|
|
|
|
|
|
fmt.Println("Pocket Archive exiting.")
|
|
|
|
|
|
|
|
}
|