allow multiple files to be processed

This commit is contained in:
2026-01-06 19:17:55 +01:00
parent ff35f6ecd5
commit 72f7b44f98
2 changed files with 63 additions and 49 deletions

View File

@@ -8,66 +8,71 @@ import (
type Config struct {
}
func Scan(file string, config Config) {
fmt.Printf("Scanning file: %s\n", file)
gameID, err := scanGameFileForID(file)
if err != nil {
fmt.Printf("Failed to scan game file: %s", err)
os.Exit(1)
}
fmt.Printf("Found game ID: %s\n", gameID)
func Scan(files []string, config Config) {
gameList, err := loadGamelist("./ps2-gameslist.txt")
if err != nil {
fmt.Printf("Failed to load game list: %v", err)
os.Exit(1)
}
gameName := gameList[gameID]
fmt.Printf("Found game name: %s\n", gameName)
for _, file := range files {
fmt.Printf("Scanning file: %s\n", file)
gameID, err := scanGameFileForID(file)
if err != nil {
fmt.Printf("Failed to scan game file: %s", err)
os.Exit(1)
}
fmt.Printf("Found game ID: %s\n", gameID)
gameName := gameList[gameID]
fmt.Printf("Found game name: %s\n", gameName)
}
}
func Rename(file string, config Config) {
fmt.Printf("Scanning file: %s\n", file)
gameID, err := scanGameFileForID(file)
if err != nil {
fmt.Printf("Failed to scan game file: %s", err)
os.Exit(1)
}
fmt.Printf("Found game ID: %s\n", gameID)
func Rename(files []string, config Config) {
gameList, err := loadGamelist("./ps2-gameslist.txt")
if err != nil {
fmt.Printf("Failed to load game list: %v", err)
os.Exit(1)
}
gameName := gameList[gameID]
fmt.Printf("Found game name: %s\n", gameName)
for _, file := range files {
fmt.Printf("Scanning file: %s\n", file)
newPath, err := renameGameFile(file, gameName)
if err != nil {
fmt.Printf("Failed to rename file: %v", err)
os.Exit(1)
gameID, err := scanGameFileForID(file)
if err != nil {
fmt.Printf("Failed to scan game file: %s", err)
os.Exit(1)
}
fmt.Printf("Found game ID: %s\n", gameID)
gameName := gameList[gameID]
fmt.Printf("Found game name: %s\n", gameName)
newPath, err := renameGameFile(file, gameName)
if err != nil {
fmt.Printf("Failed to rename file: %v", err)
os.Exit(1)
}
fmt.Printf("Renamed %s to %s", file, newPath)
}
fmt.Printf("Renamed %s to %s", file, newPath)
}
func DownloadGameArt(file string, config Config) {
fmt.Printf("Scanning file: %s\n", file)
func DownloadGameArt(files []string, config Config) {
for _, file := range files {
fmt.Printf("Scanning file: %s\n", file)
gameID, err := scanGameFileForID(file)
if err != nil {
fmt.Printf("Failed to scan game file: %s", err)
os.Exit(1)
gameID, err := scanGameFileForID(file)
if err != nil {
fmt.Printf("Failed to scan game file: %s", err)
os.Exit(1)
}
fmt.Printf("Found game ID: %s\n", gameID)
downloadArtForGame(gameID, "./ignore")
}
fmt.Printf("Found game ID: %s\n", gameID)
downloadArtForGame(gameID, "./art")
}