Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
ironsmile committed Dec 25, 2016
1 parent bed6f2c commit c67619f
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,7 @@ _testmain.go
*.exe
*.test
*.prof
<<<<<<< HEAD
=======

>>>>>>> 3a3bbc6... Inietial commit
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2016 Doychin Atanasov

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# id3inspect

This is a small command line tool for viewing [ID3](https://en.wikipedia.org/wiki/ID3) media information.

## Usage

Just give it a file name and it will print everything it can find about the file in the stdout

```sh
$ id3inspect 06.Some.People.mp3
Title: Some People
Artist: Goldfrapp
Album: Seventh Tree
Year: 2008
Track: 6
Length: 4m40s
Genre: Electronic
Samplerate: 44100
Bitrate: 222 KB
```

## Installation

As any simple go program, you can just use `go get`:

```sh
go get github.com/ironsmile/id3inspect
```

and you are good to go.

## Why?

I haven't found any suitable way of viewing the meta information for a random MP3 files in OSX. In Finder, iTunes or otherwise. This tool displays everything I need. Users of Linux distros and Windows would probably find it useless as their GUI file managers show the same information easily.

## License

MIT
58 changes: 58 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// idv3inspect: tool for showing information about media files.
//
// It will just print the basic id3v1 and id3v2 tags for a file. This icludes
// Artist, Album, Title, Track Number, Year, Genre, Sample and Bitrate
//
// Run with --help or -h for more information.
//
package main

import (
"flag"
"fmt"
"log"
"os"

"github.com/ironsmile/logger"
taglib "github.com/wtolson/go-taglib"
)

func init() {
flag.Usage = func() {
fmt.Printf("Usage: %s MEDIA_FILE\n", os.Args[0])
}
}

func main() {
flag.Parse()

logger.Default().Errorer = log.New(os.Stderr, "Error: ", 0)

if len(flag.Args()) < 1 {
logger.Fatalf("Missing argument: filename\nSee -h for more information\n")
}

fileName := flag.Arg(0)

// Because I do not like the taglib's error message for "file not found"
if _, err := os.Lstat(fileName); err != nil {
logger.Fatalln(err)
}

// Open file and find tag in it
tag, err := taglib.Read(fileName)
if err != nil {
logger.Fatal("Error while opening mp3 file: ", err)
}
defer tag.Close()

fmt.Printf("Title:\t%s\n", tag.Title())
fmt.Printf("Artist:\t%s\n", tag.Artist())
fmt.Printf("Album:\t%s\n", tag.Album())
fmt.Printf("Year:\t%d\n", tag.Year())
fmt.Printf("Track:\t%d\n", tag.Track())
fmt.Printf("Length:\t%s\n", tag.Length())
fmt.Printf("Genre:\t%s\n", tag.Genre())
fmt.Printf("Samplerate:\t%d\n", tag.Samplerate())
fmt.Printf("Bitrate:\t%d KB\n", tag.Bitrate())
}

0 comments on commit c67619f

Please sign in to comment.