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

View File

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