Skip to content

Info command to print GoPro settings #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: development
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
getFileInfo
  • Loading branch information
daktak committed Jan 10, 2023
commit d65e34764dc3a96d2a9f68414e35e288f1a3d226
6 changes: 2 additions & 4 deletions cmd/info.go
Original file line number Diff line number Diff line change
@@ -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)
}
}
}
138 changes: 85 additions & 53 deletions pkg/gopro/info.go
Original file line number Diff line number Diff line change
@@ -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)
}
}