nicovideo

package module
v0.0.0-...-923f0ef Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2015 License: BSD-3-Clause Imports: 11 Imported by: 0

README

Nicovideo API Client

API client for http://www.nicovideo.jp written in go.

License

Copyright (c) 2014 Shouichi Kamiya.

Documentation

Overview

Package nicovideo is nicovideo.jp API wrapper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsPostedByUser

func IsPostedByUser(ID string) bool

IsPostedByUser returns true if video ID starts with "sm", namely posted by user.

Types

type Client

type Client struct {
	*http.Client
	IsLogin bool
}

Client manages cookies.

func NewClient

func NewClient() *Client

NewClient returns a pointer to a new Client instance.

func (*Client) Download

func (c *Client) Download(ID string) (io.ReadCloser, error)

Download takes video ID and returns content as io.ReadCloser

func (*Client) GetDailyAllRanking

func (c *Client) GetDailyAllRanking() (*Ranking, error)

GetDailyAllRanking returns array of video IDs.

func (*Client) GetRanking

func (c *Client) GetRanking(
	typ RankingType,
	genre RankingGenre,
	span RankingSpan,
) (*Ranking, error)

GetRanking returns array of video IDs.

func (*Client) GetVideoDetails

func (c *Client) GetVideoDetails(ID string) (*VideoDetails, error)

GetVideoDetails takes video ID and returns details.

func (*Client) Login

func (c *Client) Login(email, password string) error

Login takes email and password and returns error if fail.

type Ranking

type Ranking struct {
	Status     string `xml:"status,attr"`
	Count      int    `xml:"count"`
	VideoInfos []struct {
		Video struct {
			ID        string `xml:"id"`
			IsDeleted bool   `xml:"deleted"`
		} `xml:"video"`
	} `xml:"video_info"`
}

Ranking represents ranking.

type RankingGenre

type RankingGenre string

RankingGenre is type of genre.

const (
	RankingGenreAll RankingGenre = "all"
)

Ranking genres.

type RankingSpan

type RankingSpan string

RankingSpan is type of ranking span.

const (
	RankingSpanDaily RankingSpan = "daily"
)

Ranking spans.

type RankingType

type RankingType string

RankingType is type of ranking type.

const (
	RankingTypeView RankingType = "view"
)

Ranking types.

type VideoDetails

type VideoDetails struct {
	Title       string   `xml:"thumb>title"`
	Description string   `xml:"thumb>description"`
	Tags        []string `xml:"thumb>tags>tag"`
	Type        string   `xml:"thumb>movie_type"`
	Error       string   `xml:"error>code"`
}

VideoDetails contains details from API.

Jump to

Keyboard shortcuts

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