Do not register SoundCloud/YouTube parsers if no auth details given for them.

develop
Icedream 2016-07-22 20:48:57 +02:00
parent fb85ad8554
commit 19708251b9
Signed by: icedream
GPG Key ID: 1573F6D8EFE4D0CF
1 changed files with 17 additions and 9 deletions

26
main.go
View File

@ -74,19 +74,27 @@ func main() {
m := manager.NewManager() m := manager.NewManager()
// Load youtube parser // Load youtube parser
youtubeParser := &youtube.Parser{ if len(youtubeApiKey) > 0 {
Config: &youtube.Config{ApiKey: youtubeApiKey}, youtubeParser := &youtube.Parser{
Config: &youtube.Config{ApiKey: youtubeApiKey},
}
must(m.RegisterParser(youtubeParser))
} else {
log.Println("No YouTube API key provided, YouTube parsing via API is disabled.")
} }
must(m.RegisterParser(youtubeParser))
// Load soundcloud parser // Load soundcloud parser
soundcloudParser := &soundcloud.Parser{ if len(soundcloudClientId) > 0 && len(soundcloudClientSecret) > 0 {
Config: &soundcloud.Config{ soundcloudParser := &soundcloud.Parser{
ClientId: soundcloudClientId, Config: &soundcloud.Config{
ClientSecret: soundcloudClientSecret, ClientId: soundcloudClientId,
}, ClientSecret: soundcloudClientSecret,
},
}
must(m.RegisterParser(soundcloudParser))
} else {
log.Println("No SoundCloud client ID or secret provided, SoundCloud parsing via API is disabled.")
} }
must(m.RegisterParser(soundcloudParser))
// Load wikipedia parser // Load wikipedia parser
must(m.RegisterParser(new(wikipedia.Parser))) must(m.RegisterParser(new(wikipedia.Parser)))