olivetv

package
v0.6.3 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: Apache-2.0 Imports: 24 Imported by: 3

Documentation

Overview

Package olivetv provides support for retrieving stream urls and other streamers' details.

Index

Examples

Constants

View Source
const (
	HeaderUserAgent = "User-Agent"
	HeaderCookie    = "cookie"
)
View Source
const (
	ANDROID  = "Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.5563.116 Mobile Safari/537.36"
	CHROME   = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36"
	CHROMEOS = "Mozilla/5.0 (X11; CrOS x86_64 15236.80.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.5414.125 Safari/537.36"
	FIREFOX  = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:111.0) Gecko/20100101 Firefox/111.0"
	IE11     = "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"
	IPHONE   = "" /* 135-byte string literal not displayed */
	OPERA    = "" /* 128-byte string literal not displayed */
	SAFARI   = "Mozilla/5.0 (Macintosh; Intel Mac OS X 13_3) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/16.4 Safari/605.1.15"

	EDGE = CHROME
)
View Source
const (
	EmptyRoomName     = ""
	EmptyStreamerName = ""
)

Variables

View Source
var (
	ErrNotSupported = errors.New("streamer not supported")
	ErrSiteInvalid  = errors.New("site invalid")
)
View Source
var (
	ErrCookieNotSet = errors.New("cookie not configured")
)

Functions

This section is empty.

Types

type ITV

type ITV interface {
	Snap() error
	StreamURL() (string, bool)
	RoomName() (string, bool)
	StreamerName() (string, bool)
	SiteName() string
}

type Info

type Info struct {
	Timestamp int64
	// contains filtered or unexported fields
}

type KuaishouAutoGenerated added in v0.5.7

type KuaishouAutoGenerated struct {
	Liveroom struct {
		PlayList []struct {
			LiveStream struct {
				Caption  string `json:"caption"`
				PlayUrls []struct {
					AdaptationSet struct {
						Representation []struct {
							URL     string `json:"url"`
							Bitrate int    `json:"bitrate"`
						} `json:"representation"`
					} `json:"adaptationSet"`
				} `json:"playUrls"`
			} `json:"liveStream"`
			Author struct {
				Name string `json:"name"`
			} `json:"author"`
			IsLiving bool `json:"isLiving"`
		} `json:"playList"`
	} `json:"liveroom"`
}

type Option

type Option func(*TV) error

func SetCookie

func SetCookie(cookie string) Option
Example
package main

import (
	"fmt"

	"github.com/go-olive/olive/foundation/olivetv"
)

func main() {
	douyinCookie := "__ac_nonce=06245c89100e7ab2dd536; __ac_signature=_02B4Z6wo00f01LjBMSAAAIDBwA.aJ.c4z1C44TWAAEx696;"
	t, err := olivetv.New("douyin", "600571451250", olivetv.SetCookie(douyinCookie))
	if err != nil {
		println(err.Error())
		return
	}

	t.Snap()
	fmt.Println(t)
}
Output:

type RoomURL

type RoomURL string

func (RoomURL) SiteID

func (this RoomURL) SiteID() string

func (RoomURL) Stream

func (this RoomURL) Stream() (*TV, error)

type Site

type Site interface {
	Name() string
	Snap(*TV) error
	Permit(RoomURL) (*TV, error)
}

func Sniff

func Sniff(siteID string) (Site, bool)

type SiteID added in v0.5.7

type SiteID = string

type TV

type TV struct {
	SiteID string
	RoomID string

	*Info
	// contains filtered or unexported fields
}
Example
package main

import (
	"fmt"

	"github.com/go-olive/olive/foundation/olivetv"
)

func main() {
	t, err := olivetv.New("huya", "518512")
	if err != nil {
		println(err.Error())
		return
	}

	t.Snap()
	fmt.Println(t)
}
Output:

func New

func New(siteID, roomID string, opts ...Option) (*TV, error)

func NewWithURL

func NewWithURL(roomURL string, opts ...Option) (*TV, error)
Example
package main

import (
	"fmt"

	"github.com/go-olive/olive/foundation/olivetv"
)

func main() {
	t, err := olivetv.NewWithURL("https://www.huya.com/518512")
	if err != nil {
		println(err.Error())
		return
	}

	t.Snap()
	fmt.Println(t)
}
Output:

func (*TV) RoomName

func (tv *TV) RoomName() (string, bool)

func (*TV) SiteName

func (tv *TV) SiteName() string

func (*TV) Snap

func (tv *TV) Snap() error

Snap takes the latest snapshot of the streamer info that could be retrieved individually.

func (*TV) SnapWithCookie

func (tv *TV) SnapWithCookie(cookie string) error

SnapWithCookie takes the latest snapshot of the streamer info that could be retrieved individually with the cookie passed in.

func (*TV) StreamURL

func (tv *TV) StreamURL() (string, bool)

func (*TV) StreamerName

func (tv *TV) StreamerName() (string, bool)

func (*TV) String

func (tv *TV) String() string

type TiktokAutoGenerated added in v0.5.3

type TiktokAutoGenerated struct {
	Data struct {
		Status int    `json:"status"`
		Title  string `json:"title"`
		Owner  struct {
			Nickname string `json:"nickname"`
		} `json:"owner"`
		StreamURL struct {
			RtmpPullURL string `json:"rtmp_pull_url"`
			FlvPullURL  struct {
				FullHd1 string `json:"FULL_HD1"`
				Hd1     string `json:"HD1"`
				Sd1     string `json:"SD1"`
				Sd2     string `json:"SD2"`
			} `json:"flv_pull_url"`
			HlsPullURL string `json:"hls_pull_url"`
		} `json:"stream_url"`
	} `json:"data"`
}

type YoutubePlayerResponse added in v0.5.3

type YoutubePlayerResponse struct {
	ResponseContext struct {
		MainAppWebResponseContext struct {
			LoggedOut bool `json:"loggedOut"`
		} `json:"mainAppWebResponseContext"`
	} `json:"responseContext"`
	PlayabilityStatus struct {
		Status            string `json:"status"`
		Reason            string `json:"reason"`
		LiveStreamability struct {
			LiveStreamabilityRenderer struct {
				VideoID      string `json:"videoId"`
				OfflineSlate struct {
					LiveStreamOfflineSlateRenderer struct {
						ScheduledStartTime string `json:"scheduledStartTime"`
					} `json:"liveStreamOfflineSlateRenderer"`
				} `json:"offlineSlate"`
				PollDelayMs string `json:"pollDelayMs"`
			} `json:"liveStreamabilityRenderer"`
		} `json:"liveStreamability"`
	} `json:"playabilityStatus"`
	StreamingData struct {
		ExpiresInSeconds string `json:"expiresInSeconds"`
		AdaptiveFormats  []struct {
			Itag              int     `json:"itag"`
			URL               string  `json:"url"`
			MimeType          string  `json:"mimeType"`
			QualityLabel      string  `json:"qualityLabel,omitempty"`
			TargetDurationSec float64 `json:"targetDurationSec"`
		} `json:"adaptiveFormats"`
		DashManifestURL string `json:"dashManifestUrl"`
		HlsManifestURL  string `json:"hlsManifestUrl"`
	} `json:"streamingData"`
	VideoDetails struct {
		VideoID          string  `json:"videoId"`
		Title            string  `json:"title"`
		LengthSeconds    string  `json:"lengthSeconds"`
		IsLive           bool    `json:"isLive"`
		ChannelID        string  `json:"channelId"`
		IsOwnerViewing   bool    `json:"isOwnerViewing"`
		ShortDescription string  `json:"shortDescription"`
		AverageRating    float64 `json:"averageRating"`
		AllowRatings     bool    `json:"allowRatings"`
		ViewCount        string  `json:"viewCount"`
		Author           string  `json:"author"`
		IsLiveContent    bool    `json:"isLiveContent"`
	} `json:"videoDetails"`
	Microformat struct {
		PlayerMicroformatRenderer struct {
			Thumbnail struct {
				Thumbnails []struct {
					URL string `json:"url"`
				} `json:"thumbnails"`
			} `json:"thumbnail"`
			LiveBroadcastDetails struct {
				IsLiveNow      bool   `json:"isLiveNow"`
				StartTimestamp string `json:"startTimestamp"`
				EndTimestamp   string `json:"endTimestamp"`
			} `json:"liveBroadcastDetails"`
			PublishDate string `json:"publishDate"`
			UploadDate  string `json:"uploadDate"`
		} `json:"playerMicroformatRenderer"`
	} `json:"microformat"`
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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