From fe2a273115f374389bdbcb5b43c103fdf34f50ec Mon Sep 17 00:00:00 2001 From: Unbewohnte Date: Fri, 9 Jul 2021 16:23:54 +0300 Subject: [PATCH] Added information to README --- README.md | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index d042dcf..0850bd0 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ go install github.com/Unbewohnte/id3ed/... # ∙ Examples -## ⚬ Decoding ID3v1 +## ⚬ Reading ID3v1 ``` package main @@ -45,24 +45,25 @@ func main() { panic(err) } - // extract ID3v1.1 tags - mp3tags, err := id3v1.Getv1Tag(mp3file) + // extract ID3v1.1 tag + mp3tag, err := id3v1.Readv1Tag(mp3file) if err != nil { panic(err) } - // print all tags - fmt.Printf("%+v",mp3tags) + // print the whole tag + fmt.Printf("%+v",mp3tag) - songname := mp3tags.SongName + // get certain fields + songname := mp3tag.SongName - genre := mp3tags.Genre + genre := mp3tag.Genre // etc. } ``` -## ⚬ Encoding ID3v1 +## ⚬ Writing ID3v1 ``` package main @@ -97,6 +98,38 @@ func main() { } ``` +## ⚬ Reading ID3v2 +``` +package main + +import( + "fmt" + id3v2 "github.com/Unbewohnte/id3ed/v2" +) + +func main() { + mp3file, err := os.Open("/path/to/mp3/myMP3.mp3") + if err != nil { + panic(err) + } + + // extract ID3v2 tag + mp3tag, err := id3v2.Readv2Tag(mp3file) + if err != nil { + panic(err) + } + + if mp3tag.Header.Version == id3v2.V2_3 { + // get certain frame by identifier + title := mp3tag.Frames["TIT2"] + artist := mp3tag.Frames["TPE1"] + } + + + // etc. + +``` + --- # ∙ Testing