Compare commits

...

4 Commits

Author SHA1 Message Date
Stein Ivar Berghei c4f1163a94 Add DefaultOptions 2024-04-16 10:17:29 +02:00
Stein Ivar Berghei 7b4bf1563c Add VideoCodec 2024-04-09 11:03:45 +02:00
Stein Ivar Berghei 7d34e678ac Actually support Other fully. 2023-08-11 18:58:05 +02:00
Stein Ivar Berghei b81c62af15 Support Other fully. 2023-08-11 18:51:40 +02:00
1 changed files with 12 additions and 1 deletions

View File

@ -15,6 +15,7 @@ type GuessitConfig struct {
type Guessit struct {
GuessitConfig
DefaultOptions []string
}
type Match struct {
@ -32,6 +33,7 @@ type Match struct {
// Video
ScreenSize string `json:"screen_size,omitempty"`
Container string `json:"container,omitempty"`
VideoCodec string `json:"video_codec,omitempty"`
// Audio
AudioChannels string `json:"audio_channels,omitempty"`
@ -45,6 +47,7 @@ func (u *Match) UnmarshalJSON(data []byte) error {
type Alias Match
aux := &struct {
AudioCodec interface{} `json:"audio_codec,omitempty"`
Other interface{} `json:"other,omitempty"`
*Alias
}{
Alias: (*Alias)(u),
@ -61,6 +64,13 @@ func (u *Match) UnmarshalJSON(data []byte) error {
u.AudioCodec = ac
}
switch oth := aux.Other.(type) {
case string:
u.Other = append(u.Other, oth)
case []string:
u.Other = oth
}
return nil
}
@ -96,11 +106,12 @@ func New(conf GuessitConfig) (Guessit, error) {
}
}
return Guessit{conf}, nil
return Guessit{conf, []string{}}, nil
}
func (g Guessit) Guessit(s string, options ...string) (out Match, err error) {
args := []string{"-m", "guessit", s}
args = append(args, g.DefaultOptions...)
args = append(args, options...)
args = append(args, "--json")