withny

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

package withny provides a way to watch a withny channel.

Index

Constants

This section is empty.

Variables

View Source
var DefaultParams = Params{
	QualityConstraint:      api.PlaylistConstraint{},
	PacketLossMax:          20,
	OutFormat:              "{{ .Date }} {{ .Title }} ({{ .ChannelName }}).{{ .Ext }}",
	WriteChat:              false,
	WriteMetaDataJSON:      false,
	WriteThumbnail:         false,
	WaitPollInterval:       10 * time.Second,
	Remux:                  true,
	RemuxFormat:            "mp4",
	Concat:                 true,
	KeepIntermediates:      false,
	ScanDirectory:          "",
	EligibleForCleaningAge: 48 * time.Hour,
	DeleteCorrupted:        true,
	ExtractAudio:           false,
	Labels:                 nil,
	Ignore:                 []string{},
}

DefaultParams is the default set of parameters.

View Source
var (
	// ErrLiveStreamNotOnline is returned when the live stream is not online.
	ErrLiveStreamNotOnline = errors.New("live stream is not online")
)

Functions

func DownloadChat added in v0.2.0

func DownloadChat(ctx context.Context, client *api.Client, chat Chat) error

DownloadChat downloads a withny chat.

func DownloadLiveStream

func DownloadLiveStream(ctx context.Context, client *api.Client, ls LiveStream) error

DownloadLiveStream downloads a withny live stream.

func FormatOutput

func FormatOutput(
	outFormat string,
	meta api.MetaData,
	labels map[string]string,
	ext string,
) (string, error)

FormatOutput formats the output file name.

func PrepareFile

func PrepareFile(
	outFormat string,
	meta api.MetaData,
	labels map[string]string,
	ext string,
) (fName string, err error)

PrepareFile prepares a file with a formatted name.

func PrepareFileAutoRename added in v0.2.5

func PrepareFileAutoRename(
	outFormat string,
	meta api.MetaData,
	labels map[string]string,
	ext string,
) (fName string, err error)

PrepareFileAutoRename prepares a file with a unique name.

Types

type ChannelWatcher

type ChannelWatcher struct {
	*api.Client
	// contains filtered or unexported fields
}

ChannelWatcher is responsible to watch a withny channel.

func NewChannelWatcher

func NewChannelWatcher(client *api.Client, params *Params, channelID string) *ChannelWatcher

NewChannelWatcher creates a new withny channel watcher.

func (*ChannelWatcher) HasNewStream added in v1.2.0

func (w *ChannelWatcher) HasNewStream(
	ctx context.Context,
) (res HasNewStreamResponse, err error)

HasNewStream checks if the live stream is online.

func (*ChannelWatcher) Process

func (w *ChannelWatcher) Process(ctx context.Context, meta api.MetaData, playbackURL string) error

Process runs the whole preparation, download and post-processing pipeline.

func (*ChannelWatcher) Watch

func (w *ChannelWatcher) Watch(ctx context.Context)

Watch watches the channel for any new live stream.

type Chat added in v0.2.0

type Chat struct {
	ChannelID      string
	OutputFileName string
}

Chat encapsulates the withny chat.

type HasNewStreamResponse added in v1.2.0

type HasNewStreamResponse struct {
	HasNewStream bool
	Stream       api.GetStreamsResponseElement
	User         api.GetUserResponse
	PlaybackURL  string
}

HasNewStreamResponse is the response of HasNewStream.

type LiveStream

type LiveStream struct {
	MetaData       api.MetaData
	Params         *Params
	OutputFileName string
	PlaybackURL    string
}

LiveStream encapsulates the withny live stream.

type OptionalParams

type OptionalParams struct {
	QualityConstraint      *api.PlaylistConstraint `yaml:"quality,omitempty"`
	PacketLossMax          *int                    `yaml:"packetLossMax,omitempty"`
	OutFormat              *string                 `yaml:"outFormat,omitempty"`
	WriteChat              *bool                   `yaml:"writeChat,omitempty"`
	WriteMetaDataJSON      *bool                   `yaml:"writeMetaDataJson,omitempty"`
	WriteThumbnail         *bool                   `yaml:"writeThumbnail,omitempty"`
	WaitPollInterval       *time.Duration          `yaml:"waitPollInterval,omitempty"`
	Remux                  *bool                   `yaml:"remux,omitempty"`
	RemuxFormat            *string                 `yaml:"remuxFormat,omitempty"`
	Concat                 *bool                   `yaml:"concat,omitempty"`
	KeepIntermediates      *bool                   `yaml:"keepIntermediates,omitempty"`
	ScanDirectory          *string                 `yaml:"scanDirectory,omitempty"`
	EligibleForCleaningAge *time.Duration          `yaml:"eligibleForCleaningAge,omitempty"`
	DeleteCorrupted        *bool                   `yaml:"deleteCorrupted,omitempty"`
	ExtractAudio           *bool                   `yaml:"extractAudio,omitempty"`
	Labels                 map[string]string       `yaml:"labels,omitempty"`
	Ignore                 []string                `yaml:"ignore,omitempty"`
}

OptionalParams represents the optional parameters for the download.

func (*OptionalParams) Override

func (override *OptionalParams) Override(params *Params)

Override applies the values from the OptionalParams to the Params.

type Params

type Params struct {
	QualityConstraint      api.PlaylistConstraint `yaml:"quality,omitempty"`
	PacketLossMax          int                    `yaml:"packetLossMax,omitempty"`
	OutFormat              string                 `yaml:"outFormat,omitempty"`
	WriteChat              bool                   `yaml:"writeChat,omitempty"`
	WriteMetaDataJSON      bool                   `yaml:"writeMetaDataJson,omitempty"`
	WriteThumbnail         bool                   `yaml:"writeThumbnail,omitempty"`
	WaitPollInterval       time.Duration          `yaml:"waitPollInterval,omitempty"`
	Remux                  bool                   `yaml:"remux,omitempty"`
	RemuxFormat            string                 `yaml:"remuxFormat,omitempty"`
	Concat                 bool                   `yaml:"concat,omitempty"`
	KeepIntermediates      bool                   `yaml:"keepIntermediates,omitempty"`
	ScanDirectory          string                 `yaml:"scanDirectory,omitempty"`
	EligibleForCleaningAge time.Duration          `yaml:"eligibleForCleaningAge,omitempty"`
	DeleteCorrupted        bool                   `yaml:"deleteCorrupted,omitempty"`
	ExtractAudio           bool                   `yaml:"extractAudio,omitempty"`
	Labels                 map[string]string      `yaml:"labels,omitempty"`
	Ignore                 []string               `yaml:"ignore,omitempty"`
}

Params represents the parameters for the download.

func (*Params) Clone

func (p *Params) Clone() *Params

Clone creates a deep copy of the Params struct.

func (*Params) String

func (p *Params) String() string

Directories

Path Synopsis
Package api provide a client for the withny API.
Package api provide a client for the withny API.
Package cleaner provides functions to clean old .ts files.
Package cleaner provides functions to clean old .ts files.

Jump to

Keyboard shortcuts

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