Show taglib and ffmpeg versions in the log

This commit is contained in:
Deluan 2024-02-17 12:06:01 -05:00 committed by Deluan Quintão
parent effd588406
commit b67d1c0830
9 changed files with 51 additions and 0 deletions

View File

@ -23,6 +23,7 @@ type FFmpeg interface {
Probe(ctx context.Context, files []string) (string, error)
CmdPath() (string, error)
IsAvailable() bool
Version() string
}
func New() FFmpeg {
@ -84,6 +85,24 @@ func (e *ffmpeg) IsAvailable() bool {
return err == nil
}
// Version executes ffmpeg -version and extracts the version from the output.
// Sample output: ffmpeg version 6.0 Copyright (c) 2000-2023 the FFmpeg developers
func (e *ffmpeg) Version() string {
cmd, err := ffmpegCmd()
if err != nil {
return "N/A"
}
out, err := exec.Command(cmd, "-version").CombinedOutput() // #nosec
if err != nil {
return "N/A"
}
parts := strings.Split(string(out), " ")
if len(parts) < 3 {
return "N/A"
}
return parts[2]
}
func (e *ffmpeg) start(ctx context.Context, args []string) (io.ReadCloser, error) {
log.Trace(ctx, "Executing ffmpeg command", "cmd", args)
j := &ffCmd{args: args}

View File

@ -49,6 +49,10 @@ func (e *Extractor) CustomMappings() metadata.ParsedTags {
}
}
func (e *Extractor) Version() string {
return e.ffmpeg.Version()
}
func (e *Extractor) extractMetadata(filePath, info string) (metadata.ParsedTags, error) {
tags := e.parseInfo(info)
if len(tags) == 0 {

View File

@ -22,6 +22,7 @@ import (
type Extractor interface {
Parse(files ...string) (map[string]ParsedTags, error)
CustomMappings() ParsedTags
Version() string
}
var extractors = map[string]Extractor{}
@ -30,6 +31,12 @@ func RegisterExtractor(id string, parser Extractor) {
extractors[id] = parser
}
func LogExtractors() {
for id, p := range extractors {
log.Debug("Registered metadata extractor", "id", id, "version", p.Version())
}
}
func Extract(files ...string) (map[string]Tags, error) {
p, ok := extractors[conf.Server.Scanner.Extractor]
if !ok {

View File

@ -34,6 +34,10 @@ func (e *Extractor) CustomMappings() metadata.ParsedTags {
}
}
func (e *Extractor) Version() string {
return Version()
}
func (e *Extractor) extractMetadata(filePath string) (metadata.ParsedTags, error) {
tags, err := Read(filePath)
if err != nil {

View File

@ -21,6 +21,13 @@
char has_cover(const TagLib::FileRef f);
static char TAGLIB_VERSION[16];
char* taglib_version() {
snprintf((char *)TAGLIB_VERSION, 16, "%d.%d.%d", TAGLIB_MAJOR_VERSION, TAGLIB_MINOR_VERSION, TAGLIB_PATCH_VERSION);
return (char *)TAGLIB_VERSION;
}
int taglib_read(const FILENAME_CHAR_T *filename, unsigned long id) {
TagLib::FileRef f(filename, true, TagLib::AudioProperties::Fast);

View File

@ -25,6 +25,10 @@ import (
const iTunesKeyPrefix = "----:com.apple.itunes:"
func Version() string {
return C.GoString(C.taglib_version())
}
func Read(filename string) (tags map[string][]string, err error) {
// Do not crash on failures in the C code/library
debug.SetPanicOnFault(true)

View File

@ -17,6 +17,7 @@ extern void go_map_put_int(unsigned long id, char *key, int val);
extern void go_map_put_lyrics(unsigned long id, char *lang, char *val);
extern void go_map_put_lyric_line(unsigned long id, char *lang, char *text, int time);
int taglib_read(const FILENAME_CHAR_T *filename, unsigned long id);
char* taglib_version();
#ifdef __cplusplus
}

View File

@ -38,6 +38,7 @@ func NewTagScanner(rootFolder string, ds model.DataStore, playlists core.Playlis
ds: ds,
cacheWarmer: cacheWarmer,
}
metadata.LogExtractors()
return s
}

View File

@ -64,6 +64,10 @@ func (ff *MockFFmpeg) CmdPath() (string, error) {
return "ffmpeg", nil
}
func (ff *MockFFmpeg) Version() string {
return "1.0"
}
func (ff *MockFFmpeg) Read(p []byte) (n int, err error) {
ff.lock.Lock()
defer ff.lock.Unlock()