aboutsummaryrefslogtreecommitdiffstats
path: root/post
diff options
context:
space:
mode:
authorAdam Mathes <adam@trenchant.org>2017-10-16 16:52:55 -0700
committerAdam Mathes <adam@trenchant.org>2017-10-16 16:52:55 -0700
commit59a506dea038f693414efed5f1edaa65a09a48e3 (patch)
tree9f3c366cf6ea654b2036167a96b4c443f595fd89 /post
parent77dfba1cdf16e23fa21a80ff27fc693b09e4afc7 (diff)
downloadsnkt-59a506dea038f693414efed5f1edaa65a09a48e3.tar.gz
snkt-59a506dea038f693414efed5f1edaa65a09a48e3.tar.bz2
snkt-59a506dea038f693414efed5f1edaa65a09a48e3.zip
error checking on exif handling
Diffstat (limited to 'post')
-rw-r--r--post/post.go29
1 files changed, 24 insertions, 5 deletions
diff --git a/post/post.go b/post/post.go
index c43b9e3..8f96c8d 100644
--- a/post/post.go
+++ b/post/post.go
@@ -143,12 +143,27 @@ func (p *Post) AbsoluteFilePath() string {
Try to extract metadata from EXIF
*/
func (p *Post) parseExif() {
- // TODO: full exif parsing / metadata propogation
- // TODO: error checking
- f, _ := os.Open(p.AbsoluteFilePath())
- x, _ := exif.Decode(f)
- tm, _ := x.DateTime()
+ f, err := os.Open(p.AbsoluteFilePath())
+ if err != nil {
+ vlog.Printf("%v", err)
+ return
+ }
+
+ x, err := exif.Decode(f)
+ if err != nil {
+ vlog.Printf("%v", err)
+ return
+ }
+
+ tm, err := x.DateTime()
+ if err != nil {
+ vlog.Printf("%v", err)
+ return
+ }
p.Time = tm
+
+ // TODO: full exif parsing | metadata propogation but exif is ugh
+ p.Meta["Exif"] = x.String()
}
/*
@@ -203,6 +218,10 @@ func NormalizeTag(tag string) string {
splitText splits up p.Unparsed into p.Text and p.Meta[attr][value]
*/
func (p *Post) splitTextMeta() {
+ if p.Unparsed == "" {
+ p.Text = ""
+ return
+ }
SEPARATOR := ":"
lines := strings.Split(p.Unparsed, "\n")
for _, line := range lines {