From 768eb8d5162b06daa3b3744126ea35b8e30313bf Mon Sep 17 00:00:00 2001 From: KonradIT Date: Sun, 12 Sep 2021 14:20:16 +0200 Subject: [PATCH] add video resolution/framerate sort to gopro connect --- pkg/gopro/connect.go | 15 ++++++++++++--- pkg/gopro/structs.go | 24 ++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/pkg/gopro/connect.go b/pkg/gopro/connect.go index 6eb3af9..52179cc 100644 --- a/pkg/gopro/connect.go +++ b/pkg/gopro/connect.go @@ -157,14 +157,23 @@ func ImportConnect(in, out string, sortOptions SortOptions) (*utils.Result, erro filename := fmt.Sprintf("%s%s-%s.%s", x[:2], x[4:][:4], x[2:][:2], strings.Split(x, ".")[1]) color.Green(">>> %s", x) - if _, err := os.Stat(filepath.Join(dayFolder, "videos")); os.IsNotExist(err) { - err = os.MkdirAll(filepath.Join(dayFolder, "videos"), 0755) + var gpFileInfo = &goProMediaMetadata{} + err = caller(in, fmt.Sprintf("gp/gpMediaMetadata?p=%s/%s&t=v4info", folder.D, goprofile.N), gpFileInfo) + if err != nil { + return nil, err + } + + framerate := gpFileInfo.Fps / gpFileInfo.FpsDenom + rfpsFolder := fmt.Sprintf("%sx%s %d", gpFileInfo.W, gpFileInfo.H, framerate) + + if _, err := os.Stat(filepath.Join(dayFolder, "videos", rfpsFolder)); os.IsNotExist(err) { + err = os.MkdirAll(filepath.Join(dayFolder, "videos", rfpsFolder), 0755) if err != nil { log.Fatal(err.Error()) } } - err := utils.DownloadFile(filepath.Join(dayFolder, "videos", filename), fmt.Sprintf("http://%s:8080/videos/DCIM/%s/%s", in, folder.D, goprofile.N)) + err := utils.DownloadFile(filepath.Join(dayFolder, "videos", rfpsFolder, filename), fmt.Sprintf("http://%s:8080/videos/DCIM/%s/%s", in, folder.D, goprofile.N)) if err != nil { result.Errors = append(result.Errors, err) result.FilesNotImported = append(result.FilesNotImported, goprofile.N) diff --git a/pkg/gopro/structs.go b/pkg/gopro/structs.go index 01d9a23..7a3a835 100644 --- a/pkg/gopro/structs.go +++ b/pkg/gopro/structs.go @@ -137,3 +137,27 @@ type GoProConnectDevice struct { IP string Info cameraInfo } + +type goProMediaMetadata struct { + Cre string `json:"cre"` + S string `json:"s"` + Us string `json:"us"` + Mos []interface{} `json:"mos"` + Eis string `json:"eis"` + Pta string `json:"pta"` + Ao string `json:"ao"` + Tr string `json:"tr"` + Mp string `json:"mp"` + Gumi string `json:"gumi"` + Ls string `json:"ls"` + Cl string `json:"cl"` + Hc string `json:"hc"` + Hi []interface{} `json:"hi"` + Dur string `json:"dur"` + W string `json:"w"` + H string `json:"h"` + Fps int `json:"fps,string"` + FpsDenom int `json:"fps_denom,string"` + Prog string `json:"prog"` + Subsample string `json:"subsample"` +}