Compare commits

..

2 Commits

Author SHA1 Message Date
d4836c1d95 Cosmetics 2024-10-24 17:16:20 +02:00
e810c7d9a6 Fix a bug with the progress field and the quotes 2024-10-24 17:15:59 +02:00
8 changed files with 11 additions and 6 deletions

View File

@ -26,6 +26,7 @@ func LoadBooks() ([]Book, error) {
}
func ProcessBooks(books []Book, update bool) error {
utils.Sep()
fmt.Printf(" B O O K S\n")
utils.Sep()
for _, book := range books {

View File

@ -26,12 +26,12 @@ func LoadMovies() ([]Movie, error) {
}
func ProcessMovies(movies []Movie, update bool) error {
utils.Sep()
fmt.Printf(" M O V I E S\n")
utils.Sep()
for _, movie := range movies {
// Debug print
fmt.Printf("Título: %s, Puntuación: %.1f, Fecha: %s\n",
movie.Title, movie.Rate, movie.Date)
fmt.Printf("Título: %s\n", movie.Title)
// If we're updating, the process is a bit different
if update || !movie.New {
@ -126,6 +126,7 @@ func generateMovieMarkdown(movie Movie) error {
"Subtitle": movie.Year,
"Year": movie.Year,
"Rate": movie.Rate,
"Progress": movie.Progress,
"Image": movie.Image,
"Poster": movie.Poster,
"Background": movie.Background,
@ -138,6 +139,7 @@ func generateMovieMarkdown(movie Movie) error {
// Helper function to update only YAML fields that exist in both the frontmatter and YAML data
func updateFrontmatterWithYAML(frontmatter utils.FrontMatter, movie Movie) utils.FrontMatter {
frontmatter.Progress = movie.Progress
frontmatter.Date = movie.Date
frontmatter.Rate = movie.Rate
return frontmatter

View File

@ -12,6 +12,7 @@ type Movie struct {
Link string `yaml:"link"`
Year int `yaml:"year"`
Rate float64 `yaml:"rate"`
Progress string `yaml:"progress"`
Image string `yaml:"image"`
Poster string `yaml:"poster-image"`
Background string `yaml:"background-image"`

View File

@ -26,6 +26,7 @@ func LoadAlbums() ([]Album, error) {
}
func ProcessAlbum(albumList []Album, update bool) error {
utils.Sep()
fmt.Printf(" M U S I C\n")
utils.Sep()
for _, album := range albumList {

View File

@ -26,12 +26,12 @@ func LoadSeries() ([]Serie, error) {
}
func ProcessSeries(series []Serie, update bool) error {
utils.Sep()
fmt.Printf(" S E R I E S\n")
utils.Sep()
for _, serie := range series {
// Debug print
fmt.Printf("Título: %s, Puntuación: %.1f, Fecha: %s\n",
serie.Title, serie.Rate, serie.Date)
fmt.Printf("Título: %s\n", serie.Title)
// If we're updating, the process is a bit different
if update || !serie.New {

View File

@ -14,7 +14,6 @@ import (
func main() {
// Load .env file
utils.LoadConfig()
utils.Sep()
// --media parameter
media := flag.String("media", "", "Specify the media type to process: movies, series, books, games, or music")

View File

@ -4,6 +4,7 @@ link: "{{ .Link }}"
subtitle: "{{ .Subtitle }}"
year: {{ .Year }}
rate: {{ .Rate }}
progress: {{ .Progress }}
image: {{ .Image }}
poster-image: {{ .Poster }}
background-image: {{ .Background }}

View File

@ -97,7 +97,7 @@ func SaveUpdatedMarkdown(filepath string, frontmatter FrontMatter, content strin
fileContent := string(fileBytes)
fieldPatterns := map[string]string{
"progress": `(?m)^progress: "(.*)%"$`,
"progress": `(?m)^progress: (.*)%$`,
"episode": `(?m)^episode: "(.*)"$`,
"date": `(?m)^date: "(.*)"$`,
"rate": `(?m)^rate: (\d+\.?\d*)$`,