Documentation ¶
Overview ¶
niconico client for Golang.
Index ¶
- Variables
- func NewHttpClient() (*http.Client, error)
- type ChannelInfo
- type Client
- func (c *Client) AddMyListItem(mylistId, contentID, description string) error
- func (c *Client) CreateDMCSession(reqsession jsonObject, sessionApiURL string) (*DMCSession, error)
- func (c *Client) CreateDMCSessionById(contentID string) (*DMCSession, error)
- func (c *Client) CreateDMCSessionByVideoData(data *VideoData) (*DMCSession, error)
- func (c *Client) CreateMyList(mylist *MyList) error
- func (c *Client) CreateSmileSessionByVideoData(data *VideoData) (*SmileSession, error)
- func (c *Client) CreateVideoSession(contentID string) (VideoSession, error)
- func (c *Client) DeleteMyList(mylistId string) error
- func (c *Client) DeleteMyListItem(mylistId string, itemID string) error
- func (c *Client) Download(ctx context.Context, session VideoSession, w io.Writer) error
- func (c *Client) DownloadFromDMC(ctx context.Context, session *DMCSession, w io.Writer) error
- func (c *Client) DownloadFromSmile(ctx context.Context, data *VideoData, w io.Writer) error
- func (c *Client) GetAvailableSessions() ([]string, error)
- func (c *Client) GetChannelVideos(channelID string, page int) (*VideoListPage, error)
- func (c *Client) GetDefListItems() ([]*MyListItem, error)
- func (c *Client) GetMyListItems(mylistId string) ([]*MyListItem, error)
- func (c *Client) GetMyLists() ([]*MyList, error)
- func (c *Client) GetPublicMyList(mylistId string) (*MyList, []*VideoInfo, error)
- func (c *Client) GetVideoData(contentId string) (*VideoData, error)
- func (c *Client) LoadLoginSession(path string) error
- func (c *Client) Login(id, password string) error
- func (c *Client) LoginWithJsonFile(path string) error
- func (c *Client) Logout() error
- func (c *Client) SaveLoginSession(path string) error
- func (c *Client) SearchByKeyword(s string, offset, limit int) (*SearchResult, error)
- func (c *Client) SearchByTag(tag string, offset, limit int) (*SearchResult, error)
- func (c *Client) SearchChannel(q string, mode SearchChannelMode, page int) ([]*ChannelInfo, error)
- func (c *Client) SearchVideo(q string, targets, fields []SearchField, sort string, offset, limit int, ...) (*SearchResult, error)
- func (c *Client) SearchVideo2(req *SearchRequest) (*SearchResult, error)
- func (c *Client) SetSessionString(sessionStr string) error
- type DMCSession
- type HLSDownloader
- type HTTPDownloader
- type MyList
- type MyListItem
- type MyListItemType
- type NicoSession
- type SearchChannelMode
- type SearchField
- type SearchFilter
- type SearchRequest
- type SearchResult
- type SearchResultItem
- type SmileSession
- type SourceStream
- type SourceStream2
- type VideoData
- func (data *VideoData) GenDMCSessionReq(audio, video string) (jsonObject, error)
- func (v *VideoData) GetAvailableAudio() *SourceStream
- func (v *VideoData) GetAvailableSource(sources []*SourceStream) *SourceStream
- func (v *VideoData) GetAvailableVideo() *SourceStream
- func (v *VideoData) GetEncryption() map[string]interface{}
- func (v *VideoData) GetSessionData() map[string]interface{}
- func (v *VideoData) IsDMC() bool
- func (v *VideoData) IsNeedPayment() bool
- func (v *VideoData) IsSmile() bool
- func (v *VideoData) SmileFileExtension() string
- type VideoInfo
- type VideoListPage
- type VideoSession
Constants ¶
This section is empty.
Variables ¶
View Source
var ( AuthenticationRequired = errors.New("authentication required") InvalidResponse = errors.New("invalid response received") )
errors
View Source
var DefaultFields = []SearchField{ SearchFieldContentID, SearchFieldTitle, SearchFieldThumbnailURL, SearchFieldTags, SearchFieldStartTime, SearchFieldUserID, SearchFieldChannelID, SearchFieldLengthSeconds, }
View Source
var RequestLogger *log.Logger = nil
View Source
var UserAgent = "Mozilla/5.0 Nigonigo/1.0"
Functions ¶
func NewHttpClient ¶
Types ¶
type ChannelInfo ¶
type Client ¶
type Client struct { HttpClient *http.Client Session *NicoSession }
func (*Client) AddMyListItem ¶
func (*Client) CreateDMCSession ¶
func (c *Client) CreateDMCSession(reqsession jsonObject, sessionApiURL string) (*DMCSession, error)
func (*Client) CreateDMCSessionById ¶
func (c *Client) CreateDMCSessionById(contentID string) (*DMCSession, error)
func (*Client) CreateDMCSessionByVideoData ¶
func (c *Client) CreateDMCSessionByVideoData(data *VideoData) (*DMCSession, error)
func (*Client) CreateMyList ¶
func (*Client) CreateSmileSessionByVideoData ¶
func (c *Client) CreateSmileSessionByVideoData(data *VideoData) (*SmileSession, error)
func (*Client) CreateVideoSession ¶
func (c *Client) CreateVideoSession(contentID string) (VideoSession, error)
func (*Client) DeleteMyList ¶
func (*Client) DeleteMyListItem ¶
func (*Client) DownloadFromDMC ¶
func (*Client) DownloadFromSmile ¶
func (*Client) GetAvailableSessions ¶
func (*Client) GetChannelVideos ¶
func (c *Client) GetChannelVideos(channelID string, page int) (*VideoListPage, error)
func (*Client) GetDefListItems ¶
func (c *Client) GetDefListItems() ([]*MyListItem, error)
func (*Client) GetMyListItems ¶
func (c *Client) GetMyListItems(mylistId string) ([]*MyListItem, error)
func (*Client) GetMyLists ¶
func (*Client) GetPublicMyList ¶
func (*Client) LoadLoginSession ¶
func (*Client) LoginWithJsonFile ¶
func (*Client) SaveLoginSession ¶
func (*Client) SearchByKeyword ¶
func (c *Client) SearchByKeyword(s string, offset, limit int) (*SearchResult, error)
func (*Client) SearchByTag ¶
func (c *Client) SearchByTag(tag string, offset, limit int) (*SearchResult, error)
func (*Client) SearchChannel ¶
func (c *Client) SearchChannel(q string, mode SearchChannelMode, page int) ([]*ChannelInfo, error)
func (*Client) SearchVideo ¶
func (c *Client) SearchVideo(q string, targets, fields []SearchField, sort string, offset, limit int, filter SearchFilter) (*SearchResult, error)
func (*Client) SearchVideo2 ¶
func (c *Client) SearchVideo2(req *SearchRequest) (*SearchResult, error)
func (*Client) SetSessionString ¶
type DMCSession ¶
type DMCSession struct { ID string `json:"id"` ContentURI string `json:"content_uri"` Protocol struct { Name string `json:"name"` Parameters map[string]interface{} `json:"parameters"` } `json:"protocol"` KeepMethod struct { Heartbeat *struct { LifetimeMs int `json:"lifetime"` OnetimeToken string `json:"onetime_token"` } `json:"heartbeat"` } `json:"keep_method"` // contains filtered or unexported fields }
func (*DMCSession) FileExtension ¶
func (s *DMCSession) FileExtension() string
func (*DMCSession) IsHTTP ¶
func (s *DMCSession) IsHTTP() bool
IsHTTP returns true if protocol is http or https
func (*DMCSession) IsRTMP ¶
func (s *DMCSession) IsRTMP() bool
IsRTMP returns true if protocol is rtmp
type HLSDownloader ¶
func NewHLSDownloader ¶
func NewHLSDownloader(client *http.Client) *HLSDownloader
func (*HLSDownloader) GetSegment ¶
func (*HLSDownloader) GetSegment2 ¶
type HTTPDownloader ¶
func NewHTTPDownloader ¶
func NewHTTPDownloader(client *http.Client) *HTTPDownloader
type MyList ¶
type MyList struct { ID string `json:"id"` Name string `json:"name"` Description string `json:"description"` UserID int64 `json:"user_id,string"` Public int `json:"public,string"` CreatedTime int64 `json:"create_time"` UpdatedTime int64 `json:"update_time"` SortOrder string `json:"sort_order"` PlaylistToken string `json:"watch_playlist"` }
type MyListItem ¶
type MyListItemType ¶
type MyListItemType int
const ( MyListItemTypeVideo MyListItemType = 0 MyListItemTypeSeiga MyListItemType = 5 MyListItemTypeBook MyListItemType = 6 )
func (*MyListItemType) UnmarshalJSON ¶
func (m *MyListItemType) UnmarshalJSON(b []byte) error
type NicoSession ¶
type SearchChannelMode ¶
type SearchChannelMode string
const ( SearchChannelModeKeyword SearchChannelMode = "s" SearchChannelModeTag SearchChannelMode = "t" )
type SearchField ¶
type SearchField = string
const ( SearchFieldContentID SearchField = "contentId" SearchFieldTitle SearchField = "title" SearchFieldLengthSeconds SearchField = "lengthSeconds" SearchFieldThumbnailURL SearchField = "thumbnailUrl" SearchFieldViewCounter SearchField = "viewCounter" SearchFieldMylistCounter SearchField = "mylistCounter" SearchFieldCommentCounter SearchField = "commentCounter" SearchFieldDescription SearchField = "description" SearchFieldTags SearchField = "tags" SearchFieldTagsExact SearchField = "tagsExact" SearchFieldLockTagsExact SearchField = "lockTagsExact" SearchFieldCategoryTags SearchField = "categoryTags" SearchFieldGenre SearchField = "genre" SearchFieldGenreKey SearchField = "genre.keyword" SearchFieldStartTime SearchField = "startTime" SearchFieldUserID SearchField = "userId" SearchFieldChannelID SearchField = "channelId" SearchFieldThreadID SearchField = "threadId" )
type SearchFilter ¶
type SearchFilter interface{}
TODO
func AndFilter ¶
func AndFilter(filters []SearchFilter) SearchFilter
func EqualFilter ¶
func EqualFilter(field SearchField, value string) SearchFilter
func NotFilter ¶
func NotFilter(filter SearchFilter) SearchFilter
func OrFilter ¶
func OrFilter(filters []SearchFilter) SearchFilter
func RangeFilter ¶
func RangeFilter(field SearchField, from, to string, includeUpper bool) SearchFilter
type SearchRequest ¶
type SearchRequest struct { Query string Offset int Limit int Sort string Targets []SearchField Filter SearchFilter Fields []SearchField }
type SearchResult ¶
type SearchResult struct { TotalCount int Offset int Items []*SearchResultItem }
type SearchResultItem ¶
type SearchResultItem struct { ContentID string `json:"contentId"` Title string `json:"title"` ThumbnailURL string `json:"thumbnailUrl"` Duration int `json:"lengthSeconds"` ViewCount int `json:"viewCounter"` MylistCount int `json:"mylistCounter"` CommentCount int `json:"commentCounter"` Description int `json:"description"` UserID int `json:"userId"` ChannelID int `json:"channelId"` ThreadID int `json:"threadId"` Tags string `json:"tags"` StartTime string `json:"startTime"` }
type SmileSession ¶
type SmileSession struct {
VideoData *VideoData
}
func (*SmileSession) FileExtension ¶
func (s *SmileSession) FileExtension() string
type SourceStream ¶
type SourceStream2 ¶
type SourceStream2 struct { ID string `json:"id"` Available bool `json:"isAvailable"` Metadata struct { SamplingRate int `json:"samplingRate"` Bitrate int `json:"bitrate"` Resolution struct { Width int `json:"width"` Height int `json:"height"` } `json:"resolution"` } `json:"metadata"` }
func (*SourceStream2) SourceStream ¶
func (s *SourceStream2) SourceStream() *SourceStream
type VideoData ¶
type VideoData struct { Video struct { ContentID string `json:"id"` Title string `json:"title"` ThumbnailURL string `json:"thumbnailURL"` Description string `json:"description"` Duration int `json:"duration"` PostedDateTime string `json:"postedDateTime"` ViewCount int `json:"viewCount"` MylistCount int `json:"mylistCount"` // Deprecated? DMC struct { Quality struct { Audios []*SourceStream `json:"audios"` Videos []*SourceStream `json:"videos"` } `json:"quality"` SessionAPI map[string]interface{} `json:"session_api"` TrackingID string `json:"tracking_id"` Encryption map[string]interface{} `json:"encryption"` } `json:"dmcInfo"` // Deprecated? Smile struct { URL string `json:"url"` CurrentQualityID string `json:"currentQualityId"` QualityIds []string `json:"qualityIds"` IsSlowLine bool `json:"isSlowLine"` } `json:"smileInfo"` } `json:"video"` // temp1.media.delivery.movie.audios Media struct { Delivery struct { Movie struct { Audios []*SourceStream2 `json:"audios"` Videos []*SourceStream2 `json:"videos"` Session map[string]interface{} `json:"session"` } `json:"movie"` Encryption map[string]interface{} `json:"encryption"` TrackingID string `json:"trackingId"` } `json:"delivery"` DeliveryLegacy struct { } `json:"deliveryLegacy"` } `json:"media"` Thread map[string]interface{} `json:"thread"` Owner map[string]interface{} `json:"owner"` Channel map[string]interface{} `json:"channel"` Context map[string]interface{} `json:"context"` }
JSON.parse($("#js-initial-watch-data").dataset.apiData);
func (*VideoData) GenDMCSessionReq ¶
func (*VideoData) GetAvailableAudio ¶
func (v *VideoData) GetAvailableAudio() *SourceStream
func (*VideoData) GetAvailableSource ¶
func (v *VideoData) GetAvailableSource(sources []*SourceStream) *SourceStream
func (*VideoData) GetAvailableVideo ¶
func (v *VideoData) GetAvailableVideo() *SourceStream
func (*VideoData) GetEncryption ¶
func (*VideoData) GetSessionData ¶
func (*VideoData) IsNeedPayment ¶
func (*VideoData) SmileFileExtension ¶
type VideoInfo ¶
type VideoInfo struct { ContentID string `json:"video_id"` Title string `json:"title"` ThumbnailURL string `json:"thumbnail_url"` Duration int `json:"length_seconds,string"` ViewCount int `json:"view_counter,string"` MylistCount int `json:"mylist_counter,string"` CommentCount int `json:"num_res,string"` StartTime int64 `json:"first_retrieve"` Deleted int `json:"deleted,string"` }
type VideoListPage ¶
type VideoSession ¶
type VideoSession interface {
FileExtension() string
}
Source Files ¶
Click to show internal directories.
Click to hide internal directories.