From 2503bc9ebb59c9771544c475a688c35c3e085dc3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?O=CC=81scar=20M=2E=20Lage?= Date: Mon, 14 Oct 2024 16:52:15 +0200 Subject: [PATCH] Fix: update by default From now on, the update option (no api calls involved) is the default one. No matter if --update is being passed in the command line, it's the default option if there is no a "new: true" variable in the yaml. If there is a "new: true" variable in the yaml that entry will be processed as new, calling all the apis we need to call to archive the right information. --- internal/books/controller.go | 2 +- internal/books/model.go | 1 + internal/games/controller.go | 2 +- internal/games/model.go | 1 + internal/movies/controller.go | 1 + internal/movies/model.go | 1 + internal/music/controller.go | 2 +- internal/music/model.go | 1 + internal/series/controller.go | 2 +- internal/series/model.go | 1 + 10 files changed, 10 insertions(+), 4 deletions(-) diff --git a/internal/books/controller.go b/internal/books/controller.go index 321ff2f..0b7e51a 100644 --- a/internal/books/controller.go +++ b/internal/books/controller.go @@ -32,7 +32,7 @@ func ProcessBooks(books []Book, update bool) error { fmt.Printf("Title: %s, Author: %s, ID: %s\n", book.Title, book.Author, book.ID) // If we're updating, the process is a bit different - if update { + if update || !book.New { outputDir := os.Getenv("MARKDOWN_OUTPUT_BOOKS_DIR") mdFilePath := filepath.Join(outputDir, fmt.Sprintf("%s.md", utils.Sluggify(book.Title))) frontmatter, content, err := utils.LoadMarkdown(mdFilePath) diff --git a/internal/books/model.go b/internal/books/model.go index c9433d9..c9a8b2f 100644 --- a/internal/books/model.go +++ b/internal/books/model.go @@ -13,6 +13,7 @@ type Book struct { Progress string `yaml:"progress"` Image string `yaml:"image"` Date string `yaml:"date"` + New bool `yaml:"new"` Tags []string } diff --git a/internal/games/controller.go b/internal/games/controller.go index 2846e8f..c1832ef 100644 --- a/internal/games/controller.go +++ b/internal/games/controller.go @@ -32,7 +32,7 @@ func ProcessGames(games []Game, update bool) error { fmt.Printf("Title: %s\n", game.Title) // If we're updating, the process is a bit different - if update { + if update || !game.New { outputDir := os.Getenv("MARKDOWN_OUTPUT_GAMES_DIR") mdFilePath := filepath.Join(outputDir, fmt.Sprintf("%s.md", utils.Sluggify(game.Title))) frontmatter, content, err := utils.LoadMarkdown(mdFilePath) diff --git a/internal/games/model.go b/internal/games/model.go index bf06f45..649986a 100644 --- a/internal/games/model.go +++ b/internal/games/model.go @@ -14,6 +14,7 @@ type Game struct { Poster string `yaml:"poster-image"` Background string `yaml:"background-image"` Date string `yaml:"date"` + New bool `yaml:"new"` Tags []string } diff --git a/internal/movies/controller.go b/internal/movies/controller.go index cf005f4..3b2d679 100644 --- a/internal/movies/controller.go +++ b/internal/movies/controller.go @@ -34,6 +34,7 @@ func ProcessMovies(movies []Movie, update bool) error { movie.Title, movie.Rate, movie.Date) // If we're updating, the process is a bit different + if update || !movie.New { outputDir := os.Getenv("MARKDOWN_OUTPUT_MOVIES_DIR") mdFilePath := filepath.Join(outputDir, fmt.Sprintf("%s.md", utils.Sluggify(movie.Title))) frontmatter, content, err := utils.LoadMarkdown(mdFilePath) diff --git a/internal/movies/model.go b/internal/movies/model.go index 3291243..fdc8d0b 100644 --- a/internal/movies/model.go +++ b/internal/movies/model.go @@ -16,6 +16,7 @@ type Movie struct { Poster string `yaml:"poster-image"` Background string `yaml:"background-image"` Date string `yaml:"date"` + New bool `yaml:"new"` Tags []string } diff --git a/internal/music/controller.go b/internal/music/controller.go index 55512b2..557acc5 100644 --- a/internal/music/controller.go +++ b/internal/music/controller.go @@ -32,7 +32,7 @@ func ProcessAlbum(albumList []Album, update bool) error { fmt.Printf("Title: %s\n", album.Title) // If we're updating, the process is a bit different - if update { + if update || !album.New { outputDir := os.Getenv("MARKDOWN_OUTPUT_MUSIC_DIR") mdFilePath := filepath.Join(outputDir, fmt.Sprintf("%s.md", utils.Sluggify(album.Title))) frontmatter, content, err := utils.LoadMarkdown(mdFilePath) diff --git a/internal/music/model.go b/internal/music/model.go index c5d9082..84876a5 100644 --- a/internal/music/model.go +++ b/internal/music/model.go @@ -13,6 +13,7 @@ type Album struct { Tracks int `yaml:"tracks"` Image string `yaml:"image"` Date string `yaml:"date"` + New bool `yaml:"new"` Tags []string } diff --git a/internal/series/controller.go b/internal/series/controller.go index 4fc88ec..716d7c8 100644 --- a/internal/series/controller.go +++ b/internal/series/controller.go @@ -34,7 +34,7 @@ func ProcessSeries(series []Serie, update bool) error { serie.Title, serie.Rate, serie.Date) // If we're updating, the process is a bit different - if update { + if update || !serie.New { outputDir := os.Getenv("MARKDOWN_OUTPUT_SERIES_DIR") mdFilePath := filepath.Join(outputDir, fmt.Sprintf("%s.md", utils.Sluggify(serie.Title))) frontmatter, content, err := utils.LoadMarkdown(mdFilePath) diff --git a/internal/series/model.go b/internal/series/model.go index 32d70e3..ab6e514 100644 --- a/internal/series/model.go +++ b/internal/series/model.go @@ -19,6 +19,7 @@ type Serie struct { Poster string `yaml:"poster-image"` Background string `yaml:"background-image"` Date string `yaml:"date"` + New bool `yaml:"new"` Tags []string }