Probe.FullTags()

This commit is contained in:
Dan Jones 2023-09-08 21:31:13 -05:00
commit c9498340d0
4 changed files with 28 additions and 1 deletions

View file

@ -9,6 +9,8 @@ import (
"path/filepath"
)
const Version string = "0.1.0"
type Config struct {
Source string `toml:"source"`
SourceExtensions []string `toml:"source_ext"`
@ -23,6 +25,10 @@ type Config struct {
AcousticUserKey string `toml:"acoustic_user_key"`
}
func (c Config) Version() string {
return Version
}
var config Config
func newConfig() Config {

1
go.mod
View file

@ -3,6 +3,7 @@ module codeberg.org/danjones000/strip-beats
go 1.20
require (
dario.cat/mergo v1.0.0
github.com/BurntSushi/toml v1.3.2
github.com/adrg/xdg v0.4.0
github.com/akrennmair/slice v0.0.0-20220105203817-49445747ab81

2
go.sum
View file

@ -1,3 +1,5 @@
dario.cat/mergo v1.0.0 h1:AGCNq9Evsj31mOgNPcLyXc+4PNABt905YmuqPYYpBWk=
dario.cat/mergo v1.0.0/go.mod h1:uNxQE+84aUszobStD9th8a29P2fMDhsBdgRYvZOxGmk=
github.com/BurntSushi/toml v1.3.2 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=

View file

@ -1,9 +1,11 @@
package media
import (
"encoding/json"
"codeberg.org/danjones000/strip-beats/config"
"codeberg.org/danjones000/strip-beats/utils"
"encoding/json"
"dario.cat/mergo"
"github.com/akrennmair/slice"
ffmpeg "github.com/u2takey/ffmpeg-go"
)
@ -141,6 +143,22 @@ type Tags struct {
Track string
}
func (pr Probe) FullTags() Tags {
t := pr.Format.Tags
s := pr.WantedAudioStream()
if s != nil {
mergo.Merge(&t, s.Tags)
}
for _, st := range pr.Streams {
mergo.Merge(&t, st.Tags)
}
return t
}
func (pr Probe) Title() string {
return pr.FullTags().Title
}
func ProbeFile(path string) Probe {
out, err := ffmpeg.Probe(path)
if err != nil {