tv

package module
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Aug 12, 2022 License: MIT Imports: 19 Imported by: 2

README

OliveTV

GoDoc GitHub Workflow Status Sourcegraph

OliveTV is a CLI utility which gets stream url along with other streamer details.

Installation

  • build from source

    go install github.com/go-olive/tv/cmd/olivetv@latest

  • download from releases

Quickstart

After installing, simply use:

olivetv -u https://www.huya.com/518512

or

olivetv -sid huya -rid 518512

Some platforms might need a cookie, use -c to set one.

eg. olivetv -u https://live.douyin.com/xxx -c cookie

site cookie example
douyin "__ac_nonce=06245c89100e7ab2dd536; __ac_signature=_02B4Z6wo00f01LjBMSAAAIDBwA.aJ.c4z1C44TWAAEx696;"
kuaishou "did=web_d079abeeeba77349c6eb5724363b8958"

API Guide

This API is what powers the cli but is also available to developers that wish to make use of the data OliveTV can retrieve in their own application.

Extracting streams
package main

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

func main() {
	t, err := tv.New("huya", "518512")
	if err != nil {
		return
	}
	if err := t.Snap(); err != nil {
		return
	}
	if url, liveOn := t.StreamUrl(); liveOn {
		println("stream url: ", url)
	}
}

Contributing

All contributions are welcome. Feel free to open a new thread on the issue tracker or submit a new pull request.

For developer, check out template file if you want to add a new site.

Credits

This project is inspired by real-url and streamlink.

Documentation

Index

Examples

Constants

View Source
const (
	KsLiveDetailQuery = `
	query LiveDetail($principalId: String) {  
		liveDetail(principalId: $principalId) {  
			liveStream
		}
	}
	`
	KsUserInfoQuery = `
	query userInfoQuery($principalId: String) {  
		userInfo(principalId: $principalId) {  
			name
			living
		}
	}
	`
)
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 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() error

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

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
cmd

Jump to

Keyboard shortcuts

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