chzzk

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2025 License: MIT Imports: 8 Imported by: 0

README

Chzzk

Unofficial CHZZK API client for Go

Example

Get HLS URL from the live detail endpoint:

package main

import (
	"fmt"

	"github.com/jaesung9507/chzzk"
)

func main() {
	client := chzzk.NewClient(nil)

	liveDetail, err := client.GetLiveDetail("CHANNEL_ID")
	if err != nil {
		panic(err)
	}

	playback, err := liveDetail.GetLivePlayback()
	if err != nil {
		panic(err)
	}

	fmt.Println("HLS URL:", playback.GetHLSPath())
}

Disclaimer

This Go client uses unofficial APIs of NAVER CHZZK and is not affiliated with them in any way.

CHZZK may change or disable these APIs at any time, which may cause this client to stop working without notice.

License

MIT License

Documentation

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
}

func NewClient

func NewClient(client *http.Client) *Client

func (*Client) GetClipDetail added in v0.2.0

func (c *Client) GetClipDetail(clipID string) (*ClipDetailResp, error)

func (*Client) GetClipMP4URL added in v0.2.0

func (c *Client) GetClipMP4URL(clipID, videoID string) (map[string]string, error)

func (*Client) GetLiveDetail

func (c *Client) GetLiveDetail(channelID string) (*LiveDetailResp, error)

func (*Client) GetLiveStatus

func (c *Client) GetLiveStatus(channelID string) (*LiveStatusResp, error)

func (*Client) GetVideo added in v0.1.0

func (c *Client) GetVideo(videoNo int64) (*VideoResp, error)

func (*Client) GetVideoMP4URL added in v0.1.0

func (c *Client) GetVideoMP4URL(videoNo int64, videoID, inKey string) (map[string]string, error)

type ClipDetailResp added in v0.2.0

type ClipDetailResp struct {
	Code    int `json:"code"`
	Message any `json:"message"`
	Content struct {
		ClipUID           string `json:"clipUID"`
		VideoID           string `json:"videoId"`
		ClipTitle         string `json:"clipTitle"`
		ThumbnailImageURL string `json:"thumbnailImageUrl"`
		CategoryType      string `json:"categoryType"`
		ClipCategory      string `json:"clipCategory"`
		Duration          int    `json:"duration"`
		Adult             bool   `json:"adult"`
		BlindType         any    `json:"blindType"`
		KrOnlyViewing     bool   `json:"krOnlyViewing"`
		VodStatus         string `json:"vodStatus"`
		RecId             string `json:"recId"`
		CreatedDate       string `json:"createdDate"`
		OptionalProperty  any    `json:"optionalProperty"`
	} `json:"content"`
}

type LiveDetailResp

type LiveDetailResp struct {
	Code    int `json:"code"`
	Message any `json:"message"`
	Content struct {
		LiveID                        int64    `json:"liveId"`
		LiveTitle                     string   `json:"liveTitle"`
		Status                        string   `json:"status"`
		LiveImageURL                  string   `json:"liveImageUrl"`
		DefaultThumbnailImageURL      any      `json:"defaultThumbnailImageUrl"`
		ConcurrentUserCount           int      `json:"concurrentUserCount"`
		CvExposure                    bool     `json:"cvExposure"`
		AccumulateCount               int      `json:"accumulateCount"`
		OpenDate                      string   `json:"openDate"`
		CloseDate                     *string  `json:"closeDate"`
		Adult                         bool     `json:"adult"`
		KrOnlyViewing                 bool     `json:"krOnlyViewing"`
		ClipActive                    bool     `json:"clipActive"`
		Tags                          []string `json:"tags"`
		ChatChannelId                 string   `json:"chatChannelId"`
		CategoryType                  string   `json:"categoryType"`
		LiveCategory                  string   `json:"liveCategory"`
		LiveCategoryValue             string   `json:"liveCategoryValue"`
		ChatActive                    bool     `json:"chatActive"`
		ChatAvailableGroup            string   `json:"chatAvailableGroup"`
		PaidPromotion                 bool     `json:"paidPromotion"`
		ChatAvailableCondition        string   `json:"chatAvailableCondition"`
		MinFollowerMinute             int      `json:"minFollowerMinute"`
		AllowSubscriberInFollowerMode bool     `json:"allowSubscriberInFollowerMode"`
		LivePlaybackJson              string   `json:"livePlaybackJson"`
		P2PQuality                    []string `json:"p2pQuality"`
		TimeMachineActive             bool     `json:"timeMachineActive"`
		TimeMachinePlayback           bool     `json:"timeMachinePlayback"`
		Channel                       any      `json:"channel"`
		LivePollingStatusJson         string   `json:"livePollingStatusJson"`
		UserAdultStatus               *string  `json:"userAdultStatus"`
		BlindType                     any      `json:"blindType"`
		ChatDonationRankingExposure   bool     `json:"chatDonationRankingExposure"`
		LogPower                      any      `json:"logPower"`
		AdParameter                   any      `json:"adParameter"`
		DropsCampaignNo               any      `json:"dropsCampaignNo"`
		WatchPartyNo                  int      `json:"watchPartyNo"`
		WatchPartyTag                 string   `json:"watchPartyTag"`
		WatchPartyPaidProductId       any      `json:"watchPartyPaidProductId"`
		Dab                           bool     `json:"dab"`
		Earthquake                    bool     `json:"earthquake"`
		PaidProduct                   any      `json:"paidProduct"`
		TvAppViewingPolicyType        string   `json:"tvAppViewingPolicyType"`
		Party                         any      `json:"party"`
	} `json:"content"`
}

func (*LiveDetailResp) GetLivePlayback

func (r *LiveDetailResp) GetLivePlayback() (*Playback, error)

type LiveStatusResp

type LiveStatusResp struct {
	Code    int `json:"code"`
	Message any `json:"message"`
	Content struct {
		LiveTitle                     string   `json:"liveTitle"`
		Status                        string   `json:"status"`
		ConcurrentUserCount           int      `json:"concurrentUserCount"`
		CvExposure                    bool     `json:"cvExposure"`
		AccumulateCount               int      `json:"accumulateCount"`
		PaidPromotion                 bool     `json:"paidPromotion"`
		Adult                         bool     `json:"adult"`
		KrOnlyViewing                 bool     `json:"krOnlyViewing"`
		OpenDate                      string   `json:"openDate"`
		CloseDate                     *string  `json:"closeDate"`
		ClipActive                    bool     `json:"clipActive"`
		ChatChannelId                 string   `json:"chatChannelId"`
		Tags                          []string `json:"tags"`
		CategoryType                  string   `json:"categoryType"`
		LiveCategory                  string   `json:"liveCategory"`
		LiveCategoryValue             string   `json:"liveCategoryValue"`
		LivePollingStatusJson         string   `json:"livePollingStatusJson"`
		FaultStatus                   any      `json:"faultStatus"`
		UserAdultStatus               *string  `json:"userAdultStatus"`
		AbroadCountry                 bool     `json:"abroadCountry"`
		BlindType                     any      `json:"blindType"`
		PlayerRecommendContent        any      `json:"playerRecommendContent"`
		ChatActive                    bool     `json:"chatActive"`
		ChatAvailableGroup            string   `json:"chatAvailableGroup"`
		ChatAvailableCondition        string   `json:"chatAvailableCondition"`
		MinFollowerMinute             int      `json:"minFollowerMinute"`
		AllowSubscriberInFollowerMode bool     `json:"allowSubscriberInFollowerMode"`
		ChatSlowModeSec               int      `json:"chatSlowModeSec"`
		ChatEmojiMode                 bool     `json:"chatEmojiMode"`
		ChatDonationRankingExposure   bool     `json:"chatDonationRankingExposure"`
		DropsCampaignNo               any      `json:"dropsCampaignNo"`
		LiveTokenList                 []string `json:"liveTokenList"`
		WatchPartyNo                  int      `json:"watchPartyNo"`
		WatchPartyTag                 string   `json:"watchPartyTag"`
		TimeMachineActive             bool     `json:"timeMachineActive"`
		ChannelId                     string   `json:"channelId"`
		LastAdultReleaseDate          any      `json:"lastAdultReleaseDate"`
		LastKrOnlyViewingReleaseDate  any      `json:"lastKrOnlyViewingReleaseDate"`
		LastTvAppAllowedDate          any      `json:"lastTvAppAllowedDate"`
		TvAppViewingPolicyType        string   `json:"tvAppViewingPolicyType"`
		LogPowerActive                bool     `json:"logPowerActive"`
		LogPowerRankingExposure       bool     `json:"logPowerRankingExposure"`
	} `json:"content"`
}

type Playback added in v0.1.0

type Playback struct {
	Meta struct {
		VideoId   string `json:"videoId"`
		StreamSeq int64  `json:"streamSeq"`
		LiveId    string `json:"liveId"`
		PaidLive  bool   `json:"paidLive"`
		CDNInfo   struct {
			CDNType string `json:"cdnType"`
		} `json:"cdnInfo"`
		CmcdEnabled      bool    `json:"cmcdEnabled"`
		LiveRewind       bool    `json:"liveRewind,omitempty"`
		Duration         float64 `json:"duration,omitempty"`
		PlaybackAuthType string  `json:"playbackAuthType"`
	} `json:"meta"`
	ServiceMeta *struct {
		ContentType string `json:"contentType"`
	} `json:"serviceMeta,omitempty"`
	Live *struct {
		Start       string `json:"start"`
		Open        string `json:"open"`
		TimeMachine bool   `json:"timeMachine"`
		Status      string `json:"status"`
	} `json:"live,omitempty"`
	API []struct {
		Name string `json:"name"`
		Path string `json:"path"`
	} `json:"api"`
	Media []struct {
		MediaId       string `json:"mediaId"`
		Protocol      string `json:"protocol"`
		Path          string `json:"path"`
		Latency       string `json:"latency,omitempty"`
		EncodingTrack []struct {
			EncodingTrackId    string `json:"encodingTrackId"`
			Path               string `json:"path,omitempty"`
			VideoProfile       string `json:"videoProfile,omitempty"`
			AudioProfile       string `json:"audioProfile,omitempty"`
			P2PPath            string `json:"p2pPath,omitempty"`
			P2PPathURLEncoding string `json:"p2pPathUrlEncoding,omitempty"`
			VideoCodec         string `json:"videoCodec,omitempty"`
			VideoBitRate       int64  `json:"videoBitRate,omitempty"`
			AudioCodec         string `json:"audioCodec,omitempty"`
			AudioBitRate       int64  `json:"audioBitRate"`
			AudioOnly          bool   `json:"audioOnly,omitempty"`
			VideoFrameRate     string `json:"videoFrameRate,omitempty"`
			VideoWidth         int    `json:"videoWidth,omitempty"`
			VideoHeight        int    `json:"videoHeight,omitempty"`
			AudioSamplingRate  int64  `json:"audioSamplingRate"`
			AudioChannel       int    `json:"audioChannel"`
			AvoidReencoding    bool   `json:"avoidReencoding"`
			VideoDynamicRange  string `json:"videoDynamicRange,omitempty"`
		} `json:"encodingTrack"`
	} `json:"media"`
	Thumbnail struct {
		SnapshotThumbnailTemplate string `json:"snapshotThumbnailTemplate"`
		SpriteSeekingThumbnail    struct {
			SpriteFormat struct {
				RowCount        int    `json:"rowCount"`
				ColumnCount     int    `json:"columnCount"`
				IntervalType    string `json:"intervalType"`
				Interval        int    `json:"interval"`
				ThumbnailWidth  int    `json:"thumbnailWidth"`
				ThumbnailHeight int    `json:"thumbnailHeight"`
			} `json:"spriteFormat"`
			URLTemplate       string `json:"urlTemplate"`
			ProcessingSeconds int    `json:"processingSeconds"`
		} `json:"spriteSeekingThumbnail"`
		Types []string `json:"types"`
	} `json:"thumbnail"`
	Multiview *[]struct{} `json:"multiview,omitempty"`
}

func (*Playback) GetHLSPath added in v0.1.0

func (i *Playback) GetHLSPath() string

type VideoResp added in v0.1.0

type VideoResp struct {
	Code    int `json:"code"`
	Message any `json:"message"`
	Content struct {
		VideoNo                int64    `json:"videoNo"`
		VideoId                string   `json:"videoId"`
		VideoTitle             string   `json:"videoTitle"`
		VideoType              string   `json:"videoType"`
		PublishDate            string   `json:"publishDate"`
		ThumbnailImageURL      string   `json:"thumbnailImageUrl"`
		TrailerURL             *string  `json:"trailerUrl"`
		Duration               int64    `json:"duration"`
		ReadCount              int64    `json:"readCount"`
		PublishDateAt          int64    `json:"publishDateAt"`
		CategoryType           string   `json:"categoryType"`
		VideoCategory          string   `json:"videoCategory"`
		VideoCategoryValue     string   `json:"videoCategoryValue"`
		Exposure               bool     `json:"exposure"`
		Adult                  bool     `json:"adult"`
		ClipActive             bool     `json:"clipActive"`
		LivePv                 int64    `json:"livePv"`
		Tags                   []string `json:"tags"`
		Channel                any      `json:"channel"`
		BlindType              any      `json:"blindType"`
		WatchTimeline          any      `json:"watchTimeline"`
		PaidProductId          any      `json:"paidProductId"`
		TvAppViewingPolicyType string   `json:"tvAppViewingPolicyType"`
		PaidPromotion          bool     `json:"paidPromotion"`
		InKey                  string   `json:"inKey"`
		LiveOpenDate           string   `json:"liveOpenDate"`
		VodStatus              string   `json:"vodStatus"`
		LiveRewindPlaybackJson *string  `json:"liveRewindPlaybackJson"`
		PrevVideo              any      `json:"prevVideo"`
		NextVideo              any      `json:"nextVideo"`
		UserAdultStatus        any      `json:"userAdultStatus"`
		AdParameter            any      `json:"adParameter"`
		VideoChatEnabled       bool     `json:"videoChatEnabled"`
		VideoChatChannelId     string   `json:"videoChatChannelId"`
		PaidProduct            any      `json:"paidProduct"`
		Dab                    bool     `json:"dab"`
	} `json:"content"`
}

func (*VideoResp) GetLiveRewindPlayback added in v0.1.0

func (r *VideoResp) GetLiveRewindPlayback() (*Playback, error)

Jump to

Keyboard shortcuts

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