Allow setting custom screenshot filename on struct
This commit is contained in:
parent
0e4bfcdb91
commit
bc26e6e787
|
@ -57,14 +57,9 @@ func processGames(games []games.Game, outputPath string, dryRun bool) {
|
||||||
os.MkdirAll(destinationPath, 0711)
|
os.MkdirAll(destinationPath, 0711)
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Printf("=> Proceesing screenshots for %s", game.Name)
|
log.Printf("=> Proceesing screenshots for %s %s", game.Name, game.Notes)
|
||||||
for _, screenshot := range game.Screenshots {
|
for _, screenshot := range game.Screenshots {
|
||||||
fileStat, statErr := os.Stat(screenshot.Path)
|
destinationPath := path.Join(destinationPath, screenshot.GetDestinationName())
|
||||||
if statErr != nil {
|
|
||||||
log.Fatal(statErr)
|
|
||||||
}
|
|
||||||
|
|
||||||
destinationPath := path.Join(destinationPath, fileStat.ModTime().Format("2006-01-02_15-04-05")+path.Ext(screenshot.Path))
|
|
||||||
|
|
||||||
if _, err := os.Stat(destinationPath); !os.IsNotExist(err) {
|
if _, err := os.Stat(destinationPath); !os.IsNotExist(err) {
|
||||||
sourceMd5, err := helpers.Md5File(screenshot.Path)
|
sourceMd5, err := helpers.Md5File(screenshot.Path)
|
||||||
|
|
|
@ -1,13 +1,32 @@
|
||||||
package games
|
package games
|
||||||
|
|
||||||
|
import (
|
||||||
|
"log"
|
||||||
|
"os"
|
||||||
|
"path"
|
||||||
|
)
|
||||||
|
|
||||||
type Game struct {
|
type Game struct {
|
||||||
ID uint64
|
ID uint64
|
||||||
Name string
|
Name string
|
||||||
Platform string
|
Platform string
|
||||||
Provider string
|
Provider string
|
||||||
Screenshots []Screenshot
|
Screenshots []Screenshot
|
||||||
|
Notes string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Screenshot struct {
|
type Screenshot struct {
|
||||||
Path string
|
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("2006-01-02_15-04-05") + path.Ext(screenshot.Path)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue