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.
main
Óscar M. Lage 2024-10-14 16:52:15 +02:00
parent 9d30151d46
commit 2503bc9ebb
10 changed files with 10 additions and 4 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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