From f1d38a9df0e8c6e52eaeb3aa9c222cbd7d05f435 Mon Sep 17 00:00:00 2001 From: Unbewohnte Date: Thu, 24 Jun 2021 19:32:45 +0300 Subject: [PATCH] Removed getter functions --- README.md | 5 +++++ id3v10.go | 29 ++++++----------------------- id3v10_test.go | 6 ++---- id3v11.go | 29 ++++------------------------- id3v11_test.go | 8 ++++---- 5 files changed, 21 insertions(+), 56 deletions(-) diff --git a/README.md b/README.md index 78672eb..829e04f 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ go get github.com/Unbewohnte/id3ed # Usage +## Decoding ID3v1.1 ``` package main @@ -42,6 +43,10 @@ func main() { } ``` +## Encoding ID3v1.1 +``` +``` + # Testing ``` diff --git a/id3v10.go b/id3v10.go index bdc98fb..75cb448 100644 --- a/id3v10.go +++ b/id3v10.go @@ -53,11 +53,11 @@ func GetID3v1Tags(rs io.ReadSeeker) (*ID3v1Tags, error) { return nil, err } - yearBytes, err := read(rs, 4) + yearStr, err := readToString(rs, 4) if err != nil { return nil, err } - year, err := strconv.Atoi(string(yearBytes)) + year, err := strconv.Atoi(yearStr) if err != nil { return nil, fmt.Errorf("could not convert yearbytes into int: %s", err) } @@ -87,26 +87,9 @@ func GetID3v1Tags(rs io.ReadSeeker) (*ID3v1Tags, error) { }, nil } -func (t *ID3v1Tags) GetSongName() string { - return t.SongName -} - -func (t *ID3v1Tags) GetArtist() string { - return t.Artist -} - -func (t *ID3v1Tags) GetAlbum() string { - return t.Album -} - -func (t *ID3v1Tags) GetYear() int { - return t.Year -} - -func (t *ID3v1Tags) GetComment() string { - return t.Comment -} +// Writes given ID3v1.0 tags to dst +func SetID3v1Tags(dst io.WriteSeeker, tags ID3v11Tags) error { + dst.Seek(0, io.SeekEnd) -func (t *ID3v1Tags) GetGenre() string { - return t.Genre + return nil } diff --git a/id3v10_test.go b/id3v10_test.go index f822605..895e818 100644 --- a/id3v10_test.go +++ b/id3v10_test.go @@ -15,9 +15,7 @@ func TestGetID3v1Tags(t *testing.T) { t.Errorf("GetID3v1Tags failed: %s", err) } - comment := tags.GetComment() - - if comment != "Comment here " { - t.Errorf("GetID3v1Tags failed: expected %s; got %s", "Comment here ", comment) + if tags.Comment != "Comment here " { + t.Errorf("GetID3v1Tags failed: expected %s; got %s", "Comment here ", tags.Comment) } } diff --git a/id3v11.go b/id3v11.go index c264c67..d60d6a0 100644 --- a/id3v11.go +++ b/id3v11.go @@ -99,30 +99,9 @@ func GetID3v11Tags(rs io.ReadSeeker) (*ID3v11Tags, error) { }, nil } -func (t *ID3v11Tags) GetSongName() string { - return t.SongName -} - -func (t *ID3v11Tags) GetArtist() string { - return t.Artist -} - -func (t *ID3v11Tags) GetAlbum() string { - return t.Album -} - -func (t *ID3v11Tags) GetYear() int { - return t.Year -} - -func (t *ID3v11Tags) GetComment() string { - return t.Comment -} - -func (t *ID3v11Tags) GetTrack() int { - return t.Track -} +// Writes given ID3v1.1 tags to dst +func SetID3v11Tags(dst io.WriteSeeker, tags ID3v11Tags) error { + dst.Seek(0, io.SeekEnd) -func (t *ID3v11Tags) GetGenre() string { - return t.Genre + return nil } diff --git a/id3v11_test.go b/id3v11_test.go index 0dc3202..022ce35 100644 --- a/id3v11_test.go +++ b/id3v11_test.go @@ -16,12 +16,12 @@ func TestGetID3v11Tags(t *testing.T) { t.Errorf("GetID3v1Tags failed: %s", err) } - if mp3tags.GetArtist() != "Artist" { + if mp3tags.Artist != "Artist" { fmt.Printf("%v", mp3tags.Artist) - t.Errorf("GetID3v1Tags has failed: expected %v; got %v", "Artist", mp3tags.GetArtist()) + t.Errorf("GetID3v1Tags has failed: expected %v; got %v", "Artist", mp3tags.Artist) } - if mp3tags.GetTrack() != 8 { - t.Errorf("GetID3v1Tags has failed: expected %v; got %v", 8, mp3tags.GetTrack()) + if mp3tags.Track != 8 { + t.Errorf("GetID3v1Tags has failed: expected %v; got %v", 8, mp3tags.Track) } }