gonhk

package module
v0.0.0-...-eaf2c05 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 8, 2014 License: MIT Imports: 7 Imported by: 0

README

gonhk - NHK API Client in Go

Build Status GoDoc

gonhk implements a NHK API client.

Installation

$ go get github.com/yosssi/gonhk

Example

package main

import (
	"fmt"
	"github.com/yosssi/gonhk"
	"time"
)

func main() {
	// Get an NHK API client. You have to pass your NHK API key to this function.
	client := gonhk.NewClient("Your NHK API Key")

	today := time.Now()

	// Call NHK Program List API.
	// http://api-portal.nhk.or.jp/doc_list-v1_con
	result1, err := client.ProgramList("v1", "130", "g1", today)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v\n", result1)

	// Call NHK Program Genre API.
	// http://api-portal.nhk.or.jp/doc_genre-v1_con
	result2, err := client.ProgramGenre("v1", "130", "g1", "0000", today)
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v\n", result2)

	// Call NHK Program Info API.
	// http://api-portal.nhk.or.jp/doc_info-v1_con
	result3, err := client.ProgramInfo("v1", "130", "g1", "2014020702065")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v\n", result3)

	// Call NHK Now On Air API.
	// http://api-portal.nhk.or.jp/doc_now-v1_con
	result4, err := client.NowOnAir("v1", "130", "g1")
	if err != nil {
		panic(err)
	}
	fmt.Printf("%+v\n", result4)
}

Documentation

GoDoc

Note

情報提供:NHK
This program uses NHK番組表API.

Documentation

Overview

Package gonhk implements a NHK API client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

A Client represents a NHK API client.

func NewClient

func NewClient(apikey string) Client

NewClient generates and returns a new client.

func (*Client) NowOnAir

func (c *Client) NowOnAir(version, area, service string) (*NhkNowOnAirList, error)

NowOnAir calls NHK Now On Air API and returns its result.

func (*Client) ProgramGenre

func (c *Client) ProgramGenre(version, area, service, genre string, date time.Time) (*NhkList, error)

ProgramGenre calls NHK Program Genre API and returns its result.

func (*Client) ProgramInfo

func (c *Client) ProgramInfo(version, area, service, id string) (*NhkDescriptionList, error)

ProgramInfo calls NHK Program Info API and returns its result.

func (*Client) ProgramList

func (c *Client) ProgramList(version, area, service string, date time.Time) (*NhkList, error)

ProgramList calls NHK Program List API and returns its result.

type NhkArea

type NhkArea struct {
	Id   string `json:"id"`
	Name string `json:"name"`
}

An NhkArea represents an area data of NHK API.

type NhkDescription

type NhkDescription struct {
	Id          string     `json:"id"`
	EventId     string     `json:"event_id"`
	StartTime   time.Time  `json:"start_time"`
	EndTime     time.Time  `json:"end_time"`
	Area        NhkArea    `json:"area"`
	Service     NhkService `json:"service"`
	Title       string     `json:"title"`
	Subtitle    string     `json:"subtitle"`
	Genres      []string   `json:"genres"`
	ProgramUrl  string     `json:"program_url"`
	EpisodeUrl  string     `json:"episode_url"`
	Hashtags    []string   `json:"hashtags"`
	Extras      NhkExtra   `json:"extras"`
}

An NhkDescription represents a description data of NHK API.

type NhkDescriptionList

type NhkDescriptionList struct {
	List map[string][]*NhkDescription `json:"list"`
}

An NhkDescriptionList represents a description list data of NHK API.

type NhkError

type NhkError struct {
	Code    int    `json:"code"`
	Message string `json:"message"`
}

An NhkError represents an error data of NHK API.

type NhkExtra

type NhkExtra struct {
	OndemandProgram NhkLink `json:"ondemand_program"`
	OndemandEpisode NhkLink `json:"ondemand_episode"`
}

An NhkExtra represents an extra data of NHK API.

type NhkLink struct {
	Url   string `json:"url"`
	Title string `json:"title"`
	Id    string `json:"id"`
}

An NhkLink represents a link data of NHK API.

type NhkList

type NhkList struct {
	List map[string][]*NhkProgram `json:"list"`
}

An NhkList represents a list data of NHK API.

type NhkLogo struct {
	Url    string `json:"url"`
	Width  string `json:"width"`
	Height string `json:"height"`
}

An NhkLogo represents a logo data of NHK API.

type NhkNowOnAir

type NhkNowOnAir struct {
	Previous  NhkProgram `json:"previous"`
	Present   NhkProgram `json:"present"`
	Following NhkProgram `json:"following"`
}

An NhkNowOnAir represents a now on air data of NHK API.

type NhkNowOnAirList

type NhkNowOnAirList struct {
	NowOnAirList map[string]*NhkNowOnAir `json:"nowonair_list"`
}

An NhkNowOnAirList represents a now on air list data of NHK API.

type NhkProgram

type NhkProgram struct {
	Id        string     `json:"id"`
	EventId   string     `json:"event_id"`
	StartTime time.Time  `json:"start_time"`
	EndTime   time.Time  `json:"end_time"`
	Area      NhkArea    `json:"area"`
	Service   NhkService `json:"service"`
	Title     string     `json:"title"`
	Subtitle  string     `json:"subtitle"`
	Genres    []string   `json:"genres"`
}

An NhkProgram represents a program data of NHK API.

type NhkService

type NhkService struct {
	Id    string  `json:"id"`
	Name  string  `json:"name"`
	LogoS NhkLogo `json:"logo_s"`
	LogoM NhkLogo `json:"logo_m"`
	LogoL NhkLogo `json:"logo_l"`
}

An NhkService represents a service data of NHK API.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL