Skip to content

Commit

Permalink
add new error type
Browse files Browse the repository at this point in the history
- new error when stream is not live
  • Loading branch information
abhinavxd committed Mar 14, 2022
1 parent 35bae8f commit 0a92373
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion yt_chat.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ type InitialData struct {
var (
LIVE_CHAT_URL = `https://www.youtube.com/youtubei/v1/live_chat/get_%s?key=%s`
ErrLiveStreamOver error = errors.New("live stream over")
ErrStreamNotLive error = errors.New("stream not live")
)

const (
Expand Down Expand Up @@ -303,7 +304,7 @@ func ParseInitialData(videoUrl string) (string, YtCfg, error) {

subMenuItems := _initialData.Contents.TwoColumnWatchNextResults.ConversationBar.LiveChatRenderer.Header.LiveChatHeaderRenderer.ViewSelector.SortFilterSubMenuRenderer.SubMenuItems
if len(subMenuItems) == 0 {
return "", YtCfg{}, fmt.Errorf("empty initial data, the stream might not be live")
return "", YtCfg{}, ErrStreamNotLive
}
initialContinuationInfo := subMenuItems[1].Continuation.ReloadContinuationData.Continuation
return initialContinuationInfo, _ytCfg, nil
Expand Down

0 comments on commit 0a92373

Please sign in to comment.