From d6e56c6cb918630e0df6d168b9771ea8ee7dc73a Mon Sep 17 00:00:00 2001 From: Daktak Date: Tue, 10 Jan 2023 13:50:45 +1100 Subject: [PATCH 01/13] info --- cmd/info.go | 45 ++++++++++++++++++++++++++++++++++++++++++++ pkg/gopro/info.go | 14 ++++++++++++++ pkg/gopro/structs.go | 45 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 104 insertions(+) create mode 100644 cmd/info.go create mode 100644 pkg/gopro/info.go diff --git a/cmd/info.go b/cmd/info.go new file mode 100644 index 0000000..b41e7cb --- /dev/null +++ b/cmd/info.go @@ -0,0 +1,45 @@ +package cmd + +import ( + "fmt" + + "github.com/erdaltsksn/cui" + "github.com/konradit/mmt/pkg/gopro" + "github.com/spf13/cobra" + "github.com/konradit/mmt/pkg/utils" +) + +var infoCmd = &cobra.Command{ + Use: "info", + Run: func(cmd *cobra.Command, args []string) { + input := getFlagString(cmd, "input") + camera := getFlagString(cmd, "camera") + customCameraOpts := make(map[string]interface{}) + if useGoPro, err := cmd.Flags().GetBool("use_gopro"); err == nil && useGoPro { + detectedGoPro, connectionType, err := gopro.Detect() + if err != nil { + cui.Error(err.Error()) + } + input = detectedGoPro + customCameraOpts["connection"] = string(connectionType) + camera = "gopro" + } + if camera != "" && input != "" { + c, err := utils.CameraGet(camera) + if err != nil { + cui.Error("Something went wrong", err) + } + switch c { + case utils.GoPro: + fmt.Println(camera) + fmt.Println(input) + } + } + }, +} + +func init() { + rootCmd.AddCommand(infoCmd) + infoCmd.Flags().StringP("input", "i", "", "Input IP Address") + infoCmd.Flags().StringP("camera", "c", "", "Camera type") +} diff --git a/pkg/gopro/info.go b/pkg/gopro/info.go new file mode 100644 index 0000000..9ab2062 --- /dev/null +++ b/pkg/gopro/info.go @@ -0,0 +1,14 @@ +package gopro + +/* GoPro Connect - API exposed over USB Ethernet */ + +import ( + /* + "encoding/json" + "fmt" + */ +) + +func getInfo(in string) { + +} diff --git a/pkg/gopro/structs.go b/pkg/gopro/structs.go index d762520..2eb4833 100644 --- a/pkg/gopro/structs.go +++ b/pkg/gopro/structs.go @@ -143,3 +143,48 @@ type goProMediaMetadata struct { Prog string `json:"prog"` Subsample string `json:"subsample"` } + +type goProStatus struct { + batteryPresent int `json:"1"` + batteryLevel int `json:"2"` + currentMode int `json:"43"` + currentSubMode int `json:"44"` + currentRecVidDuration int `json:"13"` + multiShotNumber int `json:"39"` + clients int `json:"31"` + streaming int `json:"32"` + sdCard int `json:"33"` + photosRemaining string `json:"34,string"` + videoRemaining string `json:"35,string"` + batchNumber int `json:"36"` + videoCount int `json:"37"` + photoCount int `json:"38"` + videoAllCount int `json:"39"` + processing int `json:"8"` + cardSpace int `json:"54"` +} + +type goProSettings struct { + subModeVideo int `json:"68"` + vidRes int `json:"2"` + frameRes int `json:"3"` + fovVid int `json:"4"` + timeLapseInt int `json:"5"` + loopVidInt int `json:"6"` + interval int `json:"7"` + lowLight bool `json:"8"` + spotMeter bool `json:"9"` + proTune bool `json:"10"` + whiteBalance int `json:"11"` + color int `json:"12"` + exposure int `json:"73"` + isoMode int `json:"74"` + isoLimet int `json:"13"` + sharpness int `json:"14"` + evComp int `json:"15"` +} + +type goProCameraStatus struct { + Status []goProStatus `json:"status"` + Settings []goProSettings `json:"settings"` +} From 5c8fbc7fe04a66ebd852fbb8b08e41e260c06c80 Mon Sep 17 00:00:00 2001 From: Daktak Date: Tue, 10 Jan 2023 14:53:02 +1100 Subject: [PATCH 02/13] update --- cmd/info.go | 5 +---- pkg/gopro/detect.go | 4 ++++ pkg/gopro/info.go | 21 ++++++++++++++++----- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/cmd/info.go b/cmd/info.go index b41e7cb..5e3cad7 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -1,8 +1,6 @@ package cmd import ( - "fmt" - "github.com/erdaltsksn/cui" "github.com/konradit/mmt/pkg/gopro" "github.com/spf13/cobra" @@ -31,8 +29,7 @@ var infoCmd = &cobra.Command{ } switch c { case utils.GoPro: - fmt.Println(camera) - fmt.Println(input) + err = gopro.GetInfo(input) } } }, diff --git a/pkg/gopro/detect.go b/pkg/gopro/detect.go index 565be2c..4b8736f 100644 --- a/pkg/gopro/detect.go +++ b/pkg/gopro/detect.go @@ -1,6 +1,7 @@ package gopro import ( + "fmt" mErrors "github.com/konradit/mmt/pkg/errors" "github.com/konradit/mmt/pkg/utils" "github.com/shirou/gopsutil/disk" @@ -28,3 +29,6 @@ func Detect() (string, utils.ConnectionType, error) { return "", "", mErrors.ErrNoCameraDetected } +func Test() { + fmt.Println("aa") +} diff --git a/pkg/gopro/info.go b/pkg/gopro/info.go index 9ab2062..563982d 100644 --- a/pkg/gopro/info.go +++ b/pkg/gopro/info.go @@ -3,12 +3,23 @@ package gopro /* GoPro Connect - API exposed over USB Ethernet */ import ( - /* - "encoding/json" - "fmt" + "fmt" + /* + mErrors "github.com/konradit/mmt/pkg/errors" + "github.com/konradit/mmt/pkg/utils" + "github.com/shirou/gopsutil/disk" */ ) -func getInfo(in string) { - +func GetInfo(in string) error { + var gpStatus = &goProStatus{} + err := caller(in, "gp/gpControl/status", gpStatus) + if err != nil { + fmt.Println(err) + return err + } + fmt.Println(gpStatus) + fmt.Println("aoeua") + return nil } + From 05a2cc8a7a096a41dabf26f839ee480b5153b18c Mon Sep 17 00:00:00 2001 From: Daktak Date: Tue, 10 Jan 2023 15:29:03 +1100 Subject: [PATCH 03/13] update --- cmd/info.go | 12 ++++++------ pkg/gopro/info.go | 5 ++--- pkg/gopro/structs.go | 8 ++++---- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/cmd/info.go b/cmd/info.go index 5e3cad7..5897ff0 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -3,12 +3,12 @@ package cmd import ( "github.com/erdaltsksn/cui" "github.com/konradit/mmt/pkg/gopro" - "github.com/spf13/cobra" "github.com/konradit/mmt/pkg/utils" + "github.com/spf13/cobra" ) var infoCmd = &cobra.Command{ - Use: "info", + Use: "info", Run: func(cmd *cobra.Command, args []string) { input := getFlagString(cmd, "input") camera := getFlagString(cmd, "camera") @@ -29,10 +29,10 @@ var infoCmd = &cobra.Command{ } switch c { case utils.GoPro: - err = gopro.GetInfo(input) - } - } - }, + err = gopro.GetInfo(input) + } + } + }, } func init() { diff --git a/pkg/gopro/info.go b/pkg/gopro/info.go index 563982d..68b278d 100644 --- a/pkg/gopro/info.go +++ b/pkg/gopro/info.go @@ -12,14 +12,13 @@ import ( ) func GetInfo(in string) error { - var gpStatus = &goProStatus{} + var gpStatus = &goProCameraStatus{} err := caller(in, "gp/gpControl/status", gpStatus) if err != nil { - fmt.Println(err) + fmt.Println(err) return err } fmt.Println(gpStatus) - fmt.Println("aoeua") return nil } diff --git a/pkg/gopro/structs.go b/pkg/gopro/structs.go index 2eb4833..7f5e856 100644 --- a/pkg/gopro/structs.go +++ b/pkg/gopro/structs.go @@ -154,8 +154,8 @@ type goProStatus struct { clients int `json:"31"` streaming int `json:"32"` sdCard int `json:"33"` - photosRemaining string `json:"34,string"` - videoRemaining string `json:"35,string"` + photosRemaining int `json:"34"` + videoRemaining int `json:"35"` batchNumber int `json:"36"` videoCount int `json:"37"` photoCount int `json:"38"` @@ -185,6 +185,6 @@ type goProSettings struct { } type goProCameraStatus struct { - Status []goProStatus `json:"status"` - Settings []goProSettings `json:"settings"` + status goProStatus `json:"status"` + settings goProSettings `json:"settings"` } From 89b5e627336f3dc8d0d2a4de8fe9f49cf6cd8317 Mon Sep 17 00:00:00 2001 From: Daktak Date: Tue, 10 Jan 2023 15:46:41 +1100 Subject: [PATCH 04/13] gopro struct --- pkg/gopro/info.go | 2 +- pkg/gopro/structs.go | 346 ++++++++++++++++++++++++++++++++++++++----- 2 files changed, 307 insertions(+), 41 deletions(-) diff --git a/pkg/gopro/info.go b/pkg/gopro/info.go index 68b278d..52c4586 100644 --- a/pkg/gopro/info.go +++ b/pkg/gopro/info.go @@ -12,7 +12,7 @@ import ( ) func GetInfo(in string) error { - var gpStatus = &goProCameraStatus{} + var gpStatus = &CameraStatus{} err := caller(in, "gp/gpControl/status", gpStatus) if err != nil { fmt.Println(err) diff --git a/pkg/gopro/structs.go b/pkg/gopro/structs.go index 7f5e856..fa6d413 100644 --- a/pkg/gopro/structs.go +++ b/pkg/gopro/structs.go @@ -143,48 +143,314 @@ type goProMediaMetadata struct { Prog string `json:"prog"` Subsample string `json:"subsample"` } - -type goProStatus struct { - batteryPresent int `json:"1"` - batteryLevel int `json:"2"` - currentMode int `json:"43"` - currentSubMode int `json:"44"` - currentRecVidDuration int `json:"13"` - multiShotNumber int `json:"39"` - clients int `json:"31"` - streaming int `json:"32"` - sdCard int `json:"33"` - photosRemaining int `json:"34"` - videoRemaining int `json:"35"` - batchNumber int `json:"36"` - videoCount int `json:"37"` - photoCount int `json:"38"` - videoAllCount int `json:"39"` - processing int `json:"8"` - cardSpace int `json:"54"` +//CameraStatus current status and settings of the camera +type CameraStatus struct { + Status CurrentStatus `json:"status"` + Settings CurrentSettings `json:"settings"` } -type goProSettings struct { - subModeVideo int `json:"68"` - vidRes int `json:"2"` - frameRes int `json:"3"` - fovVid int `json:"4"` - timeLapseInt int `json:"5"` - loopVidInt int `json:"6"` - interval int `json:"7"` - lowLight bool `json:"8"` - spotMeter bool `json:"9"` - proTune bool `json:"10"` - whiteBalance int `json:"11"` - color int `json:"12"` - exposure int `json:"73"` - isoMode int `json:"74"` - isoLimet int `json:"13"` - sharpness int `json:"14"` - evComp int `json:"15"` +// CurrentStatus ... +type CurrentStatus struct { + // 1 - Internal Battery is available: + // 0 = No Battery + // 1 = Battery is available + InternalBattery int `json:"1"` + + // 2 - Internal Battery Level: + // 4 = Charging + // 3 = Full + // 2 = Halfway + // 1 = Low + // 0 = Empty + InternalBatteryLevel int `json:"2"` + + Num3 int `json:"3"` + Num4 int `json:"4"` + Num6 int `json:"6"` + Num8 int `json:"8"` + Num9 int `json:"9"` + Num10 int `json:"10"` + Num11 int `json:"11"` + + // 13 - Current Recording Video Duration + CurrentRecordingVideoDuration int `json:"13"` + + Num14 int `json:"14"` + Num15 int `json:"15"` + Num16 int `json:"16"` + Num17 int `json:"17"` + Num19 int `json:"19"` + Num20 int `json:"20"` + Num21 int `json:"21"` + Num22 int `json:"22"` + Num23 int `json:"23"` + Num24 int `json:"24"` + Num26 int `json:"26"` + Num27 int `json:"27"` + Num28 int `json:"28"` + Num29 string `json:"29"` + + // 30 - WiFi SSID + WiFiSSID string `json:"30"` + + // 31 - Number of clients connected to the camera + NumberOfClients int `json:"31"` + + // 32 - Streaming feed status: + // 0 = Not Streaming + // 1 = Streaming + StreamingFeed int `json:"32"` + + // 33 - SD card inserted: + // 0 = SD card inserted + // 2 = No SD Card present + SDcardInserted int `json:"33"` + + // 34 - Remaining Photos + RemainingPhotos int `json:"34"` + + // 35 - Remaining Video Time + RemainingVideoTime int `json:"35"` + + // 36 - Number of Batch Photos taken (Example: TimeLapse batches, burst batches, continouous photo batches...) + NumberOfBatchPhotos int `json:"36"` + + // 37 - Number of videos shot + NumberOfVideos int `json:"37"` + + // 38 - Number of ALL photos taken + Num38 int `json:"38"` + + // 39 - Number of MultiShot pictures taken + // 39 - Number of ALL videos taken + // 8 = Recording/Processing status: + // 0 = Not recording/Processing + // 1 = Recording/processing + Num39 int `json:"39"` + Num40 string `json:"40"` + Num41 int `json:"41"` + Num42 int `json:"42"` + + // 43 - Current Mode: + // Video - 0 + // Photo - 1 + // MultiShot - 2 + CurrentMode int `json:"43"` + + // 44 - Current SubMode + // 0 = Video/Single Pic/Burst + // 1 = TL Video/Continuous/TimeLapse + // 2 = Video+Photo/NightPhoto/NightLapse + CurrentSubMode int `json:"44"` + + Num45 int `json:"45"` + Num46 int `json:"46"` + Num47 int `json:"47"` + Num48 int `json:"48"` + Num49 int `json:"49"` + + // 54 - Remaning free space on memorycard in bytes + RemaningFreeSpace int `json:"54"` + + Num55 int `json:"55"` + Num56 int `json:"56"` + Num57 int `json:"57"` + Num58 int `json:"58"` + Num59 int `json:"59"` + Num60 int `json:"60"` + Num61 int `json:"61"` + Num62 int `json:"62"` + Num63 int `json:"63"` + Num64 int `json:"64"` + Num65 int `json:"65"` + Num66 int `json:"66"` + Num67 int `json:"67"` + Num68 int `json:"68"` + Num69 int `json:"69"` + + // 70 - Battery Percentage + BatteryPercentage int `json:"70"` + + Num71 int `json:"71"` + Num72 int `json:"72"` + Num73 int `json:"73"` + Num74 int `json:"74"` } -type goProCameraStatus struct { - status goProStatus `json:"status"` - settings goProSettings `json:"settings"` +// CurrentSettings ... +type CurrentSettings struct { + Num1 int `json:"1"` + + // 2 - Video Resolutions + // 1 = 4K + // 4 = 2.7K: http://10.5.5.9/gp/gpControl/setting/2/4 + // 6 = 2.7K 4:3: http://10.5.5.9/gp/gpControl/setting/2/6 + // 7 = 1440p: http://10.5.5.9/gp/gpControl/setting/2/7 + // 9 = 1080p: http://10.5.5.9/gp/gpControl/setting/2/9 + // 10 = 960p: http://10.5.5.9/gp/gpControl/setting/2/10 + // 12 = 720p: http://10.5.5.9/gp/gpControl/setting/2/12 + // 17 = WVGA: http://10.5.5.9/gp/gpControl/setting/2/17 + VideoResolutions int `json:"2"` + + // 3 - Frame Rate + // 0 = 240fps: http://10.5.5.9/gp/gpControl/setting/3/0 + // 1 = 120fps: http://10.5.5.9/gp/gpControl/setting/3/1 + // 2 = 100fps: http://10.5.5.9/gp/gpControl/setting/3/2 + // 3 = 90fps: http://10.5.5.9/gp/gpControl/setting/3/3 + // 4 = 80fps: http://10.5.5.9/gp/gpControl/setting/3/4 + // 5 = 60fps: http://10.5.5.9/gp/gpControl/setting/3/5 + // 6 = 50fps: http://10.5.5.9/gp/gpControl/setting/3/6 + // 7 = 48fps: http://10.5.5.9/gp/gpControl/setting/3/7 + // 8 = 30fps: http://10.5.5.9/gp/gpControl/setting/3/8 + // 9 = 25fps: http://10.5.5.9/gp/gpControl/setting/3/9 + FrameRate int `json:"3"` + + // 4 - Field of View + // 0 = Wide: http://10.5.5.9/gp/gpControl/setting/4/0 + // 1 = Medium: http://10.5.5.9/gp/gpControl/setting/4/1 + // 2 = Narrow: http://10.5.5.9/gp/gpControl/setting/4/2 + // 3 = SuperView: http://10.5.5.9/gp/gpControl/4/3 + // 4 = Linear: http://10.5.5.9/gp/gpControl/setting/4/4 + FOV int `json:"4"` + + // 5 - Video Timelapse Interval: + // 0 = 0.5: http://10.5.5.9/gp/gpControl/setting/5/0 + // 1 = 1: http://10.5.5.9/gp/gpControl/setting/5/1 + // 2 = 2: http://10.5.5.9/gp/gpControl/setting/5/2 + // 3 = 5: http://10.5.5.9/gp/gpControl/setting/5/3 + // 4 = 10: http://10.5.5.9/gp/gpControl/setting/5/4 + // 5 = 30: http://10.5.5.9/gp/gpControl/setting/5/5 + // 6 = 60: http://10.5.5.9/gp/gpControl/setting/5/6 + VideoTimelapseInterval int `json:"5"` + + // 6 - Video Looping Duration: + // 0 = Max: http://10.5.5.9/gp/gpControl/setting/6/0 + // 1 = 5Min: http://10.5.5.9/gp/gpControl/setting/6/1 + // 2 = 20Min: http://10.5.5.9/gp/gpControl/setting/6/2 + // 3 = 60Min: http://10.5.5.9/gp/gpControl/setting/6/3 + // 4 = 120Min: http://10.5.5.9/gp/gpControl/setting/6/4 + VideoLoopingDuration int `json:"6"` + + // 7 - Video+Photo Interval: + // 1 = 5: http://10.5.5.9/gp/gpControl/setting/7/1 + // 2 = 10: http://10.5.5.9/gp/gpControl/setting/7/2 + // 3 = 30: http://10.5.5.9/gp/gpControl/setting/7/3 + // 4 = 60Min: http://10.5.5.9/gp/gpControl/setting/7/4 + VideoPhotoInterval int `json:"7"` + + // 8 - Low Light + // 0 = OFF: http://10.5.5.9/gp/gpControl/setting/8/0 + // 1 = ON: http://10.5.5.9/gp/gpControl/setting/8/1 + LowLight int `json:"8"` + + // 9 - Spot Meter: + // 0 = off: http://10.5.5.9/gp/gpControl/setting/9/0 + // 1 = on: http://10.5.5.9/gp/gpControl/setting/9/1 + SpotMeter int `json:"9"` + + // https://github.com/KonradIT/goprowifihack/blob/master/HERO5/HERO5-Commands.md + Num10 int `json:"10"` + Num11 int `json:"11"` + Num12 int `json:"12"` + Num13 int `json:"13"` + Num14 int `json:"14"` + Num15 int `json:"15"` + Num16 int `json:"16"` + Num17 int `json:"17"` + Num18 int `json:"18"` + Num19 int `json:"19"` + Num20 int `json:"20"` + Num21 int `json:"21"` + Num22 int `json:"22"` + Num23 int `json:"23"` + Num24 int `json:"24"` + Num25 int `json:"25"` + Num26 int `json:"26"` + Num27 int `json:"27"` + Num28 int `json:"28"` + Num29 int `json:"29"` + Num30 int `json:"30"` + Num31 int `json:"31"` + Num32 int `json:"32"` + Num33 int `json:"33"` + Num34 int `json:"34"` + Num35 int `json:"35"` + Num36 int `json:"36"` + Num37 int `json:"37"` + Num38 int `json:"38"` + Num39 int `json:"39"` + Num40 int `json:"40"` + Num41 int `json:"41"` + Num42 int `json:"42"` + + // 43 - Primary modes + // 0 = Video: http://10.5.5.9/gp/gpControl/command/mode?p=0 + // 1 = Photo: http://10.5.5.9/gp/gpControl/command/mode?p=1 + // 2 = MultiShot: http://10.5.5.9/gp/gpControl/command/mode?p=2 + PrimaryMode int `json:"43"` + + // 44 - Secondary modes + // 0 = Video (VIDEO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=0 + // 1 = TimeLapse Video (VIDEO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=1 + // 2 = Video + Photo (VIDEO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=2 + // 3 = Looping (VIDEO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=0&sub_mode=3 + + // 1 = Single (PHOTO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=1&sub_mode=1 + // 2 = Night (PHOTO): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=1&sub_mode=2 + + // 0 = Burst (MultiShot): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=2&sub_mode=0 + // 1 = Timelapse (MultiShot): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=2&sub_mode=1 + // 2 = NightLapse (MultiShot): http://10.5.5.9/gp/gpControl/command/sub_mode?mode=2&sub_mode=2 + SecondaryModes int `json:"44"` + + Num45 int `json:"45"` + Num46 int `json:"46"` + Num47 int `json:"47"` + Num48 int `json:"48"` + Num50 int `json:"50"` + Num51 int `json:"51"` + Num52 int `json:"52"` + Num54 int `json:"54"` + Num57 int `json:"57"` + Num58 int `json:"58"` + Num59 int `json:"59"` + Num60 int `json:"60"` + Num61 int `json:"61"` + Num62 int `json:"62"` + Num63 int `json:"63"` + Num64 int `json:"64"` + Num65 int `json:"65"` + Num66 int `json:"66"` + Num67 int `json:"67"` + Num68 int `json:"68"` + Num69 int `json:"69"` + Num70 int `json:"70"` + Num71 int `json:"71"` + Num72 int `json:"72"` + Num73 int `json:"73"` + Num74 int `json:"74"` + Num75 int `json:"75"` + Num76 int `json:"76"` + Num77 int `json:"77"` + Num78 int `json:"78"` + Num79 int `json:"79"` + Num80 int `json:"80"` + Num81 int `json:"81"` + Num82 int `json:"82"` + Num83 int `json:"83"` + Num84 int `json:"84"` + Num85 int `json:"85"` + Num86 int `json:"86"` + Num87 int `json:"87"` + Num88 int `json:"88"` + Num89 int `json:"89"` + Num91 int `json:"91"` + Num92 int `json:"92"` + Num93 int `json:"93"` + Num94 int `json:"94"` + Num95 int `json:"95"` + Num96 int `json:"96"` + Num97 int `json:"97"` + Num98 int `json:"98"` + Num99 int `json:"99"` } From e57863c738063f658d44e4775e613a5275f80289 Mon Sep 17 00:00:00 2001 From: Daktak Date: Tue, 10 Jan 2023 16:28:45 +1100 Subject: [PATCH 05/13] update --- cmd/info.go | 57 ++++++++++++++++++++++++++++++++++++++++++++++- pkg/gopro/info.go | 9 +++----- 2 files changed, 59 insertions(+), 7 deletions(-) diff --git a/cmd/info.go b/cmd/info.go index 5897ff0..1f18ae7 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -1,6 +1,8 @@ package cmd import ( + "fmt" + "github.com/erdaltsksn/cui" "github.com/konradit/mmt/pkg/gopro" "github.com/konradit/mmt/pkg/utils" @@ -29,12 +31,65 @@ var infoCmd = &cobra.Command{ } switch c { case utils.GoPro: - err = gopro.GetInfo(input) + var gpStatus = gopro.CameraStatus{} + gpStatus, err = gopro.GetInfo(input) + fmt.Printf("SSID : %s\n", gpStatus.Status.WiFiSSID) + currentMode := gpStatus.Status.CurrentMode + var modeName = "Video" + var whiteBal = gpStatus.Settings.Num11 + var isoMode = gpStatus.Settings.Num74 + var isoLimit = gpStatus.Settings.Num13 + var isoMin = 0 + var proTune = gpStatus.Settings.Num10 + switch currentMode { + case 1: + modeName = "Photo" + whiteBal = gpStatus.Settings.Num22 + isoMin = gpStatus.Settings.Num75 + isoLimit = gpStatus.Settings.Num24 + proTune = gpStatus.Settings.Num21 + case 2: + modeName = "MultiShot" + whiteBal = gpStatus.Settings.Num35 + isoMin = gpStatus.Settings.Num76 + isoLimit = gpStatus.Settings.Num37 + proTune = gpStatus.Settings.Num34 + } + fmt.Printf("Mode : %s\n", modeName) + fmt.Printf("White Balance : %t\n", whiteBal != 0) + if currentMode == 0 { + var isoText = "" + if isoMode == 1 { + isoText = "Lock" + } else { + isoText = "Max" + } + fmt.Printf("ISO Mode : %s\n", isoText) + } else { + fmt.Printf("ISO Min : %d\n", getISO(isoMin)) + } + fmt.Printf("ISO Limit : %d\n", getISO(isoLimit)) + fmt.Printf("Protune : %t\n", proTune != 0) } } }, } +func getISO(in int) int { + switch in { + case 0: + return 800 + case 1: + return 400 + case 2: + return 200 + case 3: + return 100 + default: + return 0 + } +} + func init() { rootCmd.AddCommand(infoCmd) infoCmd.Flags().StringP("input", "i", "", "Input IP Address") diff --git a/pkg/gopro/info.go b/pkg/gopro/info.go index 52c4586..d486065 100644 --- a/pkg/gopro/info.go +++ b/pkg/gopro/info.go @@ -3,7 +3,6 @@ package gopro /* GoPro Connect - API exposed over USB Ethernet */ import ( - "fmt" /* mErrors "github.com/konradit/mmt/pkg/errors" "github.com/konradit/mmt/pkg/utils" @@ -11,14 +10,12 @@ import ( */ ) -func GetInfo(in string) error { +func GetInfo(in string) (CameraStatus, error) { var gpStatus = &CameraStatus{} err := caller(in, "gp/gpControl/status", gpStatus) if err != nil { - fmt.Println(err) - return err + return *gpStatus, err } - fmt.Println(gpStatus) - return nil + return *gpStatus, nil } From 8665a8b7bfe925f7f5bbb3845f59badaff540621 Mon Sep 17 00:00:00 2001 From: Daktak Date: Tue, 10 Jan 2023 16:59:13 +1100 Subject: [PATCH 06/13] gopro move settings --- cmd/info.go | 22 +++------------ pkg/gopro/info.go | 68 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+), 18 deletions(-) diff --git a/cmd/info.go b/cmd/info.go index 1f18ae7..a7253c2 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -56,8 +56,9 @@ var infoCmd = &cobra.Command{ proTune = gpStatus.Settings.Num34 } fmt.Printf("Mode : %s\n", modeName) - fmt.Printf("White Balance : %t\n", whiteBal != 0) + fmt.Printf("White Balance : %s\n", gopro.GetWhiteBalance(whiteBal)) if currentMode == 0 { + fmt.Printf("Resolution : %s\n", gopro.GetVidRes(gpStatus.Settings.VideoResolutions)) var isoText = "" if isoMode == 1 { isoText = "Lock" @@ -66,30 +67,15 @@ var infoCmd = &cobra.Command{ } fmt.Printf("ISO Mode : %s\n", isoText) } else { - fmt.Printf("ISO Min : %d\n", getISO(isoMin)) + fmt.Printf("ISO Min : %d\n", gopro.GetISO(isoMin)) } - fmt.Printf("ISO Limit : %d\n", getISO(isoLimit)) + fmt.Printf("ISO Limit : %d\n", gopro.GetISO(isoLimit)) fmt.Printf("Protune : %t\n", proTune != 0) } } }, } -func getISO(in int) int { - switch in { - case 0: - return 800 - case 1: - return 400 - case 2: - return 200 - case 3: - return 100 - default: - return 0 - } -} - func init() { rootCmd.AddCommand(infoCmd) infoCmd.Flags().StringP("input", "i", "", "Input IP Address") diff --git a/pkg/gopro/info.go b/pkg/gopro/info.go index d486065..54b2ad0 100644 --- a/pkg/gopro/info.go +++ b/pkg/gopro/info.go @@ -19,3 +19,71 @@ func GetInfo(in string) (CameraStatus, error) { return *gpStatus, nil } +func GetISO(in int) int { + switch in { + case 0: + return 800 + case 1: + return 400 + case 2: + return 200 + case 3: + return 100 + default: + return 0 + } +} + +func GetVidRes(in int) string { + switch in{ + case 1: + return "4K" + case 2: + return "4K SuperView" + case 4: + return "2.7K" + case 5: + return "2.7K SuperView" + case 6: + return "2.7K 4:3" + case 7: + return "1440" + case 8: + return "1080 SuperView" + case 9: + return "1080" + case 10: + return "960" + case 11: + return "720 SuperView" + case 12: + return "720" + case 13: + return "WVGA" + default: + return "" + } +} + +func GetWhiteBalance(in int) string { + switch in{ + case 0: + return "Auto" + case 1: + return "3000K" + case 5: + return "4000K" + case 6: + return "4800K" + case 2: + return "5500K" + case 7: + return "6000K" + case 3: + return "6500K" + case 4: + return "Native" + default: + return "" + } +} From 4047d4a60be993ccba06dd6d3482d48bdab198d9 Mon Sep 17 00:00:00 2001 From: daktak Date: Tue, 10 Jan 2023 21:19:37 +1100 Subject: [PATCH 07/13] Update detect.go Fix test code --- pkg/gopro/detect.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pkg/gopro/detect.go b/pkg/gopro/detect.go index 4b8736f..96603bb 100644 --- a/pkg/gopro/detect.go +++ b/pkg/gopro/detect.go @@ -1,8 +1,7 @@ package gopro import ( - "fmt" - mErrors "github.com/konradit/mmt/pkg/errors" + mErrors "github.com/konradit/mmt/pkg/errors" "github.com/konradit/mmt/pkg/utils" "github.com/shirou/gopsutil/disk" ) @@ -29,6 +28,3 @@ func Detect() (string, utils.ConnectionType, error) { return "", "", mErrors.ErrNoCameraDetected } -func Test() { - fmt.Println("aa") -} From 349251a6b41a4784ce630746f5f45a0d109230c6 Mon Sep 17 00:00:00 2001 From: Daktak Date: Wed, 11 Jan 2023 09:16:24 +1100 Subject: [PATCH 08/13] sd_card or connection --- cmd/info.go | 83 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 47 insertions(+), 36 deletions(-) diff --git a/cmd/info.go b/cmd/info.go index a7253c2..cac49a5 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -31,46 +31,56 @@ var infoCmd = &cobra.Command{ } switch c { case utils.GoPro: - var gpStatus = gopro.CameraStatus{} - gpStatus, err = gopro.GetInfo(input) - fmt.Printf("SSID : %s\n", gpStatus.Status.WiFiSSID) - currentMode := gpStatus.Status.CurrentMode - var modeName = "Video" - var whiteBal = gpStatus.Settings.Num11 - var isoMode = gpStatus.Settings.Num74 - var isoLimit = gpStatus.Settings.Num13 - var isoMin = 0 - var proTune = gpStatus.Settings.Num10 - switch currentMode { - case 1: - modeName = "Photo" - whiteBal = gpStatus.Settings.Num22 - isoMin = gpStatus.Settings.Num75 - isoLimit = gpStatus.Settings.Num24 - proTune = gpStatus.Settings.Num21 - case 2: - modeName = "MultiShot" - whiteBal = gpStatus.Settings.Num35 - isoMin = gpStatus.Settings.Num76 - isoLimit = gpStatus.Settings.Num37 - proTune = gpStatus.Settings.Num34 + if customCameraOpts["connection"] == "" { + connection := getFlagString(cmd, "connection") + if connection == "" { + connection = "sd_card" + } + customCameraOpts["connection"] = connection } - fmt.Printf("Mode : %s\n", modeName) - fmt.Printf("White Balance : %s\n", gopro.GetWhiteBalance(whiteBal)) - if currentMode == 0 { - fmt.Printf("Resolution : %s\n", gopro.GetVidRes(gpStatus.Settings.VideoResolutions)) - var isoText = "" - if isoMode == 1 { - isoText = "Lock" + switch customCameraOpts["connection"] { + case "connect": + var gpStatus = gopro.CameraStatus{} + gpStatus, err = gopro.GetInfo(input) + fmt.Printf("SSID : %s\n", gpStatus.Status.WiFiSSID) + currentMode := gpStatus.Status.CurrentMode + var modeName = "Video" + var whiteBal = gpStatus.Settings.Num11 + var isoMode = gpStatus.Settings.Num74 + var isoLimit = gpStatus.Settings.Num13 + var isoMin = 0 + var proTune = gpStatus.Settings.Num10 + switch currentMode { + case 1: + modeName = "Photo" + whiteBal = gpStatus.Settings.Num22 + isoMin = gpStatus.Settings.Num75 + isoLimit = gpStatus.Settings.Num24 + proTune = gpStatus.Settings.Num21 + case 2: + modeName = "MultiShot" + whiteBal = gpStatus.Settings.Num35 + isoMin = gpStatus.Settings.Num76 + isoLimit = gpStatus.Settings.Num37 + proTune = gpStatus.Settings.Num34 + } + fmt.Printf("Mode : %s\n", modeName) + fmt.Printf("White Balance : %s\n", gopro.GetWhiteBalance(whiteBal)) + if currentMode == 0 { + fmt.Printf("Resolution : %s\n", gopro.GetVidRes(gpStatus.Settings.VideoResolutions)) + var isoText = "" + if isoMode == 1 { + isoText = "Lock" + } else { + isoText = "Max" + } + fmt.Printf("ISO Mode : %s\n", isoText) } else { - isoText = "Max" + fmt.Printf("ISO Min : %d\n", gopro.GetISO(isoMin)) } - fmt.Printf("ISO Mode : %s\n", isoText) - } else { - fmt.Printf("ISO Min : %d\n", gopro.GetISO(isoMin)) + fmt.Printf("ISO Limit : %d\n", gopro.GetISO(isoLimit)) + fmt.Printf("Protune : %t\n", proTune != 0) } - fmt.Printf("ISO Limit : %d\n", gopro.GetISO(isoLimit)) - fmt.Printf("Protune : %t\n", proTune != 0) } } }, @@ -80,4 +90,5 @@ func init() { rootCmd.AddCommand(infoCmd) infoCmd.Flags().StringP("input", "i", "", "Input IP Address") infoCmd.Flags().StringP("camera", "c", "", "Camera type") + importCmd.Flags().StringP("connection", "x", "", "Connexion type: `sd_card`, `connect` (GoPro-specific)") } From a5f1867785a2e48ad4c357e1619f87eed2a3b4a0 Mon Sep 17 00:00:00 2001 From: Daktak Date: Wed, 11 Jan 2023 09:33:46 +1100 Subject: [PATCH 09/13] add sd_card placeholder --- cmd/info.go | 88 +++++++++++++++++++++++++++++------------------------ 1 file changed, 48 insertions(+), 40 deletions(-) diff --git a/cmd/info.go b/cmd/info.go index cac49a5..88d0a16 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -40,52 +40,60 @@ var infoCmd = &cobra.Command{ } switch customCameraOpts["connection"] { case "connect": - var gpStatus = gopro.CameraStatus{} - gpStatus, err = gopro.GetInfo(input) - fmt.Printf("SSID : %s\n", gpStatus.Status.WiFiSSID) - currentMode := gpStatus.Status.CurrentMode - var modeName = "Video" - var whiteBal = gpStatus.Settings.Num11 - var isoMode = gpStatus.Settings.Num74 - var isoLimit = gpStatus.Settings.Num13 - var isoMin = 0 - var proTune = gpStatus.Settings.Num10 - switch currentMode { - case 1: - modeName = "Photo" - whiteBal = gpStatus.Settings.Num22 - isoMin = gpStatus.Settings.Num75 - isoLimit = gpStatus.Settings.Num24 - proTune = gpStatus.Settings.Num21 - case 2: - modeName = "MultiShot" - whiteBal = gpStatus.Settings.Num35 - isoMin = gpStatus.Settings.Num76 - isoLimit = gpStatus.Settings.Num37 - proTune = gpStatus.Settings.Num34 - } - fmt.Printf("Mode : %s\n", modeName) - fmt.Printf("White Balance : %s\n", gopro.GetWhiteBalance(whiteBal)) - if currentMode == 0 { - fmt.Printf("Resolution : %s\n", gopro.GetVidRes(gpStatus.Settings.VideoResolutions)) - var isoText = "" - if isoMode == 1 { - isoText = "Lock" - } else { - isoText = "Max" - } - fmt.Printf("ISO Mode : %s\n", isoText) - } else { - fmt.Printf("ISO Min : %d\n", gopro.GetISO(isoMin)) - } - fmt.Printf("ISO Limit : %d\n", gopro.GetISO(isoLimit)) - fmt.Printf("Protune : %t\n", proTune != 0) + printGpStatus(input) + /* + case "sd_card": + do gmpf extract here + */ } } } }, } +func printGpStatus(input string) { + var gpStatus = gopro.CameraStatus{} + gpStatus, _ = gopro.GetInfo(input) + fmt.Printf("SSID : %s\n", gpStatus.Status.WiFiSSID) + currentMode := gpStatus.Status.CurrentMode + var modeName = "Video" + var whiteBal = gpStatus.Settings.Num11 + var isoMode = gpStatus.Settings.Num74 + var isoLimit = gpStatus.Settings.Num13 + var isoMin = 0 + var proTune = gpStatus.Settings.Num10 + switch currentMode { + case 1: + modeName = "Photo" + whiteBal = gpStatus.Settings.Num22 + isoMin = gpStatus.Settings.Num75 + isoLimit = gpStatus.Settings.Num24 + proTune = gpStatus.Settings.Num21 + case 2: + modeName = "MultiShot" + whiteBal = gpStatus.Settings.Num35 + isoMin = gpStatus.Settings.Num76 + isoLimit = gpStatus.Settings.Num37 + proTune = gpStatus.Settings.Num34 + } + fmt.Printf("Mode : %s\n", modeName) + fmt.Printf("White Balance : %s\n", gopro.GetWhiteBalance(whiteBal)) + if currentMode == 0 { + fmt.Printf("Resolution : %s\n", gopro.GetVidRes(gpStatus.Settings.VideoResolutions)) + var isoText = "" + if isoMode == 1 { + isoText = "Lock" + } else { + isoText = "Max" + } + fmt.Printf("ISO Mode : %s\n", isoText) + } else { + fmt.Printf("ISO Min : %d\n", gopro.GetISO(isoMin)) + } + fmt.Printf("ISO Limit : %d\n", gopro.GetISO(isoLimit)) + fmt.Printf("Protune : %t\n", proTune != 0) +} + func init() { rootCmd.AddCommand(infoCmd) infoCmd.Flags().StringP("input", "i", "", "Input IP Address") From eee46c3573b8a589369687670e0fa00219c7b8c3 Mon Sep 17 00:00:00 2001 From: Daktak Date: Wed, 11 Jan 2023 09:49:12 +1100 Subject: [PATCH 10/13] gci --- pkg/gopro/detect.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/gopro/detect.go b/pkg/gopro/detect.go index 96603bb..565be2c 100644 --- a/pkg/gopro/detect.go +++ b/pkg/gopro/detect.go @@ -1,7 +1,7 @@ package gopro import ( - mErrors "github.com/konradit/mmt/pkg/errors" + mErrors "github.com/konradit/mmt/pkg/errors" "github.com/konradit/mmt/pkg/utils" "github.com/shirou/gopsutil/disk" ) From d65e34764dc3a96d2a9f68414e35e288f1a3d226 Mon Sep 17 00:00:00 2001 From: Daktak Date: Wed, 11 Jan 2023 10:05:28 +1100 Subject: [PATCH 11/13] getFileInfo --- cmd/info.go | 6 +- pkg/gopro/info.go | 138 ++++++++++++++++++++++++++++------------------ 2 files changed, 87 insertions(+), 57 deletions(-) diff --git a/cmd/info.go b/cmd/info.go index 88d0a16..d1a7414 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -41,10 +41,8 @@ var infoCmd = &cobra.Command{ switch customCameraOpts["connection"] { case "connect": printGpStatus(input) - /* - case "sd_card": - do gmpf extract here - */ + case "sd_card": + gopro.GetFileInfo(input) } } } diff --git a/pkg/gopro/info.go b/pkg/gopro/info.go index 54b2ad0..c22197e 100644 --- a/pkg/gopro/info.go +++ b/pkg/gopro/info.go @@ -3,20 +3,23 @@ package gopro /* GoPro Connect - API exposed over USB Ethernet */ import ( - /* + "fmt" + "os" + "path/filepath" + "strings" + + "github.com/fatih/color" mErrors "github.com/konradit/mmt/pkg/errors" "github.com/konradit/mmt/pkg/utils" - "github.com/shirou/gopsutil/disk" - */ ) func GetInfo(in string) (CameraStatus, error) { var gpStatus = &CameraStatus{} err := caller(in, "gp/gpControl/status", gpStatus) if err != nil { - return *gpStatus, err + return *gpStatus, err } - return *gpStatus, nil + return *gpStatus, nil } func GetISO(in int) int { @@ -35,55 +38,84 @@ func GetISO(in int) int { } func GetVidRes(in int) string { - switch in{ - case 1: - return "4K" - case 2: - return "4K SuperView" - case 4: - return "2.7K" - case 5: - return "2.7K SuperView" - case 6: - return "2.7K 4:3" - case 7: - return "1440" - case 8: - return "1080 SuperView" - case 9: - return "1080" - case 10: - return "960" - case 11: - return "720 SuperView" - case 12: - return "720" - case 13: - return "WVGA" - default: - return "" - } + switch in { + case 1: + return "4K" + case 2: + return "4K SuperView" + case 4: + return "2.7K" + case 5: + return "2.7K SuperView" + case 6: + return "2.7K 4:3" + case 7: + return "1440" + case 8: + return "1080 SuperView" + case 9: + return "1080" + case 10: + return "960" + case 11: + return "720 SuperView" + case 12: + return "720" + case 13: + return "WVGA" + default: + return "" + } } func GetWhiteBalance(in int) string { - switch in{ - case 0: - return "Auto" - case 1: - return "3000K" - case 5: - return "4000K" - case 6: - return "4800K" - case 2: - return "5500K" - case 7: - return "6000K" - case 3: - return "6500K" - case 4: - return "Native" - default: - return "" - } + switch in { + case 0: + return "Auto" + case 1: + return "3000K" + case 5: + return "4000K" + case 6: + return "4800K" + case 2: + return "5500K" + case 7: + return "6000K" + case 3: + return "6500K" + case 4: + return "Native" + default: + return "" + } +} + +func GetFileInfo(in string) (*utils.Result, error) { + var result utils.Result + versionContent, err := os.ReadFile(filepath.Join(in, "MISC", fmt.Sprint(Version))) + if err != nil { + return nil, err + } + + gpVersion, err := readInfo(versionContent) + if err != nil { + return nil, err + } + + c := color.New(color.FgCyan) + y := color.New(color.FgHiBlue) + color.Cyan("šŸŽ„ [%s]:", gpVersion.CameraType) + c.Printf("\tšŸ“¹ FW: %s ", gpVersion.FirmwareVersion) + y.Printf("SN: %s\n", gpVersion.CameraSerialNumber) + root := strings.Split(gpVersion.FirmwareVersion, ".")[0] + + switch root { + case "HD6", "HD7", "HD8", "H19", "HD9", "H21", "H22": + return &result, nil + case "HD2", "HD3", "HD4", "HX", "HD5": + return &result, nil + default: + return nil, mErrors.ErrUnsupportedCamera(gpVersion.CameraType) + } } From 4319ba2e27f32b4b2e06eebb331e888525efacb1 Mon Sep 17 00:00:00 2001 From: Daktak Date: Wed, 11 Jan 2023 11:06:17 +1100 Subject: [PATCH 12/13] get lat long --- cmd/info.go | 4 ++-- pkg/gopro/info.go | 33 ++++----------------------------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/cmd/info.go b/cmd/info.go index d1a7414..5ce865c 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -41,7 +41,7 @@ var infoCmd = &cobra.Command{ switch customCameraOpts["connection"] { case "connect": printGpStatus(input) - case "sd_card": + default: gopro.GetFileInfo(input) } } @@ -96,5 +96,5 @@ func init() { rootCmd.AddCommand(infoCmd) infoCmd.Flags().StringP("input", "i", "", "Input IP Address") infoCmd.Flags().StringP("camera", "c", "", "Camera type") - importCmd.Flags().StringP("connection", "x", "", "Connexion type: `sd_card`, `connect` (GoPro-specific)") + infoCmd.Flags().StringP("connection", "x", "", "Connexion type: `sd_card`, `connect` (GoPro-specific)") } diff --git a/pkg/gopro/info.go b/pkg/gopro/info.go index c22197e..4453614 100644 --- a/pkg/gopro/info.go +++ b/pkg/gopro/info.go @@ -4,12 +4,7 @@ package gopro import ( "fmt" - "os" - "path/filepath" - "strings" - "github.com/fatih/color" - mErrors "github.com/konradit/mmt/pkg/errors" "github.com/konradit/mmt/pkg/utils" ) @@ -93,29 +88,9 @@ func GetWhiteBalance(in int) string { func GetFileInfo(in string) (*utils.Result, error) { var result utils.Result - versionContent, err := os.ReadFile(filepath.Join(in, "MISC", fmt.Sprint(Version))) - if err != nil { - return nil, err - } - - gpVersion, err := readInfo(versionContent) - if err != nil { - return nil, err - } - - c := color.New(color.FgCyan) - y := color.New(color.FgHiBlue) - color.Cyan("šŸŽ„ [%s]:", gpVersion.CameraType) - c.Printf("\tšŸ“¹ FW: %s ", gpVersion.FirmwareVersion) - y.Printf("SN: %s\n", gpVersion.CameraSerialNumber) - root := strings.Split(gpVersion.FirmwareVersion, ".")[0] - - switch root { - case "HD6", "HD7", "HD8", "H19", "HD9", "H21", "H22": - return &result, nil - case "HD2", "HD3", "HD4", "HX", "HD5": - return &result, nil - default: - return nil, mErrors.ErrUnsupportedCamera(gpVersion.CameraType) + returned, err := fromMP4(in) + if returned != nil { + fmt.Printf("\n\treturned: %f %f\n", returned.Latitude, returned.Longitude) } + return &result, err } From 95fd9596e0ae5c3c644db88735c814c5461c31c4 Mon Sep 17 00:00:00 2001 From: Daktak Date: Wed, 11 Jan 2023 12:10:34 +1100 Subject: [PATCH 13/13] gci --- cmd/info.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/info.go b/cmd/info.go index 5ce865c..b5512fe 100644 --- a/cmd/info.go +++ b/cmd/info.go @@ -41,7 +41,7 @@ var infoCmd = &cobra.Command{ switch customCameraOpts["connection"] { case "connect": printGpStatus(input) - default: + default: gopro.GetFileInfo(input) } }