2020-01-07 17:36:49 +01:00
|
|
|
package meta
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
)
|
|
|
|
|
2020-01-07 18:13:53 +01:00
|
|
|
// XMP parses an XMP file and returns a Data struct.
|
2020-01-07 17:36:49 +01:00
|
|
|
func XMP(filename string) (data Data, err error) {
|
|
|
|
defer func() {
|
|
|
|
if e := recover(); e != nil {
|
|
|
|
data = Data{}
|
|
|
|
err = fmt.Errorf("meta: %s", e)
|
|
|
|
}
|
|
|
|
}()
|
|
|
|
|
2020-01-13 23:14:10 +01:00
|
|
|
doc := XmpDocument{}
|
2020-01-07 17:36:49 +01:00
|
|
|
|
2020-01-13 23:14:10 +01:00
|
|
|
if err := doc.Load(filename); err != nil {
|
2020-01-07 17:36:49 +01:00
|
|
|
return data, err
|
|
|
|
}
|
|
|
|
|
2020-01-13 23:14:10 +01:00
|
|
|
data.Title = doc.Title()
|
|
|
|
data.Artist = doc.Artist()
|
|
|
|
data.Description = doc.Description()
|
|
|
|
data.Copyright = doc.Copyright()
|
|
|
|
data.CameraMake = doc.CameraMake()
|
|
|
|
data.CameraModel = doc.CameraModel()
|
|
|
|
data.LensModel = doc.LensModel()
|
2020-01-07 17:36:49 +01:00
|
|
|
|
|
|
|
return data, nil
|
|
|
|
}
|