111 lines
2.4 KiB
Go
111 lines
2.4 KiB
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"hugo-medialog/internal/books"
|
|
"hugo-medialog/internal/games"
|
|
"hugo-medialog/internal/movies"
|
|
"hugo-medialog/internal/music"
|
|
"hugo-medialog/internal/series"
|
|
"hugo-medialog/utils"
|
|
)
|
|
|
|
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")
|
|
update := flag.Bool("update", false, "Run in update mode to update existing entries")
|
|
flag.Parse()
|
|
|
|
if *media == "" {
|
|
processAll(*update)
|
|
} else {
|
|
switch *media {
|
|
case "movies":
|
|
processMovies(*update)
|
|
case "series":
|
|
processSeries(*update)
|
|
case "books":
|
|
processBooks(*update)
|
|
case "games":
|
|
processGames(*update)
|
|
case "music":
|
|
processMusic(*update)
|
|
default:
|
|
fmt.Printf("Invalid media type: %s. Please use movies, series, books, games, or music.\n", *media)
|
|
}
|
|
}
|
|
}
|
|
|
|
func processAll(update bool) {
|
|
processMovies(update)
|
|
processSeries(update)
|
|
processBooks(update)
|
|
processGames(update)
|
|
processMusic(update)
|
|
}
|
|
|
|
func processMovies(update bool) {
|
|
moviesList, err := movies.LoadMovies()
|
|
if err != nil {
|
|
fmt.Printf("Error reading movies file: %v\n", err)
|
|
return
|
|
}
|
|
err = movies.ProcessMovies(moviesList, update)
|
|
if err != nil {
|
|
fmt.Printf("Error processing movies: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func processSeries(update bool) {
|
|
seriesList, err := series.LoadSeries()
|
|
if err != nil {
|
|
fmt.Printf("Error reading series file: %v\n", err)
|
|
return
|
|
}
|
|
err = series.ProcessSeries(seriesList, update)
|
|
if err != nil {
|
|
fmt.Printf("Error processing series: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func processBooks(update bool) {
|
|
booksList, err := books.LoadBooks()
|
|
if err != nil {
|
|
fmt.Printf("Error reading books file: %v\n", err)
|
|
return
|
|
}
|
|
err = books.ProcessBooks(booksList, update)
|
|
if err != nil {
|
|
fmt.Printf("Error processing books: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func processGames(update bool) {
|
|
gamesList, err := games.LoadGames()
|
|
if err != nil {
|
|
fmt.Printf("Error reading games file: %v\n", err)
|
|
return
|
|
}
|
|
err = games.ProcessGames(gamesList, update)
|
|
if err != nil {
|
|
fmt.Printf("Error processing games: %v\n", err)
|
|
}
|
|
}
|
|
|
|
func processMusic(update bool) {
|
|
albumList, err := music.LoadAlbums()
|
|
if err != nil {
|
|
fmt.Printf("Error reading music file: %v\n", err)
|
|
return
|
|
}
|
|
err = music.ProcessAlbum(albumList, update)
|
|
if err != nil {
|
|
fmt.Printf("Error processing music: %v\n", err)
|
|
}
|
|
}
|