Skip to content

Commit

Permalink
Add html flag and skip to generate html files
Browse files Browse the repository at this point in the history
  • Loading branch information
YamazakiYasuhiro authored and igolaizola committed Sep 12, 2023
1 parent b3b8fbf commit c119c0c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions bulkai.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ type Config struct {
Upscale bool `yaml:"upscale"`
Download bool `yaml:"download"`
Thumbnail bool `yaml:"thumbnail"`
Html bool `yaml:"html"`
Channel string `yaml:"channel"`
Concurrency int `yaml:"concurrency"`
Wait time.Duration `yaml:"wait"`
Expand Down Expand Up @@ -309,7 +310,7 @@ func Generate(ctx context.Context, cfg *Config, opts ...Option) error {
}
}
}
if err := SaveAlbum(albumDir, album, cfg.Thumbnail); err != nil {
if err := SaveAlbum(albumDir, album, cfg.Thumbnail, cfg.Html); err != nil {
return fmt.Errorf("couldn't save album: %w", err)
}
log.Println("album created:", albumDir)
Expand Down Expand Up @@ -363,7 +364,7 @@ func Generate(ctx context.Context, cfg *Config, opts ...Option) error {
album.Percentage = percentage
album.Status = status

err := SaveAlbum(albumDir, album, cfg.Thumbnail)
err := SaveAlbum(albumDir, album, cfg.Thumbnail, cfg.Html)
lck.Unlock()
if err != nil {
return fmt.Errorf("couldn't generate html: %w", err)
Expand Down Expand Up @@ -495,7 +496,7 @@ type htmlImage struct {
Prompt string
}

func SaveAlbum(dir string, a *Album, thumbnail bool) error {
func SaveAlbum(dir string, a *Album, thumbnail bool, html bool) error {
// Sort images
images := a.Images
sort.Slice(images, func(i, j int) bool {
Expand All @@ -511,6 +512,11 @@ func SaveAlbum(dir string, a *Album, thumbnail bool) error {
return fmt.Errorf("couldn't write album: %w", err)
}

// Skip to generate html files
if !html {
return nil
}

var local htmlData
local.Title = fmt.Sprintf("Album %s", a.ID)
local.Status = fmt.Sprintf("%s %d%% %s", a.Status, int(a.Percentage), a.UpdatedAt.Format("2006-01-02 15:04:05"))
Expand Down

0 comments on commit c119c0c

Please sign in to comment.