handler

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: AGPL-3.0 Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MaxRedirectAttempts = 10               // 最大重定向次数限制
	RedirectTimeout     = 10 * time.Second // 最大超时时间

)

Variables

View Source
var (
	ErrInvalidLocationHeader = errors.New("重定向 Location 头无效")
	ErrMaxRedirectsExceeded  = fmt.Errorf("超过最大重定向次数限制(%d)", MaxRedirectAttempts)
)
View Source
var ErrInvalidMediaServerType = errors.New("错误的媒体服务器类型")

Functions

func Init

func Init() error

初始化媒体服务器处理器

Types

type EmbyHandler

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

Emby服务器处理器

func NewEmbyServerHandler

func NewEmbyServerHandler(addr string, apiKey string) (*EmbyHandler, error)

初始化

func (*EmbyHandler) GetImageCacheRegexp

func (handler *EmbyHandler) GetImageCacheRegexp() *regexp.Regexp

func (*EmbyHandler) GetRegexpRouteRules

func (handler *EmbyHandler) GetRegexpRouteRules() []RegexpRouteRule

正则路由表

func (*EmbyHandler) GetSubtitleCacheRegexp

func (handler *EmbyHandler) GetSubtitleCacheRegexp() *regexp.Regexp

func (*EmbyHandler) ModifyBaseHtmlPlayer

func (handler *EmbyHandler) ModifyBaseHtmlPlayer(rw *http.Response) error

修改 basehtmlplayer.js

用于修改播放器 JS,实现跨域播放 Strm 文件(302 重定向)

func (*EmbyHandler) ModifyPlaybackInfo

func (handler *EmbyHandler) ModifyPlaybackInfo(rw *http.Response) error

修改播放信息请求

/Items/:itemId/PlaybackInfo 强制将 HTTPStrm 设置为支持直链播放和转码、AlistStrm 设置为支持直链播放并且禁止转码

func (*EmbyHandler) ModifySubtitles

func (handler *EmbyHandler) ModifySubtitles(rw *http.Response) error

修改字幕

将 SRT 字幕转 ASS

func (*EmbyHandler) ReverseProxy

func (handler *EmbyHandler) ReverseProxy(rw http.ResponseWriter, req *http.Request)

转发请求至上游服务器

func (*EmbyHandler) VideosHandler

func (handler *EmbyHandler) VideosHandler(ctx *gin.Context)

视频流处理器

支持播放本地视频、重定向 HttpStrm、AlistStrm

type FNTVHandler

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

func NewFNTVHandler

func NewFNTVHandler(addr string) (*FNTVHandler, error)

func (*FNTVHandler) GetImageCacheRegexp

func (handler *FNTVHandler) GetImageCacheRegexp() *regexp.Regexp

获取图片缓存正则表达式

func (*FNTVHandler) GetRegexpRouteRules

func (handler *FNTVHandler) GetRegexpRouteRules() []RegexpRouteRule

获取正则路由表

func (*FNTVHandler) GetSubtitleCacheRegexp

func (*FNTVHandler) GetSubtitleCacheRegexp() *regexp.Regexp

获取字幕缓存正则表达式

func (*FNTVHandler) ModifyStream

func (handler *FNTVHandler) ModifyStream(rw *http.Response) error

func (*FNTVHandler) ReverseProxy

func (handler *FNTVHandler) ReverseProxy(writer http.ResponseWriter, request *http.Request)

转发请求至上游服务器

type JellyfinHandler

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

Jellyfin 服务器处理器

func NewJellyfinHandler

func NewJellyfinHandler(addr string, apiKey string) (*JellyfinHandler, error)

func (*JellyfinHandler) GetImageCacheRegexp

func (handler *JellyfinHandler) GetImageCacheRegexp() *regexp.Regexp

func (*JellyfinHandler) GetRegexpRouteRules

func (handler *JellyfinHandler) GetRegexpRouteRules() []RegexpRouteRule

正则路由表

func (*JellyfinHandler) GetSubtitleCacheRegexp

func (*JellyfinHandler) GetSubtitleCacheRegexp() *regexp.Regexp

func (*JellyfinHandler) ModifyPlaybackInfo

func (handler *JellyfinHandler) ModifyPlaybackInfo(rw *http.Response) error

修改播放信息请求

/Items/:itemId 强制将 HTTPStrm 设置为支持直链播放和转码、AlistStrm 设置为支持直链播放并且禁止转码

func (*JellyfinHandler) ReverseProxy

func (handler *JellyfinHandler) ReverseProxy(rw http.ResponseWriter, req *http.Request)

转发请求至上游服务器

func (*JellyfinHandler) VideosHandler

func (handler *JellyfinHandler) VideosHandler(ctx *gin.Context)

视频流处理器

支持播放本地视频、重定向 HttpStrm、AlistStrm

type MediaServerHandler

type MediaServerHandler interface {
	ReverseProxy(http.ResponseWriter, *http.Request) // 转发请求至上游服务器
	GetRegexpRouteRules() []RegexpRouteRule          // 获取正则路由表
	GetImageCacheRegexp() *regexp.Regexp             // 获取图片缓存正则表达式
	GetSubtitleCacheRegexp() *regexp.Regexp          // 字幕缓存正则表达式
}

媒体服务器处理接口

func GetMediaServer

func GetMediaServer() MediaServerHandler

获取媒体服务器接口

type RegexpRouteRule

type RegexpRouteRule struct {
	Regexp  *regexp.Regexp
	Handler gin.HandlerFunc
}

正则表达式路由规则

type StrmHandlerFunc

type StrmHandlerFunc func(content string, ua string) string

type TranscodeResourceInfo

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

Jump to

Keyboard shortcuts

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