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() {
|
for ch := chapterList.Front(); ch != nil; ch = ch.Next() {
|
||||||
chap := ch.Value.(Chapter)
|
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 {
|
if _, err = os.Stat(zipPath); err != nil {
|
||||||
err := os.Remove(zipPath)
|
err := os.Remove(zipPath)
|
||||||
|
@ -440,6 +440,7 @@ func DownloadAndProcessEpub(jnovel jnc.Api, serie jnc.SerieAugmented, volume jnc
|
||||||
newZip.Close()
|
newZip.Close()
|
||||||
newZipFile.Close()
|
newZipFile.Close()
|
||||||
}
|
}
|
||||||
|
|
||||||
epub.Close()
|
epub.Close()
|
||||||
os.Remove(file)
|
os.Remove(file)
|
||||||
}
|
}
|
||||||
|
@ -828,11 +829,15 @@ func GenerateMangaChapterList(navigation FileWrapper) *list.List {
|
||||||
r, _ := regexp.Compile(regex)
|
r, _ := regexp.Compile(regex)
|
||||||
num := r.FindStringSubmatch(label)[1]
|
num := r.FindStringSubmatch(label)[1]
|
||||||
parse, _ := strconv.ParseInt(num, 10, 8)
|
parse, _ := strconv.ParseInt(num, 10, 8)
|
||||||
if parse == 0 {
|
if int8(parse) == 0 {
|
||||||
fmt.Printf("Unlikely Chapter Number Detected (0): %s/n", label)
|
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)
|
subChapter = int8(0)
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if lastMainChapter == -1 {
|
if lastMainChapter == -1 {
|
||||||
subChapter -= 1
|
subChapter -= 1
|
||||||
|
@ -856,3 +861,28 @@ func GenerateMangaChapterList(navigation FileWrapper) *list.List {
|
||||||
|
|
||||||
return FinalizeChapters(chapters, pageList)
|
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
Add a link
Reference in a new issue