Documentation
¶
Overview ¶
Package url2epub fetches http(s) URL and extracts ePub files from them.
Index ¶
- Constants
- func DrainAndClose(r io.ReadCloser) error
- func Epub(args EpubArgs) (id string, err error)
- type EpubArgs
- type GetHTMLArgs
- type Node
- func (n Node) AsNode() html.Node
- func (n Node) Children() iter.Seq[*Node]
- func (n *Node) FindFirstAtomNode(a atom.Atom) *Node
- func (n *Node) GetAMPurl() string
- func (n *Node) GetAuthor() (author string)
- func (n *Node) GetLang() string
- func (n *Node) GetTitle() (title string)
- func (n *Node) IsAMP() bool
- func (n *Node) Readable(ctx context.Context, args ReadableArgs) (*html.Node, map[string]io.Reader, error)
- type ReadableArgs
Constants ¶
const EpubMimeType = `application/epub+zip`
EpubMimeType is the mime type for epub.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EpubArgs ¶
type EpubArgs struct {
// The destination to write the epub content to.
Dest io.Writer
// The title of the epub.
Title string
// The author of the epub, if any.
Author string
// The node pointing to the html tag.
Node *html.Node
// If non-empty, override the language detected from Node.
OverrideLang string
// Images map:
// key: image local filename
// value: image content
Images map[string]io.Reader
}
EpubArgs defines the args used by Epub function.
type GetHTMLArgs ¶
type GetHTMLArgs struct {
// The HTTP GET URL, required.
URL string
// The User-Agent header to use, optional.
UserAgent string
}
GetHTMLArgs define the arguments used by GetHTML function.
type Node ¶
Node is typedef'd html.Node with helper functions attached.
func GetHTML ¶
GetHTML does HTTP get requests on HTML content.
It's different from standard http.Get in the following ways:
- If there are redirects happening during the request, returned URL will be the URL of the last (final) request.
- Instead of returning *http.Response, it returns parsed *html.Node, with Type being ElementNode and DataAtom being Html (instead of root node, which is usually DoctypeNode).
- The client used by Get does not have timeout set. It's expected that a deadline is set in the ctx passed in.
func (*Node) FindFirstAtomNode ¶
FindFirstAtomNode returns n itself or the first node in its descendants, with Type == html.ElementNode and DataAtom == a, using depth first search.
If none of n's descendants matches, nil will be returned.
func (*Node) GetTitle ¶
GetTitle returns the title of the document, if any.
Note that if og:title exists in the meta header, it's preferred over title.
type ReadableArgs ¶
type ReadableArgs struct {
// Base URL of the document, used in case the image URLs are relative.
BaseURL *url.URL
// User-Agent to be used to download images.
UserAgent string
// Directory prefix for downloaded images.
ImagesDir string
// If Grayscale is set to true,
// all images will be grayscaled and encoded as jpegs.
Grayscale bool
// Downscale images to fit in NxN,
// only used when Grayscale is set to true.
FitImage int
// Set the minimal number of readable nodes under the first article node to
// use that instead of body.
//
// If the first article node has too few nodes under it, we'll skip using it
// and use the body node instead.
//
// <=0 to disable this check (always use first article node if found).
MinArticleNodes int
// Extra nodes to be inserted under <head />. For example a style node to
// apply global font size.
ExtraHeadNodes []*html.Node
}
ReadableArgs defines the args used by Readable function.
Directories
¶
| Path | Synopsis |
|---|---|
|
appengine
module
|
|
|
cloudrun
module
|
|
|
cmd
|
|
|
epubwriter
module
|
|
|
debug
module
|
|
|
Package grayscale provides function to grayscale an image.
|
Package grayscale provides function to grayscale an image. |
|
Package rmapi implements reMarkable api, as described in https://github.com/splitbrain/ReMarkableAPI/wiki.
|
Package rmapi implements reMarkable api, as described in https://github.com/splitbrain/ReMarkableAPI/wiki. |
|
debug
module
|
|
|
Package tgbot provides some simple wrapping around telegram bot api.
|
Package tgbot provides some simple wrapping around telegram bot api. |
|
Package ziputil provides some utility functions for zip archive handling.
|
Package ziputil provides some utility functions for zip archive handling. |