Enhance the ITunesProvider by adding logging with detailed caller information, implementing rate limiting to prevent API abuse, and supporting genre IDs for more precise searches. Also, update the User-Agent string and improve error handling and logging throughout the search and charts functionality.
24 lines
549 B
Go
24 lines
549 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"gitea.malaihome.work/ans/podcast-search-go/model"
|
|
"gitea.malaihome.work/ans/podcast-search-go/search"
|
|
)
|
|
|
|
func main() {
|
|
|
|
provider := search.NewITunesProvider()
|
|
|
|
// podcast, err := provider.SearchPodcasts("golang", &search.SearchOptions{Country: "us", Language: "en-us"})
|
|
podcast, err := provider.Charts(&search.ChartsOptions{Country: "us", GenreID: model.GetGenreID("en-US", "Art"), Limit: 3})
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
// print podcast to json
|
|
fmt.Printf("podcast count: %+v\n", len(podcast.Items))
|
|
|
|
}
|