Files
podcast-search-go/main.go
2025-04-27 12:16:29 +08:00

36 lines
879 B
Go

package main
import (
"fmt"
"time"
"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))
item := podcast.Items[0]
fmt.Printf("name: %s, feedUrl: %s\n", item.CollectionName, item.FeedURL)
feedUrl := "http://www.ximalaya.com/album/19206382.xml"
pod, err := model.LoadFeed(feedUrl, "", 5*time.Second)
if err != nil {
panic(err)
}
for _, e := range pod.Episodes[:2] {
fmt.Printf("episode: %+v\n", e)
}
}