mirror of
https://github.com/Belphemur/CBZOptimizer.git
synced 2025-10-14 12:38:50 +02:00
refactor: change package name
This commit is contained in:
@@ -3,12 +3,12 @@ package cbz
|
||||
import (
|
||||
"archive/zip"
|
||||
"fmt"
|
||||
"github.com/belphemur/CBZOptimizer/packer"
|
||||
"github.com/belphemur/CBZOptimizer/manga"
|
||||
"os"
|
||||
"time"
|
||||
)
|
||||
|
||||
func WriteChapterToCBZ(chapter *packer.Chapter, outputFilePath string) error {
|
||||
func WriteChapterToCBZ(chapter *manga.Chapter, outputFilePath string) error {
|
||||
// Create a new ZIP file
|
||||
zipFile, err := os.Create(outputFilePath)
|
||||
if err != nil {
|
||||
|
@@ -3,7 +3,7 @@ package cbz
|
||||
import (
|
||||
"archive/zip"
|
||||
"bytes"
|
||||
"github.com/belphemur/CBZOptimizer/packer"
|
||||
"github.com/belphemur/CBZOptimizer/manga"
|
||||
"os"
|
||||
"testing"
|
||||
"time"
|
||||
@@ -13,14 +13,14 @@ func TestWriteChapterToCBZ(t *testing.T) {
|
||||
// Define test cases
|
||||
testCases := []struct {
|
||||
name string
|
||||
chapter *packer.Chapter
|
||||
chapter *manga.Chapter
|
||||
expectedFiles []string
|
||||
}{
|
||||
//test case where there is only one page and ComicInfo and the chapter is converted
|
||||
{
|
||||
name: "Single page, ComicInfo, converted",
|
||||
chapter: &packer.Chapter{
|
||||
Pages: []*packer.Page{
|
||||
chapter: &manga.Chapter{
|
||||
Pages: []*manga.Page{
|
||||
{
|
||||
Index: 0,
|
||||
Extension: ".jpg",
|
||||
@@ -36,8 +36,8 @@ func TestWriteChapterToCBZ(t *testing.T) {
|
||||
//test case where there is only one page and no
|
||||
{
|
||||
name: "Single page, no ComicInfo",
|
||||
chapter: &packer.Chapter{
|
||||
Pages: []*packer.Page{
|
||||
chapter: &manga.Chapter{
|
||||
Pages: []*manga.Page{
|
||||
{
|
||||
Index: 0,
|
||||
Extension: ".jpg",
|
||||
@@ -49,8 +49,8 @@ func TestWriteChapterToCBZ(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Multiple pages with ComicInfo",
|
||||
chapter: &packer.Chapter{
|
||||
Pages: []*packer.Page{
|
||||
chapter: &manga.Chapter{
|
||||
Pages: []*manga.Page{
|
||||
{
|
||||
Index: 0,
|
||||
Extension: ".jpg",
|
||||
@@ -68,8 +68,8 @@ func TestWriteChapterToCBZ(t *testing.T) {
|
||||
},
|
||||
{
|
||||
name: "Split page",
|
||||
chapter: &packer.Chapter{
|
||||
Pages: []*packer.Page{
|
||||
chapter: &manga.Chapter{
|
||||
Pages: []*manga.Page{
|
||||
{
|
||||
Index: 0,
|
||||
Extension: ".jpg",
|
||||
|
@@ -6,13 +6,13 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"github.com/araddon/dateparse"
|
||||
"github.com/belphemur/CBZOptimizer/packer"
|
||||
"github.com/belphemur/CBZOptimizer/manga"
|
||||
"io"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func LoadChapter(filePath string) (*packer.Chapter, error) {
|
||||
func LoadChapter(filePath string) (*manga.Chapter, error) {
|
||||
// Open the .cbz file
|
||||
r, err := zip.OpenReader(filePath)
|
||||
if err != nil {
|
||||
@@ -20,7 +20,7 @@ func LoadChapter(filePath string) (*packer.Chapter, error) {
|
||||
}
|
||||
defer r.Close()
|
||||
|
||||
chapter := &packer.Chapter{
|
||||
chapter := &manga.Chapter{
|
||||
FilePath: filePath,
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ func LoadChapter(filePath string) (*packer.Chapter, error) {
|
||||
}
|
||||
|
||||
// Create a new Page object
|
||||
page := &packer.Page{
|
||||
page := &manga.Page{
|
||||
Index: uint16(len(chapter.Pages)), // Simple index based on order
|
||||
Extension: ext,
|
||||
Size: uint64(buf.Len()),
|
||||
|
Reference in New Issue
Block a user