feat(tags): add ReadCover interface method
This commit is contained in:
No files matched your search
@@ -339,6 +339,10 @@ func (m *tagReader) Read(absPath string) (tags.Properties, map[string][]string,
|
|||||||
return props, p.Tags, nil
|
return props, p.Tags, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *tagReader) ReadCover(absPath string) ([]byte, error) {
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
type TagInfo struct {
|
type TagInfo struct {
|
||||||
Tags map[string][]string
|
Tags map[string][]string
|
||||||
Length time.Duration
|
Length time.Duration
|
||||||
|
|||||||
@@ -60,3 +60,11 @@ func (Reader) Read(absPath string) (tags.Properties, map[string][]string, error)
|
|||||||
|
|
||||||
return props, tgs, nil
|
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
|
||||||
|
}
|
||||||
@@ -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
|
return tags.Properties{Length: tp.Length, Bitrate: tp.Bitrate}, tag, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (Reader) ReadCover(absPath string) ([]byte, error) {
|
||||||
|
return taglib.ReadImage(absPath)
|
||||||
|
}
|
||||||
@@ -16,6 +16,7 @@ var ErrUnsupported = errors.New("filetype unsupported")
|
|||||||
type Reader interface {
|
type Reader interface {
|
||||||
CanRead(absPath string) bool
|
CanRead(absPath string) bool
|
||||||
Read(absPath string) (properties Properties, tags map[string][]string, err error)
|
Read(absPath string) (properties Properties, tags map[string][]string, err error)
|
||||||
|
ReadCover(absPath string) ([]byte, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Properties struct {
|
type Properties struct {
|
||||||
|
|||||||
Reference in New Issue
Block a user