Added --media argument

You can execute the script as it is to process all the kind of media content
OR you can select the media you want to only process that kind of content:

--media movies
--media series
--media books
--media games
--media music
This commit is contained in:
Óscar M. Lage 2024-10-10 14:22:15 +02:00
parent ccb115a75b
commit ce99b3a3c6

37
main.go
View File

@ -1,6 +1,7 @@
package main
import (
"flag"
"fmt"
"hugo-medialog/internal/books"
"hugo-medialog/internal/movies"
@ -12,6 +13,37 @@ func main() {
// Load .env file
utils.LoadConfig()
// Parameter
media := flag.String("media", "", "Specify the media type to process: movies, series, books, games, or music")
flag.Parse()
if *media == "" {
processAll()
} else {
switch *media {
case "movies":
processMovies()
case "series":
processSeries()
case "books":
processBooks()
// case "games":
// processGames()
// case "music":
// processMusic()
default:
fmt.Printf("Invalid media type: %s. Please use movies, series, books, games, or music.\n", *media)
}
}
}
func processAll() {
processMovies()
processSeries()
processBooks()
}
func processMovies() {
// Movies
moviesList, err := movies.LoadMovies()
if err != nil {
@ -22,7 +54,9 @@ func main() {
if err != nil {
fmt.Printf("Error processing movies: %v\n", err)
}
}
func processSeries() {
// Series
seriesList, err := series.LoadSeries()
if err != nil {
@ -33,7 +67,9 @@ func main() {
if err != nil {
fmt.Printf("Error processing series: %v\n", err)
}
}
func processBooks() {
// Books
booksList, err := books.LoadBooks()
if err != nil {
@ -44,5 +80,4 @@ func main() {
if err != nil {
fmt.Printf("Error processing books: %v\n", err)
}
}