audio_codec still needs to be a array

master v0.0.10
Stein Ivar Berghei 2023-05-30 16:47:42 +09:00
parent 95c0ba95cc
commit 294d179089
1 changed files with 26 additions and 2 deletions

View File

@ -35,12 +35,36 @@ type Match struct {
// Audio // Audio
AudioChannels string `json:"audio_channels,omitempty"` AudioChannels string `json:"audio_channels,omitempty"`
AudioCodec string `json:"audio_codec,omitempty"` AudioCodec []string `json:"audio_codec,omitempty"`
// Other // Other
Other []string `json:"other,omitempty"` Other []string `json:"other,omitempty"`
} }
func (u *Match) UnmarshalJSON(data []byte) error {
fmt.Println(u)
type Alias Match
aux := &struct {
AudioCodec interface{} `json:"audio_codec,omitempty"`
*Alias
}{
Alias: (*Alias)(u),
}
if err := json.Unmarshal(data, &aux); err != nil {
return err
}
switch ac := aux.AudioCodec.(type) {
case string:
u.AudioCodec = append(u.AudioCodec, ac)
case []string:
u.AudioCodec = ac
}
return nil
}
func (g GuessitConfig) PipInstall() (err error) { func (g GuessitConfig) PipInstall() (err error) {
args := []string{"-m", "pip", "install", "guessit"} args := []string{"-m", "pip", "install", "guessit"}
cmd := exec.Command(g.Python, args...) cmd := exec.Command(g.Python, args...)