Skip to content

Commit

Permalink
Several German television and shopping providers were added. Language…
Browse files Browse the repository at this point in the history
… support was added to the Wikipedia and the google provider. (#159)

* Added the second german television station (ZDF) to the available providers.

* Added the first german television station (ARD) to the available providers.

* Added google maps to the available providers.

* Added idealo (german shopping comparison portal) to the available providers.

* The Wikipedia provider was extended to support different regions.

* The Google provider was extended to support different regions.

* Renamed ard to ardmediathek and added it to the README.

* Renamed ard to ardmediathek and added it to the README. Using tv as tag, it is shorter then television.

* Tags of german sites are only provided to german users.

* Idealo and ZDF are now mentioned in the README.

* I missed something during renaming from ard to ardmediathek.

* Forgot to close some brackets.
  • Loading branch information
xoro authored Dec 1, 2021
1 parent 35dc54d commit cc26aa2
Show file tree
Hide file tree
Showing 8 changed files with 164 additions and 2 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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"}
}
30 changes: 30 additions & 0 deletions providers/idealo/idealo.go
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
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

0 comments on commit cc26aa2

Please sign in to comment.