✨ Probe.FullTags()
This commit is contained in:
parent
d8cae5b9c4
commit
c9498340d0
4 changed files with 28 additions and 1 deletions
|
|
@ -9,6 +9,8 @@ import (
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const Version string = "0.1.0"
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Source string `toml:"source"`
|
Source string `toml:"source"`
|
||||||
SourceExtensions []string `toml:"source_ext"`
|
SourceExtensions []string `toml:"source_ext"`
|
||||||
|
|
@ -23,6 +25,10 @@ type Config struct {
|
||||||
AcousticUserKey string `toml:"acoustic_user_key"`
|
AcousticUserKey string `toml:"acoustic_user_key"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c Config) Version() string {
|
||||||
|
return Version
|
||||||
|
}
|
||||||
|
|
||||||
var config Config
|
var config Config
|
||||||
|
|
||||||
func newConfig() Config {
|
func newConfig() Config {
|
||||||
|
|
|
||||||
1
go.mod
1
go.mod
|
|
@ -3,6 +3,7 @@ module codeberg.org/danjones000/strip-beats
|
||||||
go 1.20
|
go 1.20
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
dario.cat/mergo v1.0.0
|
||||||
github.com/BurntSushi/toml v1.3.2
|
github.com/BurntSushi/toml v1.3.2
|
||||||
github.com/adrg/xdg v0.4.0
|
github.com/adrg/xdg v0.4.0
|
||||||
github.com/akrennmair/slice v0.0.0-20220105203817-49445747ab81
|
github.com/akrennmair/slice v0.0.0-20220105203817-49445747ab81
|
||||||
|
|
|
||||||
2
go.sum
2
go.sum
|
|
@ -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 h1:o7IhLm0Msx3BaB+n3Ag7L8EVlByGnpq14C4YWiu/gL8=
|
||||||
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
github.com/BurntSushi/toml v1.3.2/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
|
||||||
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
|
github.com/adrg/xdg v0.4.0 h1:RzRqFcjH4nE5C6oTAxhBtoE2IRyjBSa62SCbyPidvls=
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
package media
|
package media
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
|
||||||
"codeberg.org/danjones000/strip-beats/config"
|
"codeberg.org/danjones000/strip-beats/config"
|
||||||
"codeberg.org/danjones000/strip-beats/utils"
|
"codeberg.org/danjones000/strip-beats/utils"
|
||||||
"encoding/json"
|
"dario.cat/mergo"
|
||||||
"github.com/akrennmair/slice"
|
"github.com/akrennmair/slice"
|
||||||
ffmpeg "github.com/u2takey/ffmpeg-go"
|
ffmpeg "github.com/u2takey/ffmpeg-go"
|
||||||
)
|
)
|
||||||
|
|
@ -141,6 +143,22 @@ type Tags struct {
|
||||||
Track string
|
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 {
|
func ProbeFile(path string) Probe {
|
||||||
out, err := ffmpeg.Probe(path)
|
out, err := ffmpeg.Probe(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue