Compare commits
No commits in common. "master" and "v0.0.10" have entirely different histories.
14
guessit.go
14
guessit.go
|
@ -15,7 +15,6 @@ type GuessitConfig struct {
|
||||||
|
|
||||||
type Guessit struct {
|
type Guessit struct {
|
||||||
GuessitConfig
|
GuessitConfig
|
||||||
DefaultOptions []string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Match struct {
|
type Match struct {
|
||||||
|
@ -33,7 +32,6 @@ type Match struct {
|
||||||
// Video
|
// Video
|
||||||
ScreenSize string `json:"screen_size,omitempty"`
|
ScreenSize string `json:"screen_size,omitempty"`
|
||||||
Container string `json:"container,omitempty"`
|
Container string `json:"container,omitempty"`
|
||||||
VideoCodec string `json:"video_codec,omitempty"`
|
|
||||||
|
|
||||||
// Audio
|
// Audio
|
||||||
AudioChannels string `json:"audio_channels,omitempty"`
|
AudioChannels string `json:"audio_channels,omitempty"`
|
||||||
|
@ -44,10 +42,10 @@ type Match struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (u *Match) UnmarshalJSON(data []byte) error {
|
func (u *Match) UnmarshalJSON(data []byte) error {
|
||||||
|
fmt.Println(u)
|
||||||
type Alias Match
|
type Alias Match
|
||||||
aux := &struct {
|
aux := &struct {
|
||||||
AudioCodec interface{} `json:"audio_codec,omitempty"`
|
AudioCodec interface{} `json:"audio_codec,omitempty"`
|
||||||
Other interface{} `json:"other,omitempty"`
|
|
||||||
*Alias
|
*Alias
|
||||||
}{
|
}{
|
||||||
Alias: (*Alias)(u),
|
Alias: (*Alias)(u),
|
||||||
|
@ -64,13 +62,6 @@ func (u *Match) UnmarshalJSON(data []byte) error {
|
||||||
u.AudioCodec = ac
|
u.AudioCodec = ac
|
||||||
}
|
}
|
||||||
|
|
||||||
switch oth := aux.Other.(type) {
|
|
||||||
case string:
|
|
||||||
u.Other = append(u.Other, oth)
|
|
||||||
case []string:
|
|
||||||
u.Other = oth
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,12 +97,11 @@ func New(conf GuessitConfig) (Guessit, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Guessit{conf, []string{}}, nil
|
return Guessit{conf}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (g Guessit) Guessit(s string, options ...string) (out Match, err error) {
|
func (g Guessit) Guessit(s string, options ...string) (out Match, err error) {
|
||||||
args := []string{"-m", "guessit", s}
|
args := []string{"-m", "guessit", s}
|
||||||
args = append(args, g.DefaultOptions...)
|
|
||||||
args = append(args, options...)
|
args = append(args, options...)
|
||||||
args = append(args, "--json")
|
args = append(args, "--json")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue