services

package
v0.0.0-...-d0cc13a Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 45 Imported by: 4

Documentation

Index

Constants

View Source
const (
	HashSize int = 20
)
View Source
const ServiceSeparator = "~"

Variables

Functions

func RegisterExportFlags

func RegisterExportFlags(f []cli.Flag) []cli.Flag

func RegisterMagnet2TorrentFlags

func RegisterMagnet2TorrentFlags(f []cli.Flag) []cli.Flag

func RegisterNodesStatFlags

func RegisterNodesStatFlags(f []cli.Flag) []cli.Flag

func RegisterPromClientFlags

func RegisterPromClientFlags(f []cli.Flag) []cli.Flag

func RegisterTorrentStoreFlags

func RegisterTorrentStoreFlags(f []cli.Flag) []cli.Flag

func RegisterWebFlags

func RegisterWebFlags(f []cli.Flag) []cli.Flag

Types

type AudioTagBuider

type AudioTagBuider struct {
	BaseTagBuilder
}

func (*AudioTagBuider) Build

func (s *AudioTagBuider) Build(ctx context.Context) (*ExportTag, error)

type BaseExporter

type BaseExporter struct {
	// contains filtered or unexported fields
}

func (*BaseExporter) BuildURL

func (s *BaseExporter) BuildURL(ctx context.Context, r *Resource, i *ListItem, g ParamGetter) (*MyURL, error)

func (*BaseExporter) Type

func (s *BaseExporter) Type() ExportType

type BaseTagBuilder

type BaseTagBuilder struct {
	// contains filtered or unexported fields
}

func (*BaseTagBuilder) BuildAVTag

func (s *BaseTagBuilder) BuildAVTag(ctx context.Context, n ExportTagName) (*ExportTag, error)

func (*BaseTagBuilder) BuildSource

func (s *BaseTagBuilder) BuildSource(u *MyURL) *ExportSource

func (*BaseTagBuilder) BuildURL

func (s *BaseTagBuilder) BuildURL(ctx context.Context, i *ListItem) (*MyURL, error)

type BaseURLBuilder

type BaseURLBuilder struct {
	// contains filtered or unexported fields
}

func (*BaseURLBuilder) BuildBaseURL

func (s *BaseURLBuilder) BuildBaseURL(ctx context.Context, i *MyURL) (u *MyURL, err error)

func (*BaseURLBuilder) BuildDomain

func (s *BaseURLBuilder) BuildDomain(ctx context.Context, i *MyURL) (u *MyURL, err error)

func (*BaseURLBuilder) BuildScheme

func (s *BaseURLBuilder) BuildScheme(i *MyURL) (u *MyURL)

func (*BaseURLBuilder) GetLastName

func (s *BaseURLBuilder) GetLastName() string

type CacheMap

type CacheMap struct {
	lazymap.LazyMap
	// contains filtered or unexported fields
}

func NewCacheMap

func NewCacheMap(cl *http.Client) *CacheMap

func (*CacheMap) Get

func (s *CacheMap) Get(ctx context.Context, url *MyURL) (bool, error)

type DownloadExporter

type DownloadExporter struct {
	BaseExporter
}

func NewDownloadExporter

func NewDownloadExporter(ub *URLBuilder) *DownloadExporter

func (*DownloadExporter) Export

type DownloadURLBuilder

type DownloadURLBuilder struct {
	BaseURLBuilder
}

func (*DownloadURLBuilder) Build

func (s *DownloadURLBuilder) Build(ctx context.Context) (u *MyURL, err error)

func (*DownloadURLBuilder) BuildDownloadURL

func (s *DownloadURLBuilder) BuildDownloadURL(i *MyURL) (u *MyURL, err error)

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type Export

type Export struct {
	// contains filtered or unexported fields
}

func NewExport

func NewExport(e ...Exporter) *Export

func (*Export) Get

type ExportGetArgs

type ExportGetArgs struct {
	Types []ExportType
}

func ExportGetArgsFromParams

func ExportGetArgsFromParams(g ParamGetter) (*ExportGetArgs, error)

type ExportItem

type ExportItem struct {
	ExportStreamItem
	ExportMetaItem
	Type string `json:"-"`
	URL  string `json:"url,omitempty"`
}

type ExportKindType

type ExportKindType string
const (
	ExportKindTypeSubtitles ExportKindType = "subtitles"
)

type ExportMeta

type ExportMeta struct {
	Transcode    bool `json:"transcode,omitempty"`
	Multibitrate bool `json:"multibitrate,omitempty"`
	Cache        bool `json:"cache,omitempty"`
}

type ExportMetaItem

type ExportMetaItem struct {
	Meta *ExportMeta `json:"meta,omitempty"`
}

type ExportPreloadType

type ExportPreloadType string
const (
	ExportPreloadTypeAuto ExportPreloadType = "auto"
	ExportPreloadTypeNone ExportPreloadType = "none"
)

type ExportResponse

type ExportResponse struct {
	Source      ListItem              `json:"source"`
	ExportItems map[string]ExportItem `json:"exports"`
}

type ExportSource

type ExportSource struct {
	Src  string `json:"src"`
	Type string `json:"type"`
}

type ExportStreamItem

type ExportStreamItem struct {
	Tag *ExportTag `json:"html_tag,omitempty"`
}

type ExportTag

type ExportTag struct {
	Name    ExportTagName     `json:"tag,omitempty"`
	Preload ExportPreloadType `json:"preload,omitempty"`
	Sources []ExportSource    `json:"sources,omitempty"`
	Tracks  []ExportTrack     `json:"tracks,omitempty"`
	Src     string            `json:"src,omitempty"`
	Alt     string            `json:"alt,omitempty"`
	Poster  string            `json:"poster,omitempty"`
}

type ExportTagName

type ExportTagName string
const (
	ExportTagNameVideo ExportTagName = "video"
	ExportTagNameAudio ExportTagName = "audio"
	ExportTagNameImage ExportTagName = "img"
)

type ExportTrack

type ExportTrack struct {
	Src     string         `json:"src"`
	Kind    ExportKindType `json:"kind"`
	SrcLang string         `json:"srclang,omitempty"`
	Label   string         `json:"label,omitempty"`
}

type ExportType

type ExportType string
const (
	ExportTypeDownload    ExportType = "download"
	ExportTypeStream      ExportType = "stream"
	ExportTypeTorrentStat ExportType = "torrent_client_stat"
	ExportTypeSubtitles   ExportType = "subtitles"
	ExportTypeMediaProbe  ExportType = "media_probe"
)

type Exporter

type Exporter interface {
	Type() ExportType
	Export(ctx context.Context, r *Resource, i *ListItem, g ParamGetter) (*ExportItem, error)
}

type File

type File struct {
	Path   []string
	Size   int64
	Pieces []Hash
}

type Hash

type Hash [HashSize]byte

type ImageTagBuider

type ImageTagBuider struct {
	BaseTagBuilder
}

func (*ImageTagBuider) Build

func (s *ImageTagBuider) Build(ctx context.Context) (et *ExportTag, err error)

type K8SClient

type K8SClient struct {
	// contains filtered or unexported fields
}

func NewK8SClient

func NewK8SClient() *K8SClient

func (*K8SClient) Get

func (s *K8SClient) Get() (*kubernetes.Clientset, error)

type List

type List struct{}

func NewList

func NewList() *List

func (*List) Get

func (s *List) Get(r *Resource, args *ListGetArgs) (ListResponse, error)

type ListGetArgs

type ListGetArgs struct {
	Limit  int
	Offset int
	Output ListOutputType
	Path   []string
}

func ListGetArgsFromParams

func ListGetArgsFromParams(g ParamGetter) (*ListGetArgs, error)

func NewListGetArgs

func NewListGetArgs() *ListGetArgs

type ListItem

type ListItem struct {
	ID          string      `json:"id"`
	Name        string      `json:"name,omitempty"`
	PathStr     string      `json:"path"`
	Path        []string    `json:"-"`
	Type        ListType    `json:"type"`
	Size        int64       `json:"size"`
	MediaFormat MediaFormat `json:"media_format,omitempty"`
	MimeType    string      `json:"mime_type,omitempty"`
	Ext         string      `json:"ext,omitempty"`
}

func (*ListItem) SameDirectory

func (s *ListItem) SameDirectory(li *ListItem) bool

type ListOutputType

type ListOutputType string
const (
	ListOutputTypeList ListOutputType = "list"
	ListOutputTypeTree ListOutputType = "tree"
)

type ListResponse

type ListResponse struct {
	ListItem
	Items []ListItem `json:"items"`
	Count int        `json:"items_count"`
}

type ListType

type ListType string
const (
	ListTypeFile      ListType = "file"
	ListTypeDirectory ListType = "directory"
)

type Magnet2Torrent

type Magnet2Torrent struct {
	// contains filtered or unexported fields
}

func NewMagnet2Torrent

func NewMagnet2Torrent(c *cli.Context) *Magnet2Torrent

func (*Magnet2Torrent) Close

func (s *Magnet2Torrent) Close()

func (*Magnet2Torrent) Get

type Magnet2TorrentClientMock

type Magnet2TorrentClientMock struct {
	mock.Mock
	// contains filtered or unexported fields
}

func (*Magnet2TorrentClientMock) Magnet2Torrent

type Magnet2TorrentGetter

type Magnet2TorrentGetter interface {
	Get() (m2tp.Magnet2TorrentClient, error)
}

type Magnet2TorrentMock

type Magnet2TorrentMock struct {
	// contains filtered or unexported fields
}

func NewMagnet2TorrentMock

func NewMagnet2TorrentMock() *Magnet2TorrentMock

func (*Magnet2TorrentMock) Get

type MediaFormat

type MediaFormat string
const (
	Audio    MediaFormat = "audio"
	Video    MediaFormat = "video"
	Image    MediaFormat = "image"
	Subtitle MediaFormat = "subtitle"
	Unknown  MediaFormat = "unknown"
)

type MediaProbeExporter

type MediaProbeExporter struct {
	BaseExporter
}

func NewMediaProbeExporter

func NewMediaProbeExporter(ub *URLBuilder) *MediaProbeExporter

func (*MediaProbeExporter) Export

type MediaProbeURLBuilder

type MediaProbeURLBuilder struct {
	StreamURLBuilder
}

func (*MediaProbeURLBuilder) Build

func (s *MediaProbeURLBuilder) Build(ctx context.Context) (u *MyURL, err error)

type MyURL

type MyURL struct {
	url.URL
	// contains filtered or unexported fields
}

func (*MyURL) BuildExportMeta

func (s *MyURL) BuildExportMeta() *ExportMeta

type NodeBandwidth

type NodeBandwidth struct {
	High    uint64
	Low     uint64
	Current uint64
}

type NodeStat

type NodeStat struct {
	Name string
	NodeBandwidth
	// NodeCPU
	Pools     []string
	Subdomain string
}

type NodeStatWithScore

type NodeStatWithScore struct {
	NodeStat
	Score    float64
	Distance int
}

type NodesStat

type NodesStat struct {
	lazymap.LazyMap
	// contains filtered or unexported fields
}

func NewNodesStat

func NewNodesStat(c *cli.Context, pcl *PromClient, kcl *K8SClient) *NodesStat

func (*NodesStat) Get

func (s *NodesStat) Get(ctx context.Context) ([]NodeStat, error)

type ParamGetter

type ParamGetter interface {
	Param(s string) string
	Query(s string) string
	GetHeader(s string) string
}

type PromClient

type PromClient struct {
	// contains filtered or unexported fields
}

func NewPromClient

func NewPromClient(c *cli.Context) *PromClient

func (*PromClient) Get

func (s *PromClient) Get() (v1.API, error)

type Resource

type Resource struct {
	ID        string
	Name      string
	Size      int64
	Files     []*File
	Type      ResourceType
	MagnetURI string
	Torrent   []byte
}

type ResourceMap

type ResourceMap struct {
	lazymap.LazyMap
	// contains filtered or unexported fields
}

func (*ResourceMap) Get

func (s *ResourceMap) Get(ctx context.Context, b []byte) (*Resource, error)

type ResourceResponse

type ResourceResponse struct {
	ID        string `json:"id"`
	Name      string `json:"name,omitempty"`
	MagnetURI string `json:"magnet_uri,omitempty"`
}

type ResourceType

type ResourceType int
const (
	ResourceTypeHash ResourceType = iota
	ResourceTypeMagnet
	ResourceTypeTorrent
	ResourceTypeSha1
)

type ServiceType

type ServiceType string
const (
	ServiceTypeArchive   ServiceType = "arch"
	ServiceTypeTranscode ServiceType = "hls"
	ServiceTypeVOD       ServiceType = "vod"
	ServiceTypeSRT2VTT   ServiceType = "vtt"
	ServiceTypeVideoInfo ServiceType = "vi"
)

type StreamExporter

type StreamExporter struct {
	BaseExporter
	// contains filtered or unexported fields
}

func NewStreamExporter

func NewStreamExporter(ub *URLBuilder, tb *TagBuilder) *StreamExporter

func (*StreamExporter) Export

func (*StreamExporter) MakeExportStreamItem

func (s *StreamExporter) MakeExportStreamItem(ctx context.Context, r *Resource, i *ListItem, g ParamGetter) (*ExportStreamItem, error)

func (*StreamExporter) Type

func (s *StreamExporter) Type() ExportType

type StreamURLBuilder

type StreamURLBuilder struct {
	BaseURLBuilder
}

func (*StreamURLBuilder) Build

func (s *StreamURLBuilder) Build(ctx context.Context) (u *MyURL, err error)

func (*StreamURLBuilder) BuildAudioStreamURL

func (s *StreamURLBuilder) BuildAudioStreamURL(i *MyURL, suffix string) (u *MyURL, err error)

func (*StreamURLBuilder) BuildSRT2VTTURL

func (s *StreamURLBuilder) BuildSRT2VTTURL(i *MyURL) (u *MyURL)

func (*StreamURLBuilder) BuildStreamURL

func (s *StreamURLBuilder) BuildStreamURL(i *MyURL, suffix string) (u *MyURL, err error)

func (*StreamURLBuilder) BuildSubtitleStreamURL

func (s *StreamURLBuilder) BuildSubtitleStreamURL(i *MyURL) (u *MyURL, err error)

func (*StreamURLBuilder) BuildTranscodeURL

func (s *StreamURLBuilder) BuildTranscodeURL(i *MyURL, suffix string) (u *MyURL)

func (*StreamURLBuilder) BuildVODURL

func (s *StreamURLBuilder) BuildVODURL(i *MyURL, suffix string) (u *MyURL)

func (*StreamURLBuilder) BuildVideoStreamURL

func (s *StreamURLBuilder) BuildVideoStreamURL(i *MyURL, suffix string) (u *MyURL, err error)

type Subdomains

type Subdomains struct {
	// contains filtered or unexported fields
}

func NewSubdomains

func NewSubdomains(c *cli.Context, nsp *NodesStat) *Subdomains

func (*Subdomains) Get

func (s *Subdomains) Get(ctx context.Context, infohash string, pool string) ([]string, error)

type Subtitles

type Subtitles struct {
	URL string `json:"url"`
}

type SubtitlesExporter

type SubtitlesExporter struct {
	BaseExporter
}

func NewSubtitlesExporter

func NewSubtitlesExporter(ub *URLBuilder) *SubtitlesExporter

func (*SubtitlesExporter) Export

type SubtitlesURLBuilder

type SubtitlesURLBuilder struct {
	BaseURLBuilder
}

func (*SubtitlesURLBuilder) Build

func (s *SubtitlesURLBuilder) Build(ctx context.Context) (u *MyURL, err error)

func (*SubtitlesURLBuilder) BuildSubtitlesURL

func (s *SubtitlesURLBuilder) BuildSubtitlesURL(i *MyURL) (u *MyURL)

type TagBuilder

type TagBuilder struct {
	// contains filtered or unexported fields
}

func NewTagBuilder

func NewTagBuilder(ub *URLBuilder, l *List) *TagBuilder

func (*TagBuilder) Build

func (s *TagBuilder) Build(ctx context.Context, r *Resource, i *ListItem, g ParamGetter) (*ExportTag, error)

type TorrentStatExporter

type TorrentStatExporter struct {
	BaseExporter
}

func NewTorrentStatExporter

func NewTorrentStatExporter(ub *URLBuilder) *TorrentStatExporter

func (*TorrentStatExporter) Export

type TorrentStatURLBuilder

type TorrentStatURLBuilder struct {
	BaseURLBuilder
}

func (*TorrentStatURLBuilder) Build

func (s *TorrentStatURLBuilder) Build(ctx context.Context) (u *MyURL, err error)

func (*TorrentStatURLBuilder) BuildStatURL

func (s *TorrentStatURLBuilder) BuildStatURL(i *MyURL) *MyURL

type TorrentStore

type TorrentStore struct {
	// contains filtered or unexported fields
}

func NewTorrentStore

func NewTorrentStore(c *cli.Context) *TorrentStore

func (*TorrentStore) Close

func (s *TorrentStore) Close()

func (*TorrentStore) Get

type TorrentStoreClientMock

type TorrentStoreClientMock struct {
	mock.Mock
}

func (*TorrentStoreClientMock) Pull

func (*TorrentStoreClientMock) Push

func (*TorrentStoreClientMock) Touch

type TorrentStoreGetter

type TorrentStoreGetter interface {
	Get() (tsp.TorrentStoreClient, error)
}

type TorrentStoreMock

type TorrentStoreMock struct {
	// contains filtered or unexported fields
}

func NewTorrentStoreMock

func NewTorrentStoreMock() *TorrentStoreMock

func (*TorrentStoreMock) Get

type URLBuilder

type URLBuilder struct {
	// contains filtered or unexported fields
}

func NewURLBuilder

func NewURLBuilder(c *cli.Context, sd *Subdomains, cm *CacheMap) *URLBuilder

func (*URLBuilder) Build

func (s *URLBuilder) Build(ctx context.Context, r *Resource, i *ListItem, g ParamGetter, et ExportType) (*MyURL, error)

type VideoTagBuider

type VideoTagBuider struct {
	BaseTagBuilder
	// contains filtered or unexported fields
}

func (*VideoTagBuider) Build

func (s *VideoTagBuider) Build(ctx context.Context) (*ExportTag, error)

func (*VideoTagBuider) BuildAttachedResources

func (s *VideoTagBuider) BuildAttachedResources(ctx context.Context, et *ExportTag) (*ExportTag, error)

func (*VideoTagBuider) BuildTrack

func (s *VideoTagBuider) BuildTrack(ctx context.Context, i *ListItem) (*ExportTrack, error)

type Web

type Web struct {
	// contains filtered or unexported fields
}

func NewWeb

func NewWeb(c *cli.Context, rm *ResourceMap, co *List, ex *Export) *Web

func (*Web) Close

func (s *Web) Close()

func (*Web) Serve

func (s *Web) Serve() error

Jump to

Keyboard shortcuts

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