Skip to content
This repository has been archived by the owner on Jan 6, 2021. It is now read-only.

Commit

Permalink
撤销 mobi 相关功能
Browse files Browse the repository at this point in the history
  • Loading branch information
zsakvo committed May 25, 2019
1 parent f374500 commit 0d06213
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 45 deletions.
24 changes: 4 additions & 20 deletions ciweimao.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ func redownlodChapters() {

func watchChan(num int) {
if channelClosed {
println("关了")
return
}
if downloadIndex == num {
Expand Down Expand Up @@ -170,7 +169,6 @@ func getChapterContent(chapterID string) (string, int) {
titleElement := "<h2 id=\"title\" class=\"titlel2std\">" + chapterTitle + "</h2>"
content = strings.Replace(content, "  ", "<p class=\"a\">  ", -1)
content = strings.Replace(content, "\n", "</p>", -1)
// chapterTitles = append(chapterTitles, chapterTitle)
book.chapters.Store(chapterID, chapterTitle)
return contentHeader + "\n" + titleElement + "\n" + content + "\n" + contentFooter, 0
}
Expand Down Expand Up @@ -201,24 +199,10 @@ func writeChapterTemp(chapterID string, num int) {
}

func genBook() {
if book.format == "epub" {
coverElement := coverHeader + "\n" + "<img src=\"cover.jpg\" alt=\"" + book.name + "\" />" + coverFooter
res, err := httpGet(book.coverURL, nil)
if err != nil {
panic(err)
}
coverBody, err := getBody(res)
check(err)
writeOut(mimetype, book.tmpPath, "mimetype")
writeOut(container, book.tmpPath+"META-INF"+pathSeparator, "container.xml")
writeOut(coverElement, book.tmpPath+"OEBPS"+pathSeparator, "cover.html")
writeOut(coverBody, book.tmpPath+"OEBPS"+pathSeparator, "cover.jpg")
writeOut(css, book.tmpPath+"OEBPS"+pathSeparator, "style.css")
writeOut(genBookToc(), book.tmpPath+"OEBPS"+pathSeparator, "book-toc.html")
writeOut(genContentOpf(), book.tmpPath+"OEBPS"+pathSeparator, "content.opf")
writeOut(genTocNcx(), book.tmpPath+"OEBPS"+pathSeparator, "toc.ncx")
compressEpub(book.tmpPath, path.out+pathSeparator+book.name+".epub")
} else {
switch book.format {
case "epub":
genEpub()
case "txt":
mergeTemp()
}
bar.Finish()
Expand Down
19 changes: 19 additions & 0 deletions epubUtil.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,25 @@ import (
"strings"
)

func genEpub() {
coverElement := coverHeader + "\n" + "<img src=\"cover.jpg\" alt=\"" + book.name + "\" />" + coverFooter
res, err := httpGet(book.coverURL, nil)
if err != nil {
panic(err)
}
coverBody, err := getBody(res)
check(err)
writeOut(mimetype, book.tmpPath, "mimetype")
writeOut(container, book.tmpPath+"META-INF"+pathSeparator, "container.xml")
writeOut(coverElement, book.tmpPath+"OEBPS"+pathSeparator, "cover.html")
writeOut(coverBody, book.tmpPath+"OEBPS"+pathSeparator, "cover.jpg")
writeOut(css, book.tmpPath+"OEBPS"+pathSeparator, "style.css")
writeOut(genBookToc(), book.tmpPath+"OEBPS"+pathSeparator, "book-toc.html")
writeOut(genContentOpf(), book.tmpPath+"OEBPS"+pathSeparator, "content.opf")
writeOut(genTocNcx(), book.tmpPath+"OEBPS"+pathSeparator, "toc.ncx")
compressEpub(book.tmpPath, path.out+pathSeparator+book.name+".epub")
}

func genContentOpf() string {
var manifestStr string
var spineStr string
Expand Down
17 changes: 0 additions & 17 deletions getConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"fmt"
"os"
"strconv"

"github.com/Unknwon/goconfig"
)
Expand Down Expand Up @@ -70,17 +69,6 @@ func getToken() string {
return tokenMap["token"]
}

func getMobi() {
mobiMap := getSection("mobi")
hintBool, err := strconv.ParseBool(mobiMap["hint"])
if err != nil {
mobi.hint = true
} else {
mobi.hint = hintBool
}
mobi.caliPath = mobiMap["calibre-path"]
}

func initSettings() {
os.Create("conf.ini")
cfg, err := goconfig.LoadConfigFile("conf.ini")
Expand All @@ -95,10 +83,6 @@ func initSettings() {
cfg.SetKeyComments("path", "tmp", "# 临时目录,必填")
cfg.SetValue("path", "out", "output")
cfg.SetKeyComments("path", "out", "# 输出目录,必填")
cfg.SetValue("mobi", "hint", "true")
cfg.SetKeyComments("mobi", "hint", "# 首次提示,只能为 true 或 false")
cfg.SetValue("mobi", "calibre-path", "")
cfg.SetKeyComments("mobi", "calibre-path", "# calibre 路径,请精确到 ebook-convert 可执行文件所在的目录")
err1 := goconfig.SaveConfigFile(cfg, "conf.ini")
check(err1)
}
Expand All @@ -117,5 +101,4 @@ func initConfig() {
getConfig()
getPathSettings()
setSeparator()
getMobi()
}
7 changes: 0 additions & 7 deletions struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,6 @@ var path pathSettings
var config *goconfig.ConfigFile
var download cdownload

var mobi cmobi

type cmobi struct {
hint bool
caliPath string
}

type ctoken struct {
readerID string
loginToken string
Expand Down
1 change: 0 additions & 1 deletion util.go

This file was deleted.

0 comments on commit 0d06213

Please sign in to comment.