diff --git a/README.md b/README.md index b604b9b..d64cd32 100644 --- a/README.md +++ b/README.md @@ -226,6 +226,7 @@ Custom providers require a few things: * amazon * archpkg * archwiki +* ardmediathek * arstechnica * arxiv * atmospherejs @@ -269,6 +270,7 @@ Custom providers require a few things: * googledocs * googleplus * hackernews +* idealo * ietf * ifttt * imdb @@ -324,6 +326,7 @@ Custom providers require a few things: * yahoo * yandex * youtube +* zdf * zhihu ## Contributors diff --git a/providers/ardmediathek/ardmediathek.go b/providers/ardmediathek/ardmediathek.go new file mode 100644 index 0000000..0e3fecc --- /dev/null +++ b/providers/ardmediathek/ardmediathek.go @@ -0,0 +1,30 @@ +package ardmediathek + +import ( + "fmt" + "net/url" + + "github.com/zquestz/s/providers" +) + +func init() { + providers.AddProvider("ardmediathek", &Provider{}) +} + +// Provider merely implements the Provider interface. +type Provider struct{} + +// BuildURI generates a search URL for ARD MEDIATHEK. +func (p *Provider) BuildURI(q string) string { + return fmt.Sprintf("https://www.ardmediathek.de/suche/%s/", url.QueryEscape(q)) +} + +// Tags returns the tags relevant to this provider. +func (p *Provider) Tags() []string { + switch providers.Language() { + case "de": + return []string{"tv"} + default: + return []string{} + } +} diff --git a/providers/google/google.go b/providers/google/google.go index 4993cd7..bc63ddf 100644 --- a/providers/google/google.go +++ b/providers/google/google.go @@ -16,7 +16,28 @@ type Provider struct{} // BuildURI generates a search URL for Google. func (p *Provider) BuildURI(q string) string { - return fmt.Sprintf("https://www.google.com/search?q=%s", url.QueryEscape(q)) + switch providers.Region() { + case "CA": + return fmt.Sprintf("https://www.google.ca/search?q=%s", url.QueryEscape(q)) + case "DE": + return fmt.Sprintf("https://www.google.de/search?q=%s", url.QueryEscape(q)) + case "ES": + return fmt.Sprintf("https://www.google.es/search?q=%s", url.QueryEscape(q)) + case "FR": + return fmt.Sprintf("https://www.google.fr/search?q=%s", url.QueryEscape(q)) + case "IN": + return fmt.Sprintf("https://www.google.co.in/search?q=%s", url.QueryEscape(q)) + case "IT": + return fmt.Sprintf("https://www.google.it/search?q=%s", url.QueryEscape(q)) + case "JP": + return fmt.Sprintf("https://www.google.co.jp/search?q=%s", url.QueryEscape(q)) + case "MX": + return fmt.Sprintf("https://www.google.com.mx/search?q=%s", url.QueryEscape(q)) + case "NL": + return fmt.Sprintf("https://www.google.nl/search?q=%s", url.QueryEscape(q)) + default: + return fmt.Sprintf("https://www.google.com/search?q=%s", url.QueryEscape(q)) + } } // Tags returns the tags relevant to this provider. diff --git a/providers/googlemaps/googlemaps.go b/providers/googlemaps/googlemaps.go new file mode 100644 index 0000000..b6b120d --- /dev/null +++ b/providers/googlemaps/googlemaps.go @@ -0,0 +1,25 @@ +package googlemaps + +import ( + "fmt" + "net/url" + + "github.com/zquestz/s/providers" +) + +func init() { + providers.AddProvider("googlemaps", &Provider{}) +} + +// Provider merely implements the Provider interface. +type Provider struct{} + +// BuildURI generates a search URL for Google Maps. +func (p *Provider) BuildURI(q string) string { + return fmt.Sprintf("https://www.google.com/maps/search/?api=1&query=%s", url.QueryEscape(q)) +} + +// Tags returns the tags relevant to this provider. +func (p *Provider) Tags() []string { + return []string{"search"} +} diff --git a/providers/idealo/idealo.go b/providers/idealo/idealo.go new file mode 100644 index 0000000..6c162d2 --- /dev/null +++ b/providers/idealo/idealo.go @@ -0,0 +1,30 @@ +package idealo + +import ( + "fmt" + "net/url" + + "github.com/zquestz/s/providers" +) + +func init() { + providers.AddProvider("idealo", &Provider{}) +} + +// Provider merely implements the Provider interface. +type Provider struct{} + +// BuildURI generates a search URL for IDEALO. +func (p *Provider) BuildURI(q string) string { + return fmt.Sprintf("https://www.idealo.de/preisvergleich/MainSearchProductCategory.html?q=%s", url.QueryEscape(q)) +} + +// Tags returns the tags relevant to this provider. +func (p *Provider) Tags() []string { + switch providers.Language() { + case "de": + return []string{"shopping"} + default: + return []string{} + } +} diff --git a/providers/wikipedia/wikipedia.go b/providers/wikipedia/wikipedia.go index 6cc00bb..b7e9468 100644 --- a/providers/wikipedia/wikipedia.go +++ b/providers/wikipedia/wikipedia.go @@ -16,7 +16,26 @@ type Provider struct{} // BuildURI generates a search URL for Wikipedia. func (p *Provider) BuildURI(q string) string { - return fmt.Sprintf("https://en.wikipedia.org/wiki/Special:Search?search=%s", url.QueryEscape(q)) + switch providers.Region() { + case "BR": + return fmt.Sprintf("https://br.wikipedia.org/wiki/Special:Search?search=%s", url.QueryEscape(q)) + case "CA": + return fmt.Sprintf("https://ca.wikipedia.org/wiki/Special:Search?search=%s", url.QueryEscape(q)) + case "DE": + return fmt.Sprintf("https://de.wikipedia.org/wiki/Special:Search?search=%s", url.QueryEscape(q)) + case "ES": + return fmt.Sprintf("https://es.wikipedia.org/wiki/Special:Search?search=%s", url.QueryEscape(q)) + case "FR": + return fmt.Sprintf("https://fr.wikipedia.org/wiki/Special:Search?search=%s", url.QueryEscape(q)) + case "IT": + return fmt.Sprintf("https://it.wikipedia.org/wiki/Special:Search?search=%s", url.QueryEscape(q)) + case "JP": + return fmt.Sprintf("https://jp.wikipedia.org/wiki/Special:Search?search=%s", url.QueryEscape(q)) + case "NL": + return fmt.Sprintf("https://nl.wikipedia.org/wiki/Special:Search?search=%s", url.QueryEscape(q)) + default: + return fmt.Sprintf("https://en.wikipedia.org/wiki/Special:Search?search=%s", url.QueryEscape(q)) + } } // Tags returns the tags relevant to this provider. diff --git a/providers/zdf/zdf.go b/providers/zdf/zdf.go new file mode 100644 index 0000000..05371be --- /dev/null +++ b/providers/zdf/zdf.go @@ -0,0 +1,30 @@ +package zdf + +import ( + "fmt" + "net/url" + + "github.com/zquestz/s/providers" +) + +func init() { + providers.AddProvider("zdf", &Provider{}) +} + +// Provider merely implements the Provider interface. +type Provider struct{} + +// BuildURI generates a search URL for ZDF. +func (p *Provider) BuildURI(q string) string { + return fmt.Sprintf("https://www.zdf.de/suche?q=%s&synth=true&sender=Gesamtes+Angebot", url.QueryEscape(q)) +} + +// Tags returns the tags relevant to this provider. +func (p *Provider) Tags() []string { + switch providers.Language() { + case "de": + return []string{"tv"} + default: + return []string{} + } +} diff --git a/s.go b/s.go index 58a98a5..d640a51 100644 --- a/s.go +++ b/s.go @@ -12,6 +12,7 @@ import ( _ "github.com/zquestz/s/providers/amazon" _ "github.com/zquestz/s/providers/archpkg" _ "github.com/zquestz/s/providers/archwiki" + _ "github.com/zquestz/s/providers/ardmediathek" _ "github.com/zquestz/s/providers/arstechnica" _ "github.com/zquestz/s/providers/arxiv" _ "github.com/zquestz/s/providers/atmospherejs" @@ -53,8 +54,10 @@ import ( _ "github.com/zquestz/s/providers/goodreads" _ "github.com/zquestz/s/providers/google" _ "github.com/zquestz/s/providers/googledocs" + _ "github.com/zquestz/s/providers/googlemaps" _ "github.com/zquestz/s/providers/googleplus" _ "github.com/zquestz/s/providers/hackernews" + _ "github.com/zquestz/s/providers/idealo" _ "github.com/zquestz/s/providers/ietf" _ "github.com/zquestz/s/providers/ifttt" _ "github.com/zquestz/s/providers/imdb" @@ -110,6 +113,7 @@ import ( _ "github.com/zquestz/s/providers/yahoo" _ "github.com/zquestz/s/providers/yandex" _ "github.com/zquestz/s/providers/youtube" + _ "github.com/zquestz/s/providers/zdf" _ "github.com/zquestz/s/providers/zhihu" "github.com/zquestz/s/cmd"