Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Several German television and shopping providers were added. Language support was added to the Wikipedia and the google provider. #159

Merged
merged 12 commits into from Dec 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Expand Up @@ -226,6 +226,7 @@ Custom providers require a few things:
* amazon
* archpkg
* archwiki
* ardmediathek
* arstechnica
* arxiv
* atmospherejs
Expand Down Expand Up @@ -269,6 +270,7 @@ Custom providers require a few things:
* googledocs
* googleplus
* hackernews
* idealo
* ietf
* ifttt
* imdb
Expand Down Expand Up @@ -324,6 +326,7 @@ Custom providers require a few things:
* yahoo
* yandex
* youtube
* zdf
* zhihu

## Contributors
Expand Down
30 changes: 30 additions & 0 deletions 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{}
}
}
23 changes: 22 additions & 1 deletion providers/google/google.go
Expand Up @@ -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.
Expand Down
25 changes: 25 additions & 0 deletions 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"}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be left blank, search really indicates a more general purpose search like google/duckduckgo/etc. Most users won't want to search maps as well.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reminder, we should remove this tag. =)

}
30 changes: 30 additions & 0 deletions 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{}
}
}
21 changes: 20 additions & 1 deletion providers/wikipedia/wikipedia.go
Expand Up @@ -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.
Expand Down
30 changes: 30 additions & 0 deletions 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{}
}
}
4 changes: 4 additions & 0 deletions s.go
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down