2015-03-19 13:21:53 +01:00
|
|
|
// Copyright 2015, David Howden
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
/*
|
2015-04-03 05:58:49 +02:00
|
|
|
The sum tool constructs a checksum of a media file exluding any metadata
|
2015-03-19 13:21:53 +01:00
|
|
|
(as recognised by the tag library).
|
|
|
|
*/
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
|
|
|
|
"github.com/dhowden/tag"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
|
|
|
if len(os.Args) != 2 {
|
|
|
|
fmt.Printf("usage: %v filename\n", os.Args[0])
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
f, err := os.Open(os.Args[1])
|
|
|
|
if err != nil {
|
|
|
|
fmt.Printf("error loading file: %v", err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
defer f.Close()
|
|
|
|
|
2015-04-03 05:58:49 +02:00
|
|
|
h, err := tag.Sum(f)
|
2015-03-19 13:21:53 +01:00
|
|
|
if err != nil {
|
2015-04-03 05:58:49 +02:00
|
|
|
fmt.Printf("error constructing checksum: %v\n", err)
|
2015-03-19 13:21:53 +01:00
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
fmt.Println(h)
|
|
|
|
}
|