tv

package module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2022 License: MIT Imports: 15 Imported by: 2

README

tv

Documentation

Index

Examples

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type ITv

type ITv interface {
	Snap()
	StreamUrl() (string, bool)
	RoomName() (string, bool)
	StreamerName() (string, bool)
}

type Info

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

type Option

type Option func(*Tv) error

func SetCookie added in v0.1.0

func SetCookie(cookie string) Option
Example
package main

import (
	"fmt"

	"github.com/go-olive/tv"
)

func main() {
	douyinCookie := "__ac_nonce=06245c89100e7ab2dd536; __ac_signature=_02B4Z6wo00f01LjBMSAAAIDBwA.aJ.c4z1C44TWAAEx696;"
	t, err := tv.New("douyin", "600571451250", tv.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 Tv

type Tv struct {
	SiteID string
	RoomID string

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

import (
	"fmt"

	"github.com/go-olive/tv"
)

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

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

func New added in v0.1.0

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

func NewWithUrl added in v0.1.0

func NewWithUrl(roomUrl string, opts ...Option) (*Tv, error)
Example
package main

import (
	"fmt"

	"github.com/go-olive/tv"
)

func main() {
	t, err := tv.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 added in v0.1.0

func (tv *Tv) SiteName() string

func (*Tv) Snap added in v0.1.0

func (tv *Tv) Snap()

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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