feat(tags): add ReadCover interface method

This commit is contained in:
sentriz
2025-09-29 17:08:00 +01:00
parent 3a9c03ac88
commit e413bc35de
4 changed files with 17 additions and 0 deletions

No files matched your search

+4
View File
@@ -339,6 +339,10 @@ func (m *tagReader) Read(absPath string) (tags.Properties, map[string][]string,
return props, p.Tags, nil
}
func (m *tagReader) ReadCover(absPath string) ([]byte, error) {
return nil, nil
}
type TagInfo struct {
Tags map[string][]string
Length time.Duration
+8
View File
@@ -60,3 +60,11 @@ func (Reader) Read(absPath string) (tags.Properties, map[string][]string, error)
return props, tgs, nil
}
func (Reader) ReadCover(absPath string) ([]byte, error) {
out, err := exec.Command("ffmpeg", "-i", absPath, "-map", "0:v", "-c", "copy", "-f", "image2pipe", "-").Output()
if err != nil {
return nil, fmt.Errorf("exec: %w", err)
}
return out, nil
}
+4
View File
@@ -34,3 +34,7 @@ func (Reader) Read(absPath string) (tags.Properties, map[string][]string, error)
return tags.Properties{Length: tp.Length, Bitrate: tp.Bitrate}, tag, nil
}
func (Reader) ReadCover(absPath string) ([]byte, error) {
return taglib.ReadImage(absPath)
}
+1
View File
@@ -16,6 +16,7 @@ var ErrUnsupported = errors.New("filetype unsupported")
type Reader interface {
CanRead(absPath string) bool
Read(absPath string) (properties Properties, tags map[string][]string, err error)
ReadCover(absPath string) ([]byte, error)
}
type Properties struct {