仓库已迁到 gitea.malai.tech,同步更新 go.mod module 声明与全部内部 import, 使其可作为正式 Go 模块被 go get 解析(此前声明路径 gitea.malaihome.work 已不可达)。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
36 lines
871 B
Go
36 lines
871 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"gitea.malai.tech/ans/podcast-search-go/model"
|
|
"gitea.malai.tech/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)
|
|
}
|
|
}
|