Documentation
¶
Overview ¶
Package nico provides accessing the Niconico API.
Index ¶
- Constants
- func FindLiveID(s string) (string, error)
- type Chat
- type ChatResult
- type Client
- func (c *Client) FollowCommunity(ctx context.Context, communityID string) error
- func (c *Client) GetCommunityIDFromLiveID(ctx context.Context, liveID string) (string, error)
- func (c *Client) GetNicovideoUserResponse(ctx context.Context, userID int64) (*NicovideoUserResponse, error)
- func (c *Client) GetPlayerStatus(ctx context.Context, liveID string) (*PlayerStatus, error)
- func (c *Client) GetPostkey(ctx context.Context, thread int64) (string, error)
- func (c *Client) GetUserInfo(ctx context.Context, userID int64) (*UserInfo, error)
- func (c *Client) LeaveCommunity(ctx context.Context, communityID string) error
- func (c *Client) Login(ctx context.Context, mail, password string) (string, error)
- func (c *Client) MakeLiveClient(ctx context.Context, liveID string) (*LiveClient, error)
- type Comment
- type CommentError
- type Contents
- type ContentsList
- type DialogImage
- type Error
- type LiveClient
- type Mail
- type Marquee
- type Ms
- type NicovideoUserResponse
- type Player
- type PlayerStatus
- type PlayerStatusError
- type Press
- type Rtmp
- type SendChat
- type SendThread
- type Stream
- type Telop
- type Thread
- type Twitter
- type TwitterInfo
- type User
- type UserInfo
- type UserInfoError
- type VitaOption
Examples ¶
Constants ¶
const ( CommentColorWhite = "white" CommentColorRed = "red" CommentColorPink = "pink" CommentColorOrange = "orange" CommentColorYellow = "yellow" CommentColorGreen = "green" CommentColorCyan = "cyan" CommentColorBlue = "blue" CommentColorPurple = "purple" )
Comment color.
const ( SizeMedium = "medium" SizeBig = "big" SizeSmall = "small" )
Comment size.
const ( PositionNaka = "naka" PositionUe = "ue" PositionShita = "shita" )
Comment position.
const ( PlayerStatusErrorCodeFull = "full" PlayerStatusErrorCodeNotlogin = "notlogin" PlayerStatusErrorCodeRequireCommunityMember = "require_community_member" )
Error code of PlayerStatus.
Variables ¶
This section is empty.
Functions ¶
func FindLiveID ¶
FindLiveID find for the live id from s.
Example ¶
package main
import (
"fmt"
"log"
"github.com/178inaba/nico"
)
func main() {
liveID, err := nico.FindLiveID("http://live.nicovideo.jp/watch/lv1234567?ref=community")
if err != nil {
log.Fatal(err)
}
fmt.Println(liveID)
}
Output: lv1234567
Types ¶
type Chat ¶
type Chat struct {
XMLName xml.Name `xml:"chat"`
Thread int64 `xml:"thread,attr"`
No int64 `xml:"no,attr"`
Vpos int64 `xml:"vpos,attr"`
Date int64 `xml:"date,attr"`
DateUsec int64 `xml:"date_usec,attr"`
Mail string `xml:"mail,attr"`
Yourpost int64 `xml:"yourpost,attr"`
UserID string `xml:"user_id,attr"`
Premium int64 `xml:"premium,attr"`
Anonymity int64 `xml:"anonymity,attr"`
Locale string `xml:"locale,attr"`
Score int64 `xml:"score,attr"`
Comment string `xml:",chardata"`
}
Chat is an xml struct of comment.
type ChatResult ¶
type ChatResult struct {
XMLName xml.Name `xml:"chat_result"`
Thread int64 `xml:"thread,attr"`
Status int64 `xml:"status,attr"`
No int64 `xml:"no,attr"`
}
ChatResult is an xml struct that returns the posting result of comment.
type Client ¶
Client is a API client for niconico.
func (*Client) FollowCommunity ¶
FollowCommunity follows community of communityID.
func (*Client) GetCommunityIDFromLiveID ¶
GetCommunityIDFromLiveID gets the ID of the community that is broadcasting in liveID. No login required.
func (*Client) GetNicovideoUserResponse ¶
func (c *Client) GetNicovideoUserResponse(ctx context.Context, userID int64) (*NicovideoUserResponse, error)
GetNicovideoUserResponse gets the response of the user information API. No login required.
func (*Client) GetPlayerStatus ¶
GetPlayerStatus gets the player status.
func (*Client) GetPostkey ¶
GetPostkey gets the key to be specified when posting a comment.
func (*Client) GetUserInfo ¶
GetUserInfo is get user's information. No login required.
func (*Client) LeaveCommunity ¶
LeaveCommunity leaves the community of communityID.
func (*Client) MakeLiveClient ¶
MakeLiveClient creates a client with broadcast information from liveID.
type Comment ¶
type Comment interface {
// contains filtered or unexported methods
}
Comment is a interface of struct received on the chan returned by PostComment.
type CommentError ¶
type CommentError struct {
// contains filtered or unexported fields
}
CommentError is a struct containing error of StreamingComment function.
type Contents ¶
type Contents struct {
ID string `xml:"id,attr"`
DisableAudio int64 `xml:"disableAudio,attr"`
DisableVideo int64 `xml:"disableVideo,attr"`
StartTime int64 `xml:"start_time,attr"`
Contents string `xml:",chardata"`
}
Contents is detailed information of contents such as URL of RTMP etc.
type ContentsList ¶
type ContentsList struct {
// TODO slice?
Contents Contents `xml:"contents"`
}
ContentsList is a list of contents.
type DialogImage ¶
type DialogImage struct {
Oidashi string `xml:"oidashi"`
}
DialogImage is the URL of the dialog image displayed to the player.
type Error ¶
type Error struct {
Code string `xml:"code"`
}
Error stores the error code if Status of PlayerStatus is not ok.
type LiveClient ¶
type LiveClient struct {
*Client
PlayerStatus *PlayerStatus
// contains filtered or unexported fields
}
LiveClient is a client with broadcast information.
func (*LiveClient) PostComment ¶
PostComment post the comment.
func (*LiveClient) StreamingComment ¶
StreamingComment return the channel that receives comment.
type Marquee ¶
type Marquee struct {
Category string `xml:"category"`
GameKey string `xml:"game_key"`
GameTime int64 `xml:"game_time"`
ForceNicowariOff int64 `xml:"force_nicowari_off"`
}
Marquee is information related to the game etc.
type NicovideoUserResponse ¶
type NicovideoUserResponse struct {
Status string `xml:"status,attr"`
UserInfo UserInfo `xml:"user"`
VitaOption VitaOption `xml:"vita_option"`
Additionals string `xml:"additionals"`
Error UserInfoError `xml:"error"`
}
NicovideoUserResponse is the response of the user information acquisition API.
type Player ¶
type Player struct {
QosAnalytics int64 `xml:"qos_analytics"`
DialogImage DialogImage `xml:"dialog_image"`
IsNoticeViewerBalloonEnabled int64 `xml:"is_notice_viewer_balloon_enabled"`
ErrorReport int64 `xml:"error_report"`
}
Player is the setting information of the player.
type PlayerStatus ¶
type PlayerStatus struct {
Status string `xml:"status,attr"`
Time int64 `xml:"time,attr"`
Stream Stream `xml:"stream"`
User User `xml:"user"`
Rtmp Rtmp `xml:"rtmp"`
Ms Ms `xml:"ms"`
// TODO
TidList interface{} `xml:"tid_list"`
Twitter Twitter `xml:"twitter"`
Player Player `xml:"player"`
Marquee Marquee `xml:"marquee"`
Error Error `xml:"error"`
}
PlayerStatus is niconico live player status.
type PlayerStatusError ¶
PlayerStatusError is an error to return if Status of PlayerStatus is not ok.
func (PlayerStatusError) Error ¶
func (e PlayerStatusError) Error() string
type Press ¶
type Press struct {
DisplayLines int64 `xml:"display_lines"`
DisplayTime int64 `xml:"display_time"`
// TODO
StyleConf interface{} `xml:"style_conf"`
}
Press is unknown data.
type Rtmp ¶
type Rtmp struct {
IsFms int64 `xml:"is_fms,attr"`
RtmptPort int64 `xml:"rtmpt_port,attr"`
URL string `xml:"url"`
Ticket string `xml:"ticket"`
}
Rtmp is information on RTMP.
type SendChat ¶
type SendChat struct {
XMLName xml.Name `xml:"chat"`
Vpos int64 `xml:"vpos,attr"`
Mail string `xml:"mail,attr,omitempty"`
UserID string `xml:"user_id,attr"`
Postkey string `xml:"postkey,attr"`
Comment string `xml:",chardata"`
}
SendChat is a struct to use when posting comment.
type SendThread ¶
type SendThread struct {
XMLName xml.Name `xml:"thread"`
Thread int64 `xml:"thread,attr"`
Version int64 `xml:"version,attr"`
ResFrom int64 `xml:"res_from,attr"`
}
SendThread is an xml struct of the thread to send.
type Stream ¶
type Stream struct {
ID string `xml:"id"`
Title string `xml:"title"`
Description string `xml:"description"`
ProviderType string `xml:"provider_type"`
DefaultCommunity string `xml:"default_community"`
International int64 `xml:"international"`
IsOwner int64 `xml:"is_owner"`
OwnerID int64 `xml:"owner_id"`
OwnerName string `xml:"owner_name"`
IsReserved int64 `xml:"is_reserved"`
IsNiconicoEnqueteEnabled int64 `xml:"is_niconico_enquete_enabled"`
WatchCount int64 `xml:"watch_count"`
CommentCount int64 `xml:"comment_count"`
BaseTime int64 `xml:"base_time"`
OpenTime int64 `xml:"open_time"`
StartTime int64 `xml:"start_time"`
EndTime int64 `xml:"end_time"`
IsRerunStream int64 `xml:"is_rerun_stream"`
// TODO
BourbonURL interface{} `xml:"bourbon_url"`
FullVideo interface{} `xml:"full_video"`
AfterVideo interface{} `xml:"after_video"`
BeforeVideo interface{} `xml:"before_video"`
KickoutVideo interface{} `xml:"kickout_video"`
TwitterTag string `xml:"twitter_tag"`
DanjoCommentMode int64 `xml:"danjo_comment_mode"`
InfinityMode int64 `xml:"infinity_mode"`
Archive int64 `xml:"archive"`
Press Press `xml:"press"`
// TODO
PluginDelay interface{} `xml:"plugin_delay"`
PluginURL interface{} `xml:"plugin_url"`
PluginURLs interface{} `xml:"plugin_urls"`
AllowNetduetto int64 `xml:"allow_netduetto"`
NgScoring int64 `xml:"ng_scoring"`
IsNonarchiveTimeshiftEnabled int64 `xml:"is_nonarchive_timeshift_enabled"`
IsTimeshiftReserved int64 `xml:"is_timeshift_reserved"`
HeaderComment int64 `xml:"header_comment"`
SplitBottom int64 `xml:"split_bottom"`
SplitTop int64 `xml:"split_top"`
BackgroundComment int64 `xml:"background_comment"`
// TODO
FontScale interface{} `xml:"font_scale"`
CommentLock int64 `xml:"comment_lock"`
Telop Telop `xml:"telop"`
ContentsList ContentsList `xml:"contents_list"`
PictureURL string `xml:"picture_url"`
ThumbURL string `xml:"thumb_url"`
// TODO
IsPriorityPrefecture interface{} `xml:"is_priority_prefecture"`
}
Stream is niconico live player status in player status.
type Thread ¶
type Thread struct {
XMLName xml.Name `xml:"thread"`
Resultcode int64 `xml:"resultcode,attr"`
Thread int64 `xml:"thread,attr"`
LastRes int64 `xml:"last_res,attr"`
Ticket string `xml:"ticket,attr"`
Revision int64 `xml:"revision,attr"`
ServerTime int64 `xml:"server_time,attr"`
}
Thread is a struct of xml received immediately after connection.
type Twitter ¶
type Twitter struct {
LiveEnabled int64 `xml:"live_enabled"`
VipModeCount int64 `xml:"vip_mode_count"`
LiveAPIURL string `xml:"live_api_url"`
}
Twitter is Twitter setting information of the niconico live.
type TwitterInfo ¶
type TwitterInfo struct {
Status string `xml:"status"`
ScreenName interface{} `xml:"screen_name"`
FollowersCount int64 `xml:"followers_count"`
IsVip int64 `xml:"is_vip"`
ProfileImageURL string `xml:"profile_image_url"`
AfterAuth int64 `xml:"after_auth"`
TweetToken string `xml:"tweet_token"`
}
TwitterInfo is user's twitter info in user.
type User ¶
type User struct {
UserID int64 `xml:"user_id"`
Nickname string `xml:"nickname"`
IsPremium int64 `xml:"is_premium"`
UserAge int64 `xml:"userAge"`
UserSex int64 `xml:"userSex"`
UserDomain string `xml:"userDomain"`
UserPrefecture int64 `xml:"userPrefecture"`
UserLanguage string `xml:"userLanguage"`
RoomLabel string `xml:"room_label"`
RoomSeetno int64 `xml:"room_seetno"`
// TODO
IsJoin interface{} `xml:"is_join"`
TwitterInfo TwitterInfo `xml:"twitter_info"`
}
User is niconico user data in player status.
type UserInfo ¶
type UserInfo struct {
ID int64 `xml:"id"`
Nickname string `xml:"nickname"`
ThumbnailURL string `xml:"thumbnail_url"`
}
UserInfo is user information.
type UserInfoError ¶
type UserInfoError struct {
Status string
Code string `xml:"code"`
Description string `xml:"description"`
}
UserInfoError is an error when acquiring user information.
func (UserInfoError) Error ¶
func (e UserInfoError) Error() string
type VitaOption ¶
type VitaOption struct {
UserSecret int64 `xml:"user_secret"`
}
VitaOption is an option of Vita.