protocol

package
v0.0.0-...-f0b9b21 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrAcknowledgedTimeout = Error("acknowledged timeout")

	ErrIDMustBeGreaterThan0             = Error("`id` must be greater than 0")
	ErrQualityIDMustBeGreaterThan0      = Error("`q` must be greater than 0")
	ErrReleaseGroupIDMustBeGreaterThan0 = Error("`rg` must be greater than 0")

	ErrUnexpectedNilItem = Error("unexpected `nil` item")

	ErrExpectedValidJSON = Error("expected a valid JSON")

	ErrUnexpectedRequestType = Error("unexpected request type")

	ErrTypeIsRequired       = Error("`typ` is required")
	ErrPercentageIsRequired = Error("`pct` is required")

	ErrAddressIsRequired = Error("`addr` (address) is required")
	ErrAddressIsInvalid  = Error("`addr` (address) is not a valid address")

	ErrSizeIsRequired = Error("`sz` (size) is required")
	ErrSizeIsNotValid = Error("`sz` (size) is not valid (>0)")

	ErrNameIsRequired = Error("`n` (name) is required")

	ErrDataIsRequired = Error("`d` (data) is required")

	ErrMessageIsRequired = Error("`m` (message) is required")
	ErrMessageIsEmpty    = Error("`m` (message) is empty")
)

Variables

This section is empty.

Functions

func ErrUnsupportedOpcode

func ErrUnsupportedOpcode(op Opcode) error

func MustBytes

func MustBytes[D Data](opcode Opcode, data D) []byte

func NewBytes

func NewBytes[D Data](opcode Opcode, data D) ([]byte, error)

Types

type Anime

type Anime struct {
	ID            int64  `json:"d"`
	Title         string `json:"t"`
	Episode       string `json:"e"`
	QualityHeight int    `json:"h"`
	ReleaseGroup  string `json:"rg"`
}

func (Anime) Equal

func (a Anime) Equal(other Anime) bool

func (Anime) String

func (a Anime) String() string

type Data

type Data interface {
	Validate() error
}

type DataAcknowledged

type DataAcknowledged struct{}

func (DataAcknowledged) Validate

func (DataAcknowledged) Validate() error

type DataActivityCancel

type DataActivityCancel []*DataDownloadCancelItem

func (DataActivityCancel) Validate

func (items DataActivityCancel) Validate() error

type DataActivityDifference

type DataActivityDifference struct {
	Token    DifferenceToken           `json:"tkn"`
	Anime    Anime                     `json:"an"`
	Progress *DataActivityProgressItem `json:"pg"`
}

func (DataActivityDifference) String

func (d DataActivityDifference) String() string

func (DataActivityDifference) Validate

func (d DataActivityDifference) Validate() error

type DataActivityDifferences

type DataActivityDifferences []*DataActivityDifference

func (DataActivityDifferences) String

func (d DataActivityDifferences) String() string

func (DataActivityDifferences) Validate

func (d DataActivityDifferences) Validate() error

type DataActivityDownload

type DataActivityDownload []*DataDownloadItem

func (DataActivityDownload) Len

func (d DataActivityDownload) Len() int

func (DataActivityDownload) Less

func (d DataActivityDownload) Less(i, j int) bool

Less primarily sorts by the priority

func (DataActivityDownload) Swap

func (d DataActivityDownload) Swap(i, j int)

func (DataActivityDownload) Validate

func (items DataActivityDownload) Validate() error

type DataActivityGetProgress

type DataActivityGetProgress struct{}

func (DataActivityGetProgress) Validate

func (d DataActivityGetProgress) Validate() error

type DataActivityMetadata

type DataActivityMetadata struct {
	Title        string  `json:"t"`
	Episode      string  `json:"e"`
	Height       int     `json:"h"`
	ReleaseGroup string  `json:"rg"`
	Thumbnail    string  `json:"th"`
	CRC32        string  `json:"crc32"`
	Duration     float64 `json:"dur"`
	Size         int64   `json:"sz"`
	VideoPath    string  `json:"vp"`
}

func (DataActivityMetadata) Validate

func (DataActivityMetadata) Validate() error

type DataActivityProgress

type DataActivityProgress map[string]struct {
	ID            int64                                                   `json:"d"`
	ReleaseGroups map[string]map[string]map[int]*DataActivityProgressItem `json:"rg"`
}

func (DataActivityProgress) Validate

func (d DataActivityProgress) Validate() error

type DataActivityProgressItem

type DataActivityProgressItem struct {
	Type ProgressType `json:"typ"`

	Percentage float64 `json:"pct"`
	Speed      float64 `json:"sp"`

	// Download/upload properties
	CurrentFilesize *float64 `json:"cur_sz,omitempty"`
	Filesize        *float64 `json:"sz,omitempty"`

	// Transcode properties
	CurrentDuration *float64 `json:"cur_dur,omitempty"`
	Duration        *float64 `json:"dur,omitempty"`
}

DataActivityProgressItem is used show the progress for the possible progress types.

func (DataActivityProgressItem) String

func (p DataActivityProgressItem) String() string

func (DataActivityProgressItem) Validate

func (p DataActivityProgressItem) Validate() error

type DataDownloadCancelItem

type DataDownloadCancelItem struct {
	ID             int64  `json:"d"`
	QualityID      *int64 `json:"q,omitempty"`
	ReleaseGroupID int64  `json:"rg"`
}

type DataDownloadItem

type DataDownloadItem struct {
	ID             int64  `json:"d"`
	QualityID      *int64 `json:"q,omitempty"`
	ReleaseGroupID int64  `json:"rg"`
	Prioritize     *bool  `json:"p,omitempty"`
}

func (*DataDownloadItem) Equals

func (d *DataDownloadItem) Equals(in *DataDownloadItem) bool

func (*DataDownloadItem) String

func (d *DataDownloadItem) String() string

type DataException

type DataException struct {
	Message string `json:"m"`
}

func (DataException) Validate

func (d DataException) Validate() error

type DataStatusIRC

type DataStatusIRC struct {
	Connected bool `json:"c"`
}

func (DataStatusIRC) Validate

func (DataStatusIRC) Validate() error

type DataStatusJob

type DataStatusJob struct {
	State        JobState      `json:"s"`
	ID           string        `json:"d"`
	LastActivity time.Time     `json:"la,omitempty"`
	NextActivity *time.Time    `json:"na,omitempty"`
	StartedAt    *time.Time    `json:"sat,omitempty"`
	EndedAt      *time.Time    `json:"eat,omitempty"`
	Period       time.Duration `json:"p"`
}

func (DataStatusJob) Validate

func (DataStatusJob) Validate() error

type DifferenceToken

type DifferenceToken rune
const (
	DifferenceToken_Undefined DifferenceToken = '?'
	DifferenceToken_Add       DifferenceToken = '+'
	DifferenceToken_Remove    DifferenceToken = '-'
	DifferenceToken_Modify    DifferenceToken = '.'
)

func ParseDifferenceToken

func ParseDifferenceToken(t string) DifferenceToken

func (DifferenceToken) MarshalJSON

func (d DifferenceToken) MarshalJSON() ([]byte, error)

func (*DifferenceToken) UnmarshalJSON

func (d *DifferenceToken) UnmarshalJSON(b []byte) error

type Error

type Error string

func (Error) Error

func (p Error) Error() string

type JobState

type JobState string
const (
	State_Enable  JobState = "ENABLE"
	State_Disable JobState = "DISABLE"
	State_Passive JobState = "PASSIVE"
	State_Active  JobState = "ACTIVE"
)

type Opcode

type Opcode uint16
const (
	// Bidirectional between the website and the server
	Acknowledged Opcode = 0
	Exception    Opcode = 1

	// Activity
	Activity_Progress    Opcode = 10
	Activity_Metadata    Opcode = 11
	Activity_Download    Opcode = 12
	Activity_Cancel      Opcode = 13
	Activity_Difference  Opcode = 14
	Activity_GetProgress Opcode = 15

	// Status
	Status_IRC Opcode = 20
	Status_Job Opcode = 21
)

type Payload

type Payload struct {
	Opcode Opcode `json:"op"`
	Data   Data   `json:"d,omitempty"`
}

func New

func New[D Data](
	opcode Opcode,
	data D,
) *Payload

func (Payload) MarshalJSON

func (p Payload) MarshalJSON() ([]byte, error)

func (*Payload) UnmarshalJSON

func (p *Payload) UnmarshalJSON(b []byte) (err error)

type ProgressType

type ProgressType string

ProgressType defines the progression type

const (
	// Progress_Download is the type when the file is currently being uploaded
	Progress_Download ProgressType = "download"

	// Progress_Transcode is the type when the file is currently being transcoded
	// (generally from mkv to mp4/ main purpose is to prepare it for the web)
	Progress_Transcode ProgressType = "transcode"

	// Progress_Upload is the type when the runner is uploading the finalized transcode back
	// to the host.
	Progress_Upload ProgressType = "upload"

	// Progress_Metadata is when we receive metadata related information for the file
	// (duration, crc32, thumbnail),
	Progress_Metadata ProgressType = "metadata"
)

Jump to

Keyboard shortcuts

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