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()
// Load youtube parser
youtubeParser := &youtube.Parser{
Config: &youtube.Config{ApiKey: youtubeApiKey},
if len(youtubeApiKey) > 0 {
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
soundcloudParser := &soundcloud.Parser{
Config: &soundcloud.Config{
ClientId: soundcloudClientId,
ClientSecret: soundcloudClientSecret,
},
if len(soundcloudClientId) > 0 && len(soundcloudClientSecret) > 0 {
soundcloudParser := &soundcloud.Parser{
Config: &soundcloud.Config{
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
must(m.RegisterParser(new(wikipedia.Parser)))