mirror of
https://github.com/Belphemur/CBZOptimizer.git
synced 2025-10-14 12:38:50 +02:00
fix: make the progress more readable
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
|||||||
type Converter interface {
|
type Converter interface {
|
||||||
// Format of the converter
|
// Format of the converter
|
||||||
Format() (format constant.ConversionFormat)
|
Format() (format constant.ConversionFormat)
|
||||||
ConvertChapter(chapter *manga.Chapter, quality uint8, progress func(string)) (*manga.Chapter, error)
|
ConvertChapter(chapter *manga.Chapter, quality uint8, progress func(message string, current uint32, total uint32)) (*manga.Chapter, error)
|
||||||
PrepareConverter() error
|
PrepareConverter() error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -48,7 +48,7 @@ func (converter *Converter) PrepareConverter() error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (converter *Converter) ConvertChapter(chapter *packer2.Chapter, quality uint8, progress func(string)) (*packer2.Chapter, error) {
|
func (converter *Converter) ConvertChapter(chapter *packer2.Chapter, quality uint8, progress func(message string, current uint32, total uint32)) (*packer2.Chapter, error) {
|
||||||
err := converter.PrepareConverter()
|
err := converter.PrepareConverter()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -93,7 +93,7 @@ func (converter *Converter) ConvertChapter(chapter *packer2.Chapter, quality uin
|
|||||||
}
|
}
|
||||||
pagesMutex.Lock()
|
pagesMutex.Lock()
|
||||||
pages = append(pages, convertedPage.Page)
|
pages = append(pages, convertedPage.Page)
|
||||||
progress(fmt.Sprintf("Converted %d/%d pages to %s format", len(pages), totalPages, converter.Format()))
|
progress(fmt.Sprintf("Converted %d/%d pages to %s format", len(pages), totalPages, converter.Format()), uint32(len(pages)), totalPages)
|
||||||
pagesMutex.Unlock()
|
pagesMutex.Unlock()
|
||||||
<-guard
|
<-guard
|
||||||
}(page)
|
}(page)
|
||||||
|
@@ -24,8 +24,10 @@ func Optimize(chapterConverter converter.Converter, path string, quality uint8,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Convert the chapter
|
// Convert the chapter
|
||||||
convertedChapter, err := chapterConverter.ConvertChapter(chapter, quality, func(msg string) {
|
convertedChapter, err := chapterConverter.ConvertChapter(chapter, quality, func(msg string, current uint32, total uint32) {
|
||||||
log.Printf("[%s]%s", path, msg)
|
if current%10 == 0 || current == total {
|
||||||
|
log.Printf("[%s] Converting: %d/%d", chapter.FilePath, current, total)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("failed to convert chapter: %v", err)
|
return fmt.Errorf("failed to convert chapter: %v", err)
|
||||||
|
Reference in New Issue
Block a user