mirror of
https://codeberg.org/scip/epuppy.git
synced 2025-12-16 20:11:00 +01:00
add cover image support (#7)
This commit is contained in:
@@ -11,12 +11,15 @@ import (
|
||||
|
||||
// Book epub book
|
||||
type Book struct {
|
||||
Ncx Ncx `json:"ncx"`
|
||||
Opf Opf `json:"opf"`
|
||||
Container Container `json:"-"`
|
||||
Mimetype string `json:"-"`
|
||||
Content []Content
|
||||
fd *zip.ReadCloser
|
||||
Ncx Ncx `json:"ncx"`
|
||||
Opf Opf `json:"opf"`
|
||||
Container Container `json:"-"`
|
||||
Mimetype string `json:"-"`
|
||||
Content []Content
|
||||
fd *zip.ReadCloser
|
||||
CoverImage []byte
|
||||
CoverFile string
|
||||
CoverMediaType string
|
||||
}
|
||||
|
||||
// Open open resource file
|
||||
|
||||
@@ -45,8 +45,11 @@ func Open(fn string, dumpxml bool) (*Book, error) {
|
||||
if err != nil {
|
||||
return &bk, err
|
||||
}
|
||||
}
|
||||
|
||||
break
|
||||
if mf.ID == "cover-image" {
|
||||
bk.CoverFile = mf.Href
|
||||
bk.CoverMediaType = mf.MediaType
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,13 +64,18 @@ func Open(fn string, dumpxml bool) (*Book, error) {
|
||||
if err := ct.String(content); err != nil {
|
||||
return &bk, err
|
||||
}
|
||||
|
||||
bk.Content = append(bk.Content, ct)
|
||||
|
||||
if dumpxml {
|
||||
fmt.Println(string(ct.XML))
|
||||
}
|
||||
}
|
||||
|
||||
bk.Content = append(bk.Content, ct)
|
||||
|
||||
if dumpxml {
|
||||
fmt.Println(string(ct.XML))
|
||||
if strings.Contains(file, bk.CoverFile) {
|
||||
bk.CoverImage = content
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if dumpxml {
|
||||
|
||||
Reference in New Issue
Block a user