Support Roman Numeral Parsing, added Volume Name to cbz filename
This commit is contained in:
parent
4c201b8094
commit
b75edb2136
1 changed files with 34 additions and 4 deletions
38
main.go
38
main.go
|
@ -367,7 +367,7 @@ func DownloadAndProcessEpub(jnovel jnc.Api, serie jnc.SerieAugmented, volume jnc
|
|||
for ch := chapterList.Front(); ch != nil; ch = ch.Next() {
|
||||
chap := ch.Value.(Chapter)
|
||||
|
||||
zipPath := basePath + "Chapter " + chap.chDisplay + ".cbz"
|
||||
zipPath := basePath + volume.Info.Title + " Chapter " + chap.chDisplay + ".cbz"
|
||||
|
||||
if _, err = os.Stat(zipPath); err != nil {
|
||||
err := os.Remove(zipPath)
|
||||
|
@ -440,6 +440,7 @@ func DownloadAndProcessEpub(jnovel jnc.Api, serie jnc.SerieAugmented, volume jnc
|
|||
newZip.Close()
|
||||
newZipFile.Close()
|
||||
}
|
||||
|
||||
epub.Close()
|
||||
os.Remove(file)
|
||||
}
|
||||
|
@ -828,11 +829,15 @@ func GenerateMangaChapterList(navigation FileWrapper) *list.List {
|
|||
r, _ := regexp.Compile(regex)
|
||||
num := r.FindStringSubmatch(label)[1]
|
||||
parse, _ := strconv.ParseInt(num, 10, 8)
|
||||
if parse == 0 {
|
||||
fmt.Printf("Unlikely Chapter Number Detected (0): %s/n", label)
|
||||
if int8(parse) == 0 {
|
||||
fmt.Printf("Unlikely Chapter Number Detected (0): %s/n", num)
|
||||
fmt.Println("Attempting Roman Numerals")
|
||||
lastMainChapter = int8(romanToInt(num))
|
||||
} else {
|
||||
lastMainChapter = int8(parse)
|
||||
}
|
||||
lastMainChapter = int8(parse)
|
||||
subChapter = int8(0)
|
||||
|
||||
} else {
|
||||
if lastMainChapter == -1 {
|
||||
subChapter -= 1
|
||||
|
@ -856,3 +861,28 @@ func GenerateMangaChapterList(navigation FileWrapper) *list.List {
|
|||
|
||||
return FinalizeChapters(chapters, pageList)
|
||||
}
|
||||
|
||||
func romanToInt(s string) int {
|
||||
|
||||
know := map[string]int{
|
||||
"I": 1,
|
||||
"V": 5,
|
||||
"X": 10,
|
||||
"L": 50,
|
||||
"C": 100,
|
||||
"D": 500,
|
||||
"M": 1000,
|
||||
}
|
||||
lengthOfString := len(s)
|
||||
lastElement := s[len(s)-1 : lengthOfString]
|
||||
var result int
|
||||
result = know[lastElement]
|
||||
for i := len(s) - 1; i > 0; i-- {
|
||||
if know[s[i:i+1]] <= know[s[i-1:i]] {
|
||||
result += know[s[i-1:i]]
|
||||
} else {
|
||||
result -= know[s[i-1:i]]
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue