dylive

package module
v1.2.3 Latest Latest
Warning

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

Go to latest
Published: Aug 8, 2025 License: MIT Imports: 7 Imported by: 2

README

dylive

Utilities to watch Douyin live streams. 观看抖音直播工具

dywatch

Watch for new douyin live stream.

go install -v github.com/caiguanhao/dylive/dywatch@latest
# This opens mpv.app on macOS for new live stream
dywatch -q uhd hongjingmayi maidanglaodo | xargs -n1 open -na mpv

# Record live stream
dywatch -q uhd -run 'mkdir -p "{{.User.Name}}" && ffmpeg -i "{{.StreamUrl}}" -y -c copy "{{.User.Name}}/{{.Id}}.flv"' hongjingmayi maidanglaodo

dylive

  • Use keyboard or mouse to navigate different categories.
  • Select multiple live stream rooms and open them at once.

To install:

You must have installed Go first.

go install -v github.com/caiguanhao/dylive/dylive@latest

Also install mpv to play live stream.

Works on macOS, Linux or Windows.

Preview:

https://user-images.githubusercontent.com/1284703/147945918-a20c6c96-88d7-46b6-834e-1650b8033605.mp4

Usage
Video player

By default, dylive uses mpv. If mpv does not exist, IINA and then VLC will be used. If you have installed video player in a different location, set the PLAYER environment variable.

# use different video player command
PLAYER=ffplay dylive

# specify full path
PLAYER=/Applications/IINA.app/Contents/MacOS/iina-cli dylive

# also works for iPhone video player on Apple Silicon Macs
PLAYER=/Applications/OPlayer\ Lite.app dylive
Video player arguments

You can add extra video player command arguments after dylive like this:

# mute first when starting mpv
dylive -- --mute=yes

See mpv's options.

Record while playing

Use mpv's --stream-record option to save live stream to file.

You can use template in player arguments.

List of variables that can be used in template:

  • Room info (which can be obtained with Ctrl-E)
  • Index number of room ({{.Index}} or {{.Nth}})
  • Number of rooms ({{.Total}})
  • Current date/time ({{.Now}}), its format can be changed with TIME_FORMAT environment variable.
# assume you have mpv command in your PATH
dylive -- --stream-record={{.User.Name}}.mp4

# for Windows, you may need to add quotes
dylive -- --no-border "--stream-record={{.User.Name}}-{{.Now}}.mp4"

Press Ctrl-S to view list of commands.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Category

type Category struct {
	Id         string
	Name       string
	Categories []Category
}

func GetCategories

func GetCategories(ctx context.Context) ([]Category, error)

GetCategories gets all Douyin live stream categories.

type Room

type Room struct {
	Id                string
	DouyinId          string
	StatusCode        RoomStatus
	Name              string
	CoverUrl          string
	WebUrl            string
	CurrentUsersCount string
	TotalUsersCount   string
	Category          *Category
	User              User
	StreamUrl         string
	FlvStreamUrls     map[string]string
	HlsStreamUrls     map[string]string
}

func GetRoom added in v1.2.0

func GetRoom(ctx context.Context, douyinId string) (*Room, error)

GetRoom get live stream room details by Douyin ID (抖音号)

func GetRoomsByCategory

func GetRoomsByCategory(ctx context.Context, categoryId string) ([]Room, error)

GetRoomsByCategory gets top 15 Douyin live stream rooms of a category.

func (Room) FlvUrlForQuality added in v1.2.1

func (room Room) FlvUrlForQuality(quality string) string

FlvUrlForQuality returns the .flv stream URL for the given quality (uhd, hd, ld, sd). If no matching URL is found, it returns the room's default StreamUrl.

func (Room) HlsUrlForQuality added in v1.2.1

func (room Room) HlsUrlForQuality(quality string) string

HlsUrlForQuality returns the .m3u8 stream URL for the given quality (uhd, hd, ld, sd). If no matching URL is found, it returns the room's default StreamUrl.

type RoomStatus added in v1.2.1

type RoomStatus = int
const (
	RoomStatusLiveOn RoomStatus = 2 + iota

	RoomStatusLiveOff
)

type User

type User struct {
	Name    string
	Picture string
}

Directories

Path Synopsis
dylive module
dysearch module
dywatch module

Jump to

Keyboard shortcuts

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