extracting data from the exe files
This commit is contained in:
68
packages.go
68
packages.go
@@ -1,19 +1,27 @@
|
||||
package main
|
||||
|
||||
import(
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"regexp"
|
||||
"os"
|
||||
"os/exec"
|
||||
"strconv"
|
||||
)
|
||||
|
||||
type packages struct{
|
||||
Id string
|
||||
Name string
|
||||
Version string
|
||||
// packages struct represents a package with its details.
|
||||
type packages struct {
|
||||
Id string
|
||||
Name string
|
||||
Version string
|
||||
ExtraCommand *string
|
||||
Tag string
|
||||
Warning bool
|
||||
Element *elements
|
||||
Tag string
|
||||
Warning bool
|
||||
Element *elements
|
||||
}
|
||||
|
||||
// ConvertStringsToPackage converts a slice of strings to a packages struct.
|
||||
// It returns an error if the input slice does not have exactly 6 elements or if the Warning value cannot be parsed as a boolean.
|
||||
func ConvertStringsToPackage(strs []string) (packages, error) {
|
||||
var pkg packages
|
||||
if len(strs) != 6 {
|
||||
@@ -34,18 +42,44 @@ func ConvertStringsToPackage(strs []string) (packages, error) {
|
||||
Warning: warning,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// elements struct represents the elements of a the webpage.
|
||||
type elements struct {
|
||||
Title string
|
||||
Header string
|
||||
Help string
|
||||
Packagename string
|
||||
Title string
|
||||
Header string
|
||||
Help string
|
||||
Packagename string
|
||||
Packageversion string
|
||||
Allow string
|
||||
Warning string
|
||||
Explain string
|
||||
Allow string
|
||||
Warning string
|
||||
Explain string
|
||||
}
|
||||
|
||||
// DownloadElements struct represents the elements to be downloaded.
|
||||
type DownloadElements struct {
|
||||
ID string
|
||||
ID string
|
||||
Version *string
|
||||
Counter int
|
||||
}
|
||||
}
|
||||
|
||||
// Printer struct is an empty struct. Its purpose is not clear from the provided code.
|
||||
type Printer struct{}
|
||||
|
||||
// getParamsFromExif extracts EXIF parameters from a file at the given path using the exiftool command.
|
||||
// It returns a map where the keys are the EXIF parameter names and the values are the corresponding EXIF parameter values.
|
||||
func getParamsFromExif(path string) map[string]string{
|
||||
exiftool := os.Getenv("exiftool")
|
||||
e,_ := exec.Command(exiftool, "-f", path).Output()
|
||||
tags:=make(map[string]string)
|
||||
spliter:=regexp.MustCompile(`\r?\n`)
|
||||
crop:=spliter.Split(string(e),-1)
|
||||
head := regexp.MustCompile(`\s+:\s`)
|
||||
for _,c := range crop{
|
||||
if(len(c)>1){
|
||||
data:=head.Split(c,-1)
|
||||
log.Println("My Raw Data: ", c)
|
||||
tags[data[0]]=data[1]}
|
||||
}
|
||||
log.Println(tags)
|
||||
return tags
|
||||
}
|
||||
|
Reference in New Issue
Block a user