games-screenshot-manager/pkg/providers/types.go

43 lines
793 B
Go
Raw Normal View History

2021-05-08 09:37:52 +00:00
package providers
2020-10-29 12:50:27 +00:00
import (
"log"
"os"
"path/filepath"
)
2020-11-19 22:18:01 +00:00
const DatetimeFormat = "2006-01-02_15-04-05"
2021-05-08 09:37:52 +00:00
type ProviderOptions struct {
OutputPath *string
InputPath *string
DownloadCovers *bool
DryRun *bool
}
2020-10-29 12:50:27 +00:00
type Game struct {
2020-11-19 22:05:14 +00:00
ID string
2020-10-29 12:50:27 +00:00
Name string
Platform string
Provider string
Screenshots []Screenshot
Notes string
Cover Screenshot
2020-10-29 12:50:27 +00:00
}
type Screenshot struct {
Path string
DestinationName string
}
func (screenshot Screenshot) GetDestinationName() string {
if screenshot.DestinationName != "" {
return screenshot.DestinationName
}
fileStat, statErr := os.Stat(screenshot.Path)
if statErr != nil {
log.Fatal(statErr)
}
return fileStat.ModTime().Format(DatetimeFormat) + filepath.Ext(screenshot.Path)
2020-10-29 12:50:27 +00:00
}