Created
December 13, 2016 15:56
-
-
Save banux/41803b8a855f7a916129b5a8bc8941e4 to your computer and use it in GitHub Desktop.
Webpub Exporter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
"os" | |
kingpin "gopkg.in/alecthomas/kingpin.v2" | |
"github.com/feedbooks/webpub-streamer/parser" | |
) | |
var ( | |
filename = kingpin.Flag("file", "file to parse").Required().Short('f').String() | |
url = kingpin.Flag("url", "URL for the manifest").Short('u').String() | |
) | |
func main() { | |
kingpin.Version("0.0.1") | |
kingpin.Parse() | |
publication := parser.Parse(*filename, *url) | |
cover := publication.GetCover() | |
fmt.Println(cover.Href) | |
nav := publication.GetNavDoc() | |
fmt.Println(nav.Href) | |
j, _ := json.Marshal(publication) | |
var identJSON bytes.Buffer | |
json.Indent(&identJSON, j, "", " ") | |
identJSON.WriteTo(os.Stdout) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment