subtitle_best_api

package
v0.45.1 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AskDownloadTaskReply added in v0.36.0

type AskDownloadTaskReply struct {
	Status       int          `json:"status"`                 // 0 失败,1 有任务,2 没有任务
	Message      string       `json:"message"`                // 返回的信息,包括成功和失败的原因
	DownloadInfo DownloadInfo `json:"download_info,optional"` // 下载信息
}

type AskFindSubReply

type AskFindSubReply struct {
	Status            int        `json:"status"`              // 0 失败,1 成功,在缓存中有对应的信息,2 放入了队列,根据返回的时间再查询,3 查询队列满了,需要等待
	Message           string     `json:"message"`             // 返回的信息,包括成功和失败的原因
	Subtitle          []Subtitle `json:"subtitle,optional"`   // 如果查询成功,返回的字幕信息
	ScheduledUnixTime int64      `json:"scheduled_unix_time"` // 预约查询的时间
}

type AskFindSubReq

type AskFindSubReq struct {
	VideoFeature string `form:"video_feature"`    // VideoFeature ID
	ImdbId       string `form:"imdb_id"`          // IMDB ID
	TmdbId       string `form:"tmdb_id"`          // TMDB ID,这里是这个剧集的 TMDB ID 不是这一集的哈
	Season       int    `form:"season"`           // 如果对应的是电影则可能是 0,没有
	Episode      int    `form:"episode"`          // 如果对应的是电影则可能是 0,没有
	FindSubToken string `form:"find_sub_token"`   // 查询令牌,由 Client 生成的 8 位随机字符,不包含特殊字符即可
	ApiKey       string `form:"api_key,optional"` // API Key,非必须,可能是某些用户才有的权限
}

type AskForDownloadReply

type AskForDownloadReply struct {
	Status            int    `json:"status"`              // 0 失败,1 成功,2 放入了队列,根据返回的时间再下载,3 下载队列满了,需要等待
	Message           string `json:"message"`             // 返回的信息,包括成功和失败的原因
	ScheduledUnixTime int64  `json:"scheduled_unix_time"` // 预约的下载时间
}

type AskForDownloadReq

type AskForDownloadReq struct {
	SubSha256     string `form:"sub_sha256"`       // 文件的 SHA256
	DownloadToken string `form:"download_token"`   // 下载令牌,对应具体服务器会相应回复对应的数据
	ApiKey        string `form:"api_key,optional"` // API Key,非必须,可能是某些用户才有的权限
}

type AskForUploadReply

type AskForUploadReply struct {
	Status            int    `json:"status"` // 0 失败,1 成功,2 放入了队列,根据返回的时间再上传,3 已经存在,无需上传,本地标记上传了,4 上传队列满了,需要等待
	Message           string `json:"message"`
	ScheduledUnixTime int64  `json:"scheduled_unix_time,omitempty"`
}

type AskForUploadReq

type AskForUploadReq struct {
	SubSha256 string `json:"sub_sha256"`
	Trusted   bool   `json:"trusted,optional"` // 是否是信任的字幕
	ImdbId    string `form:"imdb_id,optional"` // IMDB ID
	TmdbId    string `form:"tmdb_id,optional"` // TMDB ID,这里是这个剧集的 TMDB ID 不是这一集的哈
	Season    int    `form:"season,optional"`  // 如果对应的是电影则可能是 0,没有
	Episode   int    `form:"episode,optional"` // 如果对应的是电影则可能是 0,没有
}

type CodeReplyData

type CodeReplyData struct {
	Status  int    `json:"status"`
	Message string `json:"message"`
	Code    string `json:"code"`
}

type CodeReqData

type CodeReqData struct {
	NowTime string `json:"now_time"`
}

type DownloadInfo added in v0.36.0

type DownloadInfo struct {
	TaskID       string `json:"task_id"`       // 任务id
	VideoFeature string `json:"video_feature"` // VideoFeature ID
	ImdbId       string `json:"imdb_id"`       // IMDB ID
	TmdbId       string `json:"tmdb_id"`       // TMDB ID,这里是这个剧集的 TMDB ID 不是这一集的哈
	Season       int    `json:"season"`        // 如果对应的是电影则可能是 0,没有
	Episode      int    `json:"episode"`       // 如果对应的是电影则可能是 0,没有
	IsMovie      bool   `json:"is_movie"`      // 是否是电影,如果是电影则 season 和 episode 可能是 0,没有
}

type DownloadSubReply

type DownloadSubReply struct {
	Status     int    `json:"status"`                // 0 失败,1 成功。应该说正常就是下载文件了,失败才会使用这个结构体
	Message    string `json:"message"`               // 返回的信息,包括成功和失败的原因
	StoreRPath string `json:"store_r_path,optional"` // 存储路径
}

type DownloadSubReq

type DownloadSubReq struct {
	SubSha256     string `form:"sub_sha256"`       // 文件的 SHA256
	DownloadToken string `form:"download_token"`   // 下载令牌
	ApiKey        string `form:"api_key,optional"` // API Key,非必须,可能是某些用户才有的权限
}

type FeedReply added in v0.35.0

type FeedReply struct {
	Status  int    `json:"status"` // 0 失败,1 成功
	Message string `json:"message"`
}

type FeedReq added in v0.35.0

type FeedReq struct {
	Id           string `json:"id"`             // 当前用户的id,这个需要在用户缓存中随机生成
	Version      string `json:"version"`        // 当前版本号
	MediaServer  string `json:"media_server"`   // 媒体服务的名称,没有使用则是 None
	EnableShare  bool   `json:"enable_share"`   // 是否开启了共享功能
	EnableApiKey bool   `json:"enable_api_key"` // 是否开启本地 http api 功能
}

type FindSubReply

type FindSubReply struct {
	Status            int        `json:"status"`  // 0 失败,1 成功
	Message           string     `json:"message"` // 返回的信息,包括成功和失败的原因
	Subtitle          []Subtitle `json:"subtitle,optional"`
	ScheduledUnixTime int64      `json:"scheduled_unix_time"` // 预约的下载时间,可以不用,为了占位置用的
}

type FindSubReq

type FindSubReq struct {
	VideoFeature string `form:"video_feature"`    // VideoFeature ID
	ImdbId       string `form:"imdb_id"`          // IMDB ID
	TmdbId       string `form:"tmdb_id"`          // TMDB ID,这里是这个剧集的 TMDB ID 不是这一集的哈
	Season       int    `form:"season"`           // 如果对应的是电影则可能是 0,没有
	Episode      int    `form:"episode"`          // 如果对应的是电影则可能是 0,没有
	FindSubToken string `form:"find_sub_token"`   // 查询令牌,由 Client 生成的 8 位随机字符,不包含特殊字符即可
	ApiKey       string `form:"api_key,optional"` // API Key,非必须,可能是某些用户才有的权限
}

type IdConvertReply added in v0.35.0

type IdConvertReply struct {
	Status  int    `json:"status"` // 0 失败,1 成功
	Message string `json:"message"`
	IMDBId  string `json:"imdb_id,omitempty"`
	TVDBId  string `json:"tvdb_id,omitempty"`
}

type IdConvertReq added in v0.35.0

type IdConvertReq struct {
	Id        string `json:"id"`
	Source    string `json:"source"`     // options=imdb|tmdb
	VideoType string `json:"video_type"` // ,options=movie|series
}

type MediaInfoReply

type MediaInfoReply struct {
	Status           int    `json:"status"` // 0 失败,1 成功,2 在队列中等待查询
	Message          string `json:"message"`
	TMDBId           string `json:"tmdb_id,omitempty"`
	OriginalTitle    string `json:"original_title,omitempty"`
	OriginalLanguage string `json:"original_language,omitempty"`
	TitleEN          string `json:"title_en,omitempty"`
	TitleCN          string `json:"title_cn,omitempty"`
	Year             string `json:"year,omitempty"`
}
{
	"status": 1,
	"message": "",
	"tmdb_id": "503235",
	"original_title": "邪不压正",
	"original_language": "zh",
	"title_en": "Hidden Man",
	"title_cn": "邪不压正",
	"year": "2018-07-13"
}
{
	"status": 1,
	"message": "",
	"tmdb_id": "78154",
	"original_title": "L'amica geniale",
	"original_language": "it",
	"title_en": "My Brilliant Friend",
	"title_cn": "我的天才女友",
	"year": "2018-11-18"
}

type MediaInfoReq

type MediaInfoReq struct {
	Id        string `json:"id"`
	Source    string `json:"source"`     // options=imdb|tmdb
	VideoType string `json:"video_type"` // ,options=movie|series
}
{
	"id": "tt7278862",
	"source": "imdb",
	"video_type": "series"
}
{
	"id": "503235",
	"source": "tmdb",
	"video_type": "movie"
}

type Subtitle

type Subtitle struct {
	SubSha256         string `json:"sub_sha256"`              // 文件的 SHA256
	IsDouble          bool   `json:"is_double"`               // 是否是双语,基础是中文
	MyLanguage        string `json:"my_language"`             // 这个是本程序定义的语言类型,见 my_language.go 文件
	LowTrust          bool   `json:"low_trust"`               // 是否是低信任的
	ExtraPreName      string `json:"extra_pre_name,optional"` //字幕额外的命名信息,指 Emby 字幕命名格式(简英,subhd),的 subhd
	MatchVideoFeature bool   `json:"match_video_feature"`     // 是否匹配到 VideoFeature
	Ext               string `json:"ext"`                     // 字幕的后缀名
}

type SubtitleBestApi

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

func NewSubtitleBestApi

func NewSubtitleBestApi(log *logrus.Logger, inAuthKey random_auth_key.AuthKey) *SubtitleBestApi

func (*SubtitleBestApi) AskDownloadSub

func (s *SubtitleBestApi) AskDownloadSub(SubSha256, DownloadToken, ApiKey string) (*AskForDownloadReply, error)

func (*SubtitleBestApi) AskDownloadTask added in v0.36.0

func (s *SubtitleBestApi) AskDownloadTask(id string) (*AskDownloadTaskReply, error)

func (*SubtitleBestApi) AskFindSub

func (s *SubtitleBestApi) AskFindSub(VideoFeature, ImdbId, TmdbId, Season, Episode, FindSubToken, ApiKey string) (*AskFindSubReply, error)

func (*SubtitleBestApi) AskFroUpload

func (s *SubtitleBestApi) AskFroUpload(subSha256 string, IsMovie, trusted bool, ImdbId, TmdbId string, Season, Episode int, VideoFeature string) (*AskForUploadReply, error)

AskFroUpload 在使用这个接口前,需要从 IMDB ID 获取到 TMDB ID

func (*SubtitleBestApi) CheckAlive added in v0.38.3

func (s *SubtitleBestApi) CheckAlive() error

func (*SubtitleBestApi) ConvertId added in v0.35.0

func (s *SubtitleBestApi) ConvertId(id, source, videoType string) (*IdConvertReply, error)

ConvertId 目前仅仅支持 TMDB ID 转 IMDB ID

func (*SubtitleBestApi) DownloadSub

func (s *SubtitleBestApi) DownloadSub(SubSha256, DownloadToken, ApiKey, downloadFileDesFPath string) (*DownloadSubReply, error)

DownloadSub 首先要确认 downloadFileDesFPath 这个文件是否存在,如果存在且跟需要下载的文件的 sha256 一样就要跳过,然后下载完毕后,也需要 check 这个文件是否存在,存在则需要判断是否是字幕

func (*SubtitleBestApi) FeedBack added in v0.35.0

func (s *SubtitleBestApi) FeedBack(id, version, MediaServer string, EnableShare, EnableApiKey bool) (*FeedReply, error)

func (*SubtitleBestApi) FindSub

func (s *SubtitleBestApi) FindSub(VideoFeature, ImdbId, TmdbId, Season, Episode, FindSubToken, ApiKey string) (*FindSubReply, error)

func (*SubtitleBestApi) GetCode

func (s *SubtitleBestApi) GetCode() (string, error)

func (*SubtitleBestApi) GetMediaInfo

func (s *SubtitleBestApi) GetMediaInfo(id, source, videoType string) (*MediaInfoReply, error)

func (*SubtitleBestApi) UploadLowTrustSub

func (s *SubtitleBestApi) UploadLowTrustSub(lowTrustVideoSubInfo *models.LowVideoSubInfo, subSaveRootDirPath string, tmdbId, year, taskID string) (*UploadSubReply, error)

func (*SubtitleBestApi) UploadSub

func (s *SubtitleBestApi) UploadSub(videoSubInfo *models.VideoSubInfo, subSaveRootDirPath string, tmdbId, year string) (*UploadSubReply, error)

UploadSub 在使用这个接口前,需要从 IMDB ID 获取到 TMDB ID,其实在这一步应该默认就拿到了 TMDB ID,需要提前在 AskFroUpload 接口调用前就搞定这个 year 这个也是从之前的接口拿到, 2019 or 2022

type UploadSubReply

type UploadSubReply struct {
	Status  int    `json:"status"` // 0 失败,1 成功,2 超过了上传时间,需要再此申请上传(AskForUploadReply)
	Message string `json:"message"`
}

type UploadSubReq

type UploadSubReq struct {
	SubSha256    string `json:"sub_sha256"`     // 文件的 SHA256
	Season       int    `json:"season"`         // 如果对应的是电影则可能是 0,没有
	Episode      int    `json:"episode"`        // 如果对应的是电影则可能是 0,没有
	IsDouble     bool   `json:"is_double"`      // 是否是双语,基础是中文
	LanguageISO  string `json:"language_iso"`   // 字幕的语言,目标语言,就算是双语,中英,也应该是中文。ISO_639-1_codes 标准,见 ISOLanguage.go 文件,这里无法区分简体繁体
	MyLanguage   string `json:"my_language"`    // 这个是本程序定义的语言类型,见 my_language.go 文件
	ExtraPreName string `json:"extra_pre_name"` // 字幕额外的命名信息,指 Emby 字幕命名格式(简英,subhd),的 subhd
	ImdbId       string `json:"imdb_id"`        // IMDB ID
	TmdbId       string `json:"tmdb_id"`        // TMDB ID,这里是这个剧集的 TMDB ID 不是这一集的哈
	VideoFeature string `json:"video_feature"`  // VideoFeature ID
	Year         int    `json:"year"`           // 年份,比如 2019、2022
}

Jump to

Keyboard shortcuts

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