57 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			57 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
package steamimmich
 | 
						|
 | 
						|
import (
 | 
						|
	"fmt"
 | 
						|
	"os"
 | 
						|
)
 | 
						|
 | 
						|
type Config struct {
 | 
						|
	BaseURL     string
 | 
						|
	APIKey      string
 | 
						|
	UserdataDir string
 | 
						|
	DeiveID     string
 | 
						|
}
 | 
						|
 | 
						|
func Run(config Config) {
 | 
						|
	screenshotFiles, err := listScreenshots(config.UserdataDir)
 | 
						|
 | 
						|
	if err != nil {
 | 
						|
		fmt.Println("Failed to scan for screenshots")
 | 
						|
		os.Exit(1)
 | 
						|
	}
 | 
						|
 | 
						|
	if len(screenshotFiles) == 0 {
 | 
						|
		fmt.Println("No screenshots found.")
 | 
						|
		return
 | 
						|
	}
 | 
						|
 | 
						|
	gameNameCache := make(map[string]string)
 | 
						|
 | 
						|
	for appid, files := range screenshotFiles {
 | 
						|
		gameName := getGameName(appid, gameNameCache)
 | 
						|
		fmt.Printf("AppID: %s  →  %s\n", appid, gameName)
 | 
						|
 | 
						|
		assetsInGame := make([]string, 0)
 | 
						|
 | 
						|
		for _, f := range files {
 | 
						|
			fmt.Printf("   %s\n", f)
 | 
						|
 | 
						|
			res, err := uploadToImmich(f, appid, config.BaseURL, config.APIKey, config.DeiveID)
 | 
						|
 | 
						|
			if err != nil {
 | 
						|
				fmt.Printf("Failed to upload to immich: %s", err)
 | 
						|
				return
 | 
						|
			}
 | 
						|
 | 
						|
			fmt.Printf("Done. ID: %s", res.ID)
 | 
						|
 | 
						|
			assetsInGame = append(assetsInGame, res.ID)
 | 
						|
		}
 | 
						|
 | 
						|
		setAssetMetadata(assetsInGame, fmt.Sprintf("Game: %s", gameName), config.BaseURL, config.APIKey)
 | 
						|
 | 
						|
		fmt.Println()
 | 
						|
	}
 | 
						|
 | 
						|
}
 |