-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvideo.go
More file actions
112 lines (101 loc) · 3.61 KB
/
video.go
File metadata and controls
112 lines (101 loc) · 3.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
package conversion
import (
"bufio"
"crypto/sha256"
"encoding/hex"
"encoding/json"
"io"
"os"
)
// 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"` //有码,无码
}
func init() {
registerTable(&Video{})
}
// MarshalJSONVersion ...
func (v Video) MarshalJSONVersion() (string, error) {
bys, e := json.Marshal(v)
if e != nil {
return "", e
}
return string(bys), nil
}
// JSONVersion ...
func (v Video) JSONVersion() string {
return "v0.0.1"
}
// BeforeInsert ...
func (v *Video) BeforeInsert() {
v.Model.BeforeInsert()
if len(v.Role) == 0 {
v.Role = []string{}
}
if len(v.Alias) == 0 {
v.Alias = []string{}
}
if len(v.Tags) == 0 {
v.Tags = []string{}
}
if len(v.Sample) == 0 {
v.Sample = []string{}
}
}
// Sync ...
func (v *Video) Sync() error {
return _database.Sync2(v)
}
// Table ...
func (v *Video) Table() interface{} {
return &Video{}
}
// IVideo ...
type IVideo interface {
Video() *Video
}
// Checksum ...
func Checksum(filepath string) string {
hash := sha256.New()
file, e := os.Open(filepath)
if e != nil {
return ""
}
defer file.Close()
reader := bufio.NewReader(file)
_, e = io.Copy(hash, reader)
if e != nil {
return ""
}
return hex.EncodeToString(hash.Sum(nil))
}