conversion

package module
Version: v0.1.27 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2019 License: MIT Imports: 34 Imported by: 0

README

conversion

        eng, err := conversion.InitMySQL(
            conversion.LoginOption(cfg.Addr, cfg.Username, cfg.Password))
    	if err != nil {
            return nil, fmt.Errorf("init conversion:%w", err)
    	}
        conversion.RegisterDatabase(eng)

        t := conversion.NewTask()
        t.Limit = cfg.Limit
        //don't stop when all task is done	
        t.SetAutoStop(false)        
        //then start
        t.Start()

Documentation

Index

Constants

View Source
const (
	NodeTypeCluster = "cluster"
	NodeTypeSingle  = "single"
	NodeTypeDummy   = "dummy"
)

NodeTypeCluster ...

Variables

View Source
var CachePath = cache.DefaultPath

CachePath ...

View Source
var DefaultLimit = 3

DefaultLimit ...

View Source
var ErrWorkFinish = errors.New("work was finished")

ErrWorkFinish ...

View Source
var ErrWorkID = errors.New("video id must input")

ErrWorkID ...

View Source
var ErrWrongCastType = errors.New("something wrong when cast to type")

ErrWrongCastType ...

View Source
var WorkRunProcessFunction = map[string]VideoProcessFunc{
	"source": decodeSource,
	"info":   decodeInfo,
}

WorkRunProcessFunction ...

Functions

func AllHash

func AllHash(session *xorm.Session, limit int, start ...int) (unfins *[]*Hash, e error)

AllHash ...

func ByteIndex

func ByteIndex(idx byte) int

ByteIndex ...

func CheckDatabase

func CheckDatabase() bool

CheckDatabase ...

func CheckNode

func CheckNode() bool

CheckNode ...

func Checksum

func Checksum(filepath string) string

Checksum ...

func CidHash added in v0.1.0

func CidHash(path path.Resolved) string

CidHash ...

func ExistVerifyFunc

func ExistVerifyFunc(tp string, f func(interface{}) string, v ...interface{}) bool

ExistVerifyFunc ...

func ExistVerifyString

func ExistVerifyString(tp string, v ...string) bool

ExistVerifyString ...

func FileAbsName

func FileAbsName(filename string) string

FileAbsName ...

func FileName

func FileName(filename string) string

FileName ...

func FindAll

func FindAll(model IModel, f FindResult, limit int, start ...int) (e error)

FindAll ...

func GetFileIndex

func GetFileIndex(filename string) int

GetFileIndex ...

func GetFiles

func GetFiles(name string, regex string) (files []string)

GetFiles ...

func GetNameIndex

func GetNameIndex(name string) int

GetNameIndex ...

func IndexByte

func IndexByte(index int) byte

IndexByte ...

func InitFFTool added in v0.1.27

func InitFFTool()

func InitMySQL

func InitMySQL(ops ...ConfigOptions) (*xorm.Engine, error)

InitMySQL ...

func InitSQLite3

func InitSQLite3(name string) (eng *xorm.Engine, e error)

InitSQLite3 ...

func InsertOrUpdate

func InsertOrUpdate(m IModel) (i int64, e error)

InsertOrUpdate ...

func IsExist

func IsExist(m IModel) bool

IsExist ...

func IsMedia

func IsMedia(format *fftool.StreamFormat) bool

IsMedia ...

func IsPicture

func IsPicture(name string) bool

IsPicture ...

func IsVideo

func IsVideo(filename string) bool

IsVideo ...

func LastSplit

func LastSplit(s, sep string) string

LastSplit ...

func MakeDatabaseInstance added in v0.1.24

func MakeDatabaseInstance(options ...ConfigOptions) (*xorm.Engine, error)

MakeDatabaseInstance ...

func MustDatabase

func MustDatabase(engine *xorm.Engine, err error) *xorm.Engine

MustDatabase ...

func MustSession

func MustSession(session *xorm.Session) *xorm.Session

MustSession ...

func MustString

func MustString(val, src string) string

MustString must string

func RegisterCache added in v0.0.7

func RegisterCache()

RegisterCache ...

func RegisterDatabase

func RegisterDatabase(engine *xorm.Engine)

RegisterDatabase ...

func RegisterNode added in v0.1.0

func RegisterNode(node Node)

RegisterNode ...

func ResolvedHash

func ResolvedHash(path path.Resolved) (string, error)

ResolvedHash ...

func SetCachePath added in v0.0.7

func SetCachePath(path string)

SetCachePath ...

func SyncTable

func SyncTable() (e error)

SyncTable ...

func UUID

func UUID() uuid.UUID

UUID ...

func Wrap

func Wrap(err error, msg ...string) error

Wrap ...

Types

type Actor

type Actor struct {
	Image    string   `json:"Image"`
	StarLink string   `json:"StarLink"`
	Name     string   `json:"Name"`
	Alias    []string `json:"Alias"`
}

Actor ...

type BeforeInsert

type BeforeInsert interface {
	BeforeInsert()
}

BeforeInsert ...

type Config added in v0.1.27

type Config = fftool.Config

type ConfigOptions

type ConfigOptions func(config *dbConfig)

ConfigOptions ...

func CreateDatabaseOption added in v0.1.24

func CreateDatabaseOption() ConfigOptions

CreateDatabaseOption ...

func DBType added in v0.1.24

func DBType(p string) ConfigOptions

DBType ...

func LoginOption

func LoginOption(addr, user, pass string) ConfigOptions

LoginOption ...

func SchemaOption

func SchemaOption(s string) ConfigOptions

SchemaOption ...

func ShowSQLOptions

func ShowSQLOptions(b bool) ConfigOptions

ShowSQLOptions ...

func UseCacheOptions

func UseCacheOptions(b bool) ConfigOptions

UseCacheOptions ...

type Extend

type Extend struct {
	Path    string `json:"path"`
	Message string `json:"message"`
}

Extend ...

type FindResult

type FindResult func(rows *xorm.Rows) error

FindResult ...

type Fragment

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

Fragment ...

func (Fragment) Output

func (s Fragment) Output() string

Output ...

func (Fragment) Scale

func (s Fragment) Scale() Scale

Scale ...

func (Fragment) Sharpness

func (s Fragment) Sharpness() string

Sharpness ...

type FragmentOption

type FragmentOption func(f *Fragment)

FragmentOption ...

type Genre

type Genre struct {
	URL     string `json:"URL"`
	Content string `json:"Content"`
}

Genre ...

type Hash

type Hash struct {
	Model       `xorm:"extends"`
	Checksum    string   `xorm:"default() checksum" json:"checksum"`         //sum值
	HashType    HashType `xorm:"default() hash_type" json:"hash_type"`       //类型
	Episode     string   `xorm:"default() episode" json:"episode"`           //总集数
	Name        string   `xorm:"default() name" json:"name"`                 //banno
	Hash        string   `xorm:"default() hash" json:"hash"`                 //哈希地址
	Sharpness   string   `xorm:"default() sharpness" json:"sharpness"`       //清晰度
	Caption     string   `xorm:"default() caption" json:"caption"`           //字幕
	Encrypt     bool     `xorm:"default() encrypt" json:"encrypt"`           //加密
	Key         string   `xorm:"default() key" json:"key"`                   //秘钥
	M3U8        string   `xorm:"default() m3u8" json:"m3u8"`                 //M3U8名
	SegmentFile string   `xorm:"default() segment_file" json:"segment_file"` //ts切片名
	Resource    string   `xorm:" default() resource" json:"resource"`        //资源地址
}

Hash ...

func FindHash

func FindHash(session *xorm.Session, checksum string) (unfin *Hash, e error)

FindHash ...

func (*Hash) Clone

func (h *Hash) Clone() (n *Hash)

Clone ...

func (*Hash) Sync

func (h *Hash) Sync() error

Sync ...

func (*Hash) Table

func (h *Hash) Table() interface{}

Table ...

type HashType

type HashType string

HashType ...

const (
	HashTypeOther   HashType = "other"
	HashTypeVideo   HashType = "video"
	HashTypeSlice   HashType = "slice"
	HashTypePoster  HashType = "poster"
	HashTypeThumb   HashType = "thumb"
	HashTypeCaption HashType = "caption"
)

TypeOther ...

type IModel

type IModel interface {
	Table() interface{}
	ID() string
	SetID(string)
	Version() int
	SetVersion(int)
}

IModel ...

type ISync

type ISync interface {
	Sync() error
}

ISync ...

type IVideo

type IVideo interface {
	Video() *Video
}

IVideo ...

func VideoFromInfo

func VideoFromInfo(ctx context.Context, Work *Work) (IVideo, error)

VideoFromInfo ...

func VideoFromSource

func VideoFromSource(Work *Work) (IVideo, error)

VideoFromSource ...

type IWork

type IWork interface {
	ID() string
	Work() *Work
	Video() *Video
	Info() string
	Update() error
	Store() error
	Reset() error
	Status() WorkStatus
	Run(ctx context.Context) (e error)
	Stop() error
}

IWork ...

func LoadWork

func LoadWork(id string) (IWork, error)

LoadWork ...

func NewInfoWork

func NewInfoWork(info *VideoPornInfo, options ...WorkOptions) (IWork, error)

NewInfoWork ...

func NewSourceWork

func NewSourceWork(source *VideoPornSource, options ...WorkOptions) (IWork, error)

NewSourceWork ...

type Model

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

Model ...

func (*Model) BeforeInsert

func (m *Model) BeforeInsert()

BeforeInsert ...

func (Model) ID

func (m Model) ID() string

ID ...

func (*Model) SetID

func (m *Model) SetID(id string)

SetID ...

func (*Model) SetVersion

func (m *Model) SetVersion(v int)

SetVersion ...

func (Model) Version

func (m Model) Version() int

Version ...

type Node added in v0.1.0

type Node interface {
	Type() string
	ID() *PeerID
	AddFile(ctx context.Context, filename string) (string, error)
	AddDir(ctx context.Context, dir string) (string, error)
	PinHash(ctx context.Context, hash string) error
	UnpinHash(ctx context.Context, hash string) error
	PinCheck(ctx context.Context, hash ...string) (int, error)
}

Node ...

func NewClusterNode added in v0.1.0

func NewClusterNode(addr string) Node

NewClusterNode ...

func NewSingleNode added in v0.1.0

func NewSingleNode(addr string) Node

NewSingleNode ...

type PeerID

type PeerID struct {
	Addresses       []string `json:"Addresses"`
	AgentVersion    string   `json:"AgentVersion"`
	ID              string   `json:"ID"`
	ProtocolVersion string   `json:"ProtocolVersion"`
	PublicKey       string   `json:"PublicKey"`
}

PeerID ...

type Queue added in v0.1.27

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

Queue ...

func NewQueue added in v0.1.27

func NewQueue(c cacher.Cacher) *Queue

NewQueue ...

func (*Queue) Add added in v0.1.27

func (q *Queue) Add(s string)

Add ...

func (*Queue) Delete added in v0.1.27

func (q *Queue) Delete(s string)

Delete ...

func (*Queue) Finish added in v0.1.27

func (q *Queue) Finish(s string)

Finish ...

func (*Queue) Get added in v0.1.27

func (q *Queue) Get() (v string, b bool)

Get ...

func (*Queue) Has added in v0.1.27

func (q *Queue) Has(s string) bool

Has ...

func (*Queue) IsRunning added in v0.1.27

func (q *Queue) IsRunning(s string) (b bool)

IsRunning ...

func (*Queue) List added in v0.1.27

func (q *Queue) List() []string

List ...

func (*Queue) Restore added in v0.1.27

func (q *Queue) Restore() ([]string, error)

Restore ...

func (*Queue) Running added in v0.1.27

func (q *Queue) Running(work IWork) (b bool)

Running ...

func (*Queue) Stop added in v0.1.27

func (q *Queue) Stop(id string)

Stop ...

type Sample

type Sample struct {
	Index int64  `json:"Index"`
	Thumb string `json:"Thumb"`
	Image string `json:"Image"`
	Title string `json:"Title"`
}

Sample ...

type Scale

type Scale = fftool.Scale

type Task

type Task struct {
	Limit     int
	Interval  int
	ClearTemp bool
	// contains filtered or unexported fields
}

Task ...

func NewTask

func NewTask() *Task

NewTask ...

func (*Task) AddWorker

func (t *Task) AddWorker(work IWork, force bool) error

AddWorker ...

func (*Task) AllRun added in v0.0.9

func (t *Task) AllRun() (works []IWork, e error)

AllRun ...

func (*Task) AutoStop

func (t *Task) AutoStop() bool

AutoStop ...

func (*Task) GetWork added in v0.0.7

func (t *Task) GetWork(id string) (IWork, error)

GetWork ...

func (*Task) GetWorkStatus added in v0.0.7

func (t *Task) GetWorkStatus(id string) (WorkStatus, error)

GetWorkStatus ...

func (*Task) SetAutoStop

func (t *Task) SetAutoStop(autoStop bool)

SetAutoStop ...

func (*Task) Start

func (t *Task) Start() error

Start ...

func (*Task) StartWork added in v0.0.9

func (t *Task) StartWork(id string) error

StartWork ...

func (*Task) Stop

func (t *Task) Stop()

Stop ...

func (*Task) StopWork added in v0.0.9

func (t *Task) StopWork(id string)

StopWork ...

type Video

type Video struct {
	Model        `xorm:"extends" json:"-"`
	No           string   `xorm:"no" json:"no"`                       //编号
	Intro        string   `xorm:"varchar(2048)" json:"intro"`         //简介
	Alias        []string `xorm:"json" json:"alias"`                  //别名,片名
	ThumbHash    string   `xorm:"thumb_hash" json:"thumb_hash"`       //缩略图
	PosterHash   string   `xorm:"poster_hash" json:"poster_hash"`     //海报地址
	SourceHash   string   `xorm:"source_hash" json:"source_hash"`     //原片地址
	M3U8Hash     string   `xorm:"m3u8_hash" json:"m3u8_hash"`         //切片地址
	Key          string   `xorm:"key"  json:"-"`                      //秘钥
	M3U8         string   `xorm:"m3u8" json:"-"`                      //M3U8名
	Role         []string `xorm:"json" json:"role"`                   //主演
	Director     string   `xorm:"director" json:"director"`           //导演
	Systematics  string   `xorm:"systematics" json:"systematics"`     //分级
	Season       string   `xorm:"season" json:"season"`               //季
	TotalEpisode string   `xorm:"total_episode" json:"total_episode"` //总集数
	Episode      string   `xorm:"episode" json:"episode"`             //集数
	Producer     string   `xorm:"producer" json:"producer"`           //生产商
	Publisher    string   `xorm:"publisher" json:"publisher"`         //发行商
	Type         string   `xorm:"type" json:"type"`                   //类型:film,FanDrama
	Format       string   `xorm:"format" json:"format"`               //输出格式:3D,2D,VR(VR格式:Half-SBS:左右半宽,Half-OU:上下半高,SBS:左右全宽)
	Language     string   `xorm:"language" json:"language"`           //语言
	Caption      string   `xorm:"caption" json:"caption"`             //字幕
	Group        string   `xorm:"group" json:"-"`                     //分组
	Index        string   `xorm:"index" json:"-"`                     //索引
	Date         string   `xorm:"'date'" json:"date"`                 //发行日期
	Sharpness    string   `xorm:"sharpness" json:"sharpness"`         //清晰度
	Series       string   `xorm:"series" json:"series"`               //系列
	Tags         []string `xorm:"json tags" json:"tags"`              //标签
	Length       string   `xorm:"length" json:"length"`               //时长
	Sample       []string `xorm:"json sample" json:"sample"`          //样板图
	Uncensored   bool     `xorm:"uncensored" json:"uncensored"`       //有码,无码
}

Video ...

func (*Video) BeforeInsert

func (v *Video) BeforeInsert()

BeforeInsert ...

func (Video) JSONVersion added in v0.1.25

func (v Video) JSONVersion() string

JSONVersion ...

func (Video) MarshalJSONVersion added in v0.1.24

func (v Video) MarshalJSONVersion() (string, error)

MarshalJSONVersion ...

func (*Video) Sync

func (v *Video) Sync() error

Sync ...

func (*Video) Table

func (v *Video) Table() interface{}

Table ...

type VideoPornInfo

type VideoPornInfo struct {
	From          string    `json:"From"`          //来源
	Uncensored    bool      `json:"Uncensored"`    //无码
	ID            string    `json:"ID"`            //番号
	Title         string    `json:"Title"`         //标题
	OriginalTitle string    `json:"OriginalTitle"` //原始标题
	Year          string    `json:"Year"`          //日期
	ReleaseDate   string    `json:"ReleaseDate"`   //发行日
	Studio        string    `json:"Studio"`        //工作室
	MovieSet      string    `json:"MovieSet"`      //系列
	Plot          string    `json:"Plot"`          //情节
	Genres        []*Genre  `json:"Genres"`        //类型,标签
	Actors        []*Actor  `json:"Actors"`        //演员
	Image         string    `json:"Image"`         //海报
	Thumb         string    `json:"Thumb"`         //缩略图
	Sample        []*Sample `json:"Sample"`        //样板图
}

VideoPornInfo ...

func (VideoPornInfo) Video

func (v VideoPornInfo) Video() *Video

Video ...

type VideoPornSource

type VideoPornSource struct {
	Bangumi    string    `json:"bangumi"`     //番号 no
	VideoPath  []string  `json:"video_path"`  //视频地址
	SourceHash string    `json:"source_hash"` //原片hash
	ThumbPath  string    `json:"thumb_path"`  //缩略图路径
	PosterPath string    `json:"poster_path"` //海报路径
	Format     string    `json:"format"`      //输出:3D,2D
	Thumb      string    `json:"thumb"`       //缩略图HASH
	Poster     string    `json:"poster"`      //海报HASH
	Intro      string    `json:"intro"`       //简介 title
	Alias      []string  `json:"alias"`       //别名,片名
	Role       []string  `json:"role"`        //角色列表 stars
	Director   string    `json:"director"`    //导演
	Date       string    `json:"date"`        //发行日
	Length     string    `json:"length"`      //片长
	Producer   string    `json:"producer"`    //制片商
	Series     string    `json:"series"`      //系列
	Tags       []string  `json:"tags"`        //标签
	Publisher  string    `json:"publisher"`   //发行商
	Language   string    `json:"language"`    //语言
	Caption    string    `json:"caption"`     //字幕
	Uncensored bool      `json:"uncensored"`  //有码,无码
	ExtendList []*Extend `json:"extend_list"` //扩展信息
}

VideoPornSource ...

func (VideoPornSource) Video

func (v VideoPornSource) Video() *Video

Video ...

type VideoProcessFunc

type VideoProcessFunc func(src []byte) (IVideo, error)

VideoProcessFunc ...

type Work

type Work struct {
	*WorkImpl
	WorkType string
	Value    []byte
	// contains filtered or unexported fields
}

Work ...

func (Work) CheckStop

func (w Work) CheckStop(f func() error) error

CheckStop ...

func (Work) ID

func (w Work) ID() string

ID ...

func (*Work) Info added in v0.0.7

func (w *Work) Info() string

Info ...

func (Work) Output

func (w Work) Output() string

Output ...

func (*Work) Reset

func (w *Work) Reset() error

Reset ...

func (*Work) Run

func (w *Work) Run(ctx context.Context) (e error)

Run ...

func (Work) Status

func (w Work) Status() WorkStatus

Status ...

func (*Work) Stop

func (w *Work) Stop() error

Stop ...

func (*Work) Store

func (w *Work) Store() error

Store ...

func (*Work) Update

func (w *Work) Update() error

Update ...

func (*Work) Video added in v0.0.8

func (w *Work) Video() *Video

Video ...

func (*Work) Work added in v0.0.8

func (w *Work) Work() *Work

Work ...

type WorkImpl

type WorkImpl struct {
	ID         string
	Status     WorkStatus
	VideoPaths []string
	PosterPath string
	ThumbPath  string
	SamplePath []string
	Scale      Scale
	Output     string
	Skip       []string
	ClearTemp  bool
}

WorkImpl ...

type WorkOptions

type WorkOptions func(impl *WorkImpl)

WorkOptions ...

func ClearTempOption added in v0.1.27

func ClearTempOption(b bool) WorkOptions

ClearTempOption ...

func IDOption

func IDOption(id string) WorkOptions

IDOption ...

func OutputPathOption

func OutputPathOption(path string) WorkOptions

OutputPathOption ...

func PosterPathOption

func PosterPathOption(path string) WorkOptions

PosterPathOption ...

func SamplePathOption

func SamplePathOption(path []string) WorkOptions

SamplePathOption ...

func ScaleOption

func ScaleOption(scale Scale) WorkOptions

ScaleOption ...

func SkipOption

func SkipOption(skip ...string) WorkOptions

SkipOption ...

func ThumbPathOption

func ThumbPathOption(path string) WorkOptions

ThumbPathOption ...

func VideoPathOption

func VideoPathOption(path []string) WorkOptions

VideoPathOption ...

type WorkStatus

type WorkStatus int

WorkStatus ...

const (
	WorkAbnormal WorkStatus = iota
	WorkWaiting
	WorkRunning
	WorkStopped
	WorkFinish
)

WorkWaiting ...

Jump to

Keyboard shortcuts

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