Added --update param
It's being used to only update some frontmatter fields: - title - progress - rate - date
This commit is contained in:
parent
c7b120a1e5
commit
410f50f716
37
main.go
37
main.go
@ -18,37 +18,38 @@ func main() {
|
||||
|
||||
// --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()
|
||||
processAll(*update)
|
||||
} else {
|
||||
switch *media {
|
||||
case "movies":
|
||||
processMovies()
|
||||
processMovies(*update)
|
||||
case "series":
|
||||
processSeries()
|
||||
processSeries(*update)
|
||||
case "books":
|
||||
processBooks()
|
||||
processBooks(*update)
|
||||
case "games":
|
||||
processGames()
|
||||
processGames(*update)
|
||||
case "music":
|
||||
processMusic()
|
||||
processMusic(*update)
|
||||
default:
|
||||
fmt.Printf("Invalid media type: %s. Please use movies, series, books, games, or music.\n", *media)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func processAll() {
|
||||
processMovies()
|
||||
processSeries()
|
||||
processBooks()
|
||||
processGames()
|
||||
processMusic()
|
||||
func processAll(update bool) {
|
||||
processMovies(update)
|
||||
processSeries(update)
|
||||
processBooks(update)
|
||||
processGames(update)
|
||||
processMusic(update)
|
||||
}
|
||||
|
||||
func processMovies() {
|
||||
func processMovies(update bool) {
|
||||
moviesList, err := movies.LoadMovies()
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading movies file: %v\n", err)
|
||||
@ -60,7 +61,7 @@ func processMovies() {
|
||||
}
|
||||
}
|
||||
|
||||
func processSeries() {
|
||||
func processSeries(update bool) {
|
||||
seriesList, err := series.LoadSeries()
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading series file: %v\n", err)
|
||||
@ -72,19 +73,19 @@ func processSeries() {
|
||||
}
|
||||
}
|
||||
|
||||
func processBooks() {
|
||||
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)
|
||||
err = books.ProcessBooks(booksList, update)
|
||||
if err != nil {
|
||||
fmt.Printf("Error processing books: %v\n", err)
|
||||
}
|
||||
}
|
||||
|
||||
func processGames() {
|
||||
func processGames(update bool) {
|
||||
gamesList, err := games.LoadGames()
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading games file: %v\n", err)
|
||||
@ -96,7 +97,7 @@ func processGames() {
|
||||
}
|
||||
}
|
||||
|
||||
func processMusic() {
|
||||
func processMusic(update bool) {
|
||||
albumList, err := music.LoadAlbums()
|
||||
if err != nil {
|
||||
fmt.Printf("Error reading music file: %v\n", err)
|
||||
|
Loading…
Reference in New Issue
Block a user