go-mirakurun is a Mirakurun Client for Go.
import "ykzts.com/x/mirakurun"
c := mirakurun.NewClient()
opt := &mirakurun.ChannelScanOptions{Type: "BS"}
stream, _, err := c.ChannelScan(context.Background(), opt)
if err != nil {
log.Fatal(err)
}
defer stream.Close()
io.Copy(os.Stdout, stream)
c := mirakurun.NewClient()
channels, _, err := c.GetChannels(context.Background(), nil)
if err != nil {
log.Fatal(err)
}
for _, channel := range channels {
fmt.Printf("%s (%s): %s\n", channel.Channel, channel.Type, channel.Name)
}
c := mirakurun.NewClient()
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
stream, _, err := c.GetServiceStream(ctx, 3239123608, true)
if err != nil {
log.Fatal(err)
}
defer stream.Close()
name := fmt.Sprintf("stream-%d.ts", time.Now().Unix())
file, err := os.Create(name)
if err != nil {
log.Fatal(err)
}
defer file.Close()
fmt.Printf("save to %s\n", name)
io.Copy(file, stream)