Browse Source

Removed getter functions

main
Unbewohnte 3 years ago
parent
commit
f1d38a9df0
  1. 5
      README.md
  2. 29
      id3v10.go
  3. 6
      id3v10_test.go
  4. 29
      id3v11.go
  5. 8
      id3v11_test.go

5
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
```

29
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
}

6
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)
}
}

29
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
}

8
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)
}
}

Loading…
Cancel
Save