refactor: change package name

This commit is contained in:
Antoine Aflalo
2024-08-27 13:27:50 -04:00
parent 9083ec599a
commit 634f13582e
13 changed files with 122 additions and 49 deletions

View File

@@ -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 {

View File

@@ -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",

View File

@@ -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()),