You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
podgrab/service/itunesService.go

31 lines
614 B

package service
import (
"encoding/json"
"fmt"
"net/url"
"github.com/akhilrex/podgrab/model"
)
type ItunesService struct {
}
const ITUNES_BASE = "https://itunes.apple.com"
func (service ItunesService) Query(q string) []*model.CommonSearchResultModel {
url := fmt.Sprintf("%s/search?term=%s&entity=podcast", ITUNES_BASE, url.QueryEscape(q))
body, _ := makeQuery(url)
var response model.ItunesResponse
json.Unmarshal(body, &response)
var toReturn []*model.CommonSearchResultModel
for _, obj := range response.Results {
toReturn = append(toReturn, GetSearchFromItunes(obj))
}
return toReturn
}