Create & Init Project...

This commit is contained in:
2019-04-22 18:49:16 +08:00
commit fc4fa37393
25440 changed files with 4054998 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [
":package-srcs",
"//app/job/main/tv/model/common:all-srcs",
"//app/job/main/tv/model/pgc:all-srcs",
"//app/job/main/tv/model/report:all-srcs",
"//app/job/main/tv/model/ugc:all-srcs",
],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,30 @@
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"sync_retry.go",
"zone_idx.go",
],
importpath = "go-common/app/job/main/tv/model/common",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//library/time:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,34 @@
package common
import "fmt"
const (
_ctypeSN = "retry_sn"
_ctypeEP = "retry_ep"
)
// SyncRetry is the struct used for retry info storage
type SyncRetry struct {
Ctype string
Retry int
CID int64
}
// FromSn def.
func (v *SyncRetry) FromSn(retry int, sid int64) {
v.Ctype = _ctypeSN
v.Retry = retry
v.CID = sid
}
// FromEp def.
func (v *SyncRetry) FromEp(retry int, epid int64) {
v.Ctype = _ctypeEP
v.Retry = retry
v.CID = epid
}
// MCKey def.
func (v *SyncRetry) MCKey() (key string) {
return v.Ctype + "_" + fmt.Sprintf("%d", v.CID)
}

View File

@@ -0,0 +1,9 @@
package common
import "go-common/library/time"
// IdxRank is for index page ranking
type IdxRank struct {
ID int64
Ctime time.Time
}

View File

@@ -0,0 +1,39 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"content.go",
"databus.go",
"license.go",
"media_cache.go",
"memcache.go",
"pgc.go",
"playurl.go",
"search.go",
"style.go",
],
importpath = "go-common/app/job/main/tv/model/pgc",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = ["//library/time:go_default_library"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,28 @@
package pgc
import "go-common/library/time"
// Content content def.
type Content struct {
ID int64 `json:"id"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Desc string `json:"desc"`
Cover string `json:"cover"`
EPID int `json:"epid"`
CID int `json:"cid"`
MenuID int `json:"menu_id"`
SeasonID int `json:"season_id"`
State int `json:"state"`
Valid int `json:"valid"`
PayStatus int `json:"pay_status"`
IsDeleted int `json:"is_deleted"`
AuditTime int `json:"audit_time"`
Ctime time.Time `json:"ctime"`
Mtime time.Time `json:"mtime"`
}
// TableName tv_content
func (c Content) TableName() string {
return "tv_content"
}

View File

@@ -0,0 +1,94 @@
package pgc
// MediaEP is the new structure of ep in Databus Msg
type MediaEP struct {
ID int64 `json:"id"`
EPID int `json:"epid"`
SeasonID int `json:"season_id"`
State int `json:"state"`
Valid int `json:"valid"`
IsDeleted int `json:"is_deleted"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
Cover string `json:"cover"`
Mark int `json:"mark"`
CID int64 `json:"cid"`
PayStatus int `json:"pay_status"`
}
// MediaSn is the new structure of season in Databus Msg
type MediaSn struct {
ID int64 `json:"id"`
IsDeleted int8 `json:"is_deleted"`
Valid int `json:"valid"`
Check int8 `json:"check"`
Title string `json:"title"`
Cover string `json:"cover"`
Desc string `json:"desc"`
UpInfo string `json:"upinfo"`
Ctime string `json:"ctime"`
Category int `json:"category"`
Area string `json:"area"`
Playtime string `json:"play_time"`
Role string `json:"role"`
Staff string `json:"staff"`
TotalNum int `json:"total_num"`
Style string `json:"style"`
Producer string `json:"producer"`
Version string `json:"version"`
AliasSearch string `json:"alias_search"`
Brief string `json:"brief"`
Status int `json:"status"`
}
// DatabusRes is the result of databus message
type DatabusRes struct {
Action string `json:"action"`
Table string `json:"table"`
}
// DatabusEP is the struct of message for the modification of tv_content
type DatabusEP struct {
New *MediaEP `json:"new"`
Old *MediaEP `json:"old"`
}
// DatabusSeason is the struct of message for the modification of tv_ep_season
type DatabusSeason struct {
Old *MediaSn `json:"old"`
New *MediaSn `json:"new"`
}
// ToSimple returns SimpleSeason struct
func (m *MediaSn) ToSimple() *SimpleSeason {
return &SimpleSeason{
ID: m.ID,
IsDeleted: m.IsDeleted,
Valid: m.Valid,
Check: m.Check,
}
}
// ToSimple returns SimpleEP struct
func (ep *MediaEP) ToSimple() *SimpleEP {
return &SimpleEP{
ID: ep.ID,
IsDeleted: ep.IsDeleted,
Valid: ep.Valid,
State: ep.State,
SeasonID: ep.SeasonID,
EPID: ep.EPID,
NoMark: ep.Mark,
}
}
// ToCMS returns EpCMS
func (ep *MediaEP) ToCMS() *EpCMS {
return &EpCMS{
EPID: int(ep.EPID),
Cover: ep.Cover,
Title: ep.Title,
Subtitle: ep.Subtitle,
PayStatus: ep.PayStatus,
}
}

View File

@@ -0,0 +1,189 @@
package pgc
import "fmt"
const (
_definition = "SD"
)
// License Owner Request message
// License represents the data that we need to send to the license owner for auditing
type License struct {
TId string
InputTime string
Sign string
XMLData *XMLData
}
// XMLData reprensents the main body of xml data sent to license owner
type XMLData struct {
Service *Service `xml:"Service"`
}
// Service body+head
type Service struct {
ID string `xml:"id,attr"`
Head *Head
Body *Body
}
// Head some header info
type Head struct {
TradeID string `xml:"TradeId"`
Date string
Count int
}
// Body Media list
type Body struct {
ProgramSetList *PSList `xml:"programSetList"`
}
// PSList is short for programSetList
type PSList struct {
ProgramSet []*PS `xml:"programSet"`
}
// PS is short for ProgramSet
type PS struct {
ProgramSetID string `xml:"programSetId"`
ProgramSetName string `xml:"programSetName"`
ProgramSetClass string `xml:"programSetClass"`
ProgramSetType string `xml:"programSetType"`
ProgramSetPoster string `xml:"programSetPoster"`
Portrait string `xml:"portrait"` // upper's portrait
Producer string `xml:"producer"` // upper's name
PublishDate string `xml:"publishDate"`
Copyright string `xml:"copyright"`
ProgramCount int `xml:"programCount"`
CREndData string `xml:"cREndDate"`
DefinitionType string `xml:"definitionType"`
CpCode string `xml:"cpCode"`
PayStatus int `xml:"payStatus"`
PrimitiveName string `xml:"primitiveName"`
Alias string `xml:"alias"`
Zone string `xml:"zone"`
LeadingRole string `xml:"leadingRole"`
ProgramSetDesc string `xml:"programSetDesc"`
Staff string `xml:"Staff"`
SubGenre string `xml:"subGenre"`
ProgramList *ProgramList `xml:"programList,omitempty"`
}
// ProgramList contains different EP
type ProgramList struct {
Program []*Program `xml:"program"`
}
// Program represents one EP data
type Program struct {
ProgramID string `xml:"programId"`
ProgramName string `xml:"programName"`
ProgramPoster string `xml:"programPoster"`
ProgramLength int `xml:"programLength"`
PublishDate string `xml:"publishDate"`
IfPreview int `xml:"ifPreview"`
Number string `xml:"number"`
DefinitionType string `xml:"definitionType"`
PlayCount int `xml:"playCount"`
Drm int `xml:"drm"`
ProgramMediaList *PMList `xml:"programMediaList"`
ProgramDesc string `xml:"programDesc"`
}
// PMList is short for programMediaList
type PMList struct {
ProgramMedia []*PMedia `xml:"programMedia"`
}
// PMedia is short for ProgramMedia
type PMedia struct {
MediaID string `xml:"mediaId"`
PlayURL string `xml:"playUrl"`
Definition string `xml:"definition"`
HTMLURL string `xml:"htmlUrl"`
}
// MakePMedia is used to construct PMedia structure
func MakePMedia(prefix, playurl string, cid int64) *PMedia {
return &PMedia{
MediaID: fmt.Sprintf("%s%d", prefix, cid),
PlayURL: playurl,
Definition: _definition,
HTMLURL: playurl,
}
}
// Document is the result structure of license owner's response
type Document struct {
Response *Response
}
// Response is the main content of response
type Response struct {
TradeID string `xml:"TradeId"`
ResponseCode string
ResponseInfo string
ResponseTime string `xml:"responseTime"`
ErrorList *ErrorList
}
// ErrorList is the list of error returned by the license owner
type ErrorList struct {
Error *Error
}
// Error one error body
type Error struct {
ID string `xml:"Id"`
Message string
}
// DelBody is the bodu message of deletion
type DelBody struct {
ProgramList *ProgramList `xml:"programList"`
}
// CreatePMedia creates PMedia struct
func CreatePMedia(prefix string, epid int, url string) *PMedia {
return &PMedia{
MediaID: prefix + fmt.Sprintf("%d", epid),
PlayURL: url,
Definition: "SD",
HTMLURL: url,
}
}
// CreateProgram creates program
func CreateProgram(prefix string, ep *TVEpContent) *Program {
r := &Program{
ProgramID: prefix + fmt.Sprintf("%d", ep.ID),
ProgramName: ep.LongTitle,
ProgramPoster: ep.Cover,
ProgramLength: int(ep.Length * 60),
PublishDate: "1970-01-01",
IfPreview: 0,
Number: ep.Title,
DefinitionType: "SD",
PlayCount: 0,
Drm: ep.PayStatus,
}
r.isPay()
return r
}
// ReqEpLicCall is the request struct for epLicCall function
type ReqEpLicCall struct {
EpLic *License
SID int64
Conts []*Content
}
// isPay .
func (p *Program) isPay() {
if p.Drm == 2 {
p.Drm = 0
} else {
p.Drm = 1
}
}

View File

@@ -0,0 +1,35 @@
package pgc
import "go-common/library/time"
// SeasonCMS defines the elements could be changed from TV CMS side
type SeasonCMS struct {
SeasonID int
Cover string
Desc string
Title string
UpInfo string // season update information
Category int // - cn, jp, movie, tv, documentary
Area string // - cn, jp, others
Playtime time.Time
Role string
Staff string
NewestOrder int // the newest passed ep's order
NewestEPID int // the newest passed ep's ID
NewestNb int // the newest ep's number ( after keyword filter )
TotalNum int
Style string
OriginName string // new fields
Alias string // new fields
PayStatus int // season's pay status, 0||2 = free, others = pay, pass by conf
}
// EpCMS defines the elements could be changed from TV CMS side
type EpCMS struct {
EPID int `json:"epid"`
Cover string `json:"cover"`
Title string `json:"title"`
Subtitle string `json:"subtitle"`
// new fields
PayStatus int `json:"pay_status"`
}

View File

@@ -0,0 +1,20 @@
package pgc
// SimpleEP is the structure of ep in mc
type SimpleEP struct {
ID int64 `json:"id"`
EPID int `json:"epid"`
SeasonID int `json:"season_id"`
State int `json:"state"`
Valid int `json:"valid"`
IsDeleted int `json:"is_deleted"`
NoMark int `json:"no_mark"`
}
// SimpleSeason is the structure of season in mc
type SimpleSeason struct {
ID int64 `json:"id"`
IsDeleted int8 `json:"is_deleted"`
Valid int `json:"valid"`
Check int8 `json:"check"`
}

View File

@@ -0,0 +1,67 @@
package pgc
import (
"go-common/library/time"
)
// TVEpContent reprensents the content table
type TVEpContent struct {
ID int64
SeasonID int64
CID int64
Title string
LongTitle string
Cover string
Length int32
IsDeleted int8
Order int
Ctime time.Time
Mtime time.Time
PayStatus int
}
// TVEpSeason represents the season table
type TVEpSeason struct {
ID int64
OriginName string
Title string
Alias string
Category int8
Desc string
Style string
Area string
PlayTime time.Time
Info int8
State int8
TotalNum int32
Upinfo string
Staff string
Role string
Copyright string
IsDeleted int8
Ctime time.Time
Mtime time.Time
Check int8
AuditTime int
Cover string
Valid int `json:"valid"`
Producer string `json:"producer"`
Version string `json:"version"`
Status int
}
// Offset used for mysql offset
type Offset struct {
Begin int
End int
}
// TableName gives the table name of content
func (*TVEpContent) TableName() string {
return "tv_ep_content"
}
// TableName gives the table name of season
func (*TVEpSeason) TableName() string {
return "tv_ep_season"
}

View File

@@ -0,0 +1,25 @@
package pgc
// PlayurlResp is the response struct from Playurl API
type PlayurlResp struct {
Code int `json:"code"`
Message string `json:"message"`
From string `json:"from"`
Result string `json:"result"`
Quality int `json:"quality"`
Format string `json:"format"`
Timelength int `json:"timelength"`
AcceptFormat string `json:"accept_format"`
AcceptQuality []int `json:"accept_quality"`
SeekParam string `json:"seek_param"`
SeekType string `json:"seek_type"`
Durl []*Durl `json:"durl"`
}
// Durl def.
type Durl struct {
Order int `json:"order"`
Length int `json:"length"`
Size int `json:"size"`
URL string `json:"url"`
}

View File

@@ -0,0 +1,32 @@
package pgc
import "go-common/library/time"
// SearPgcCon is used for setting search pgc content
type SearPgcCon struct {
ID int `json:"id"`
Category int `json:"category"`
Cover string `json:"cover"`
Title string `json:"title"`
PlayTime time.Time `json:"pubtime"`
Role string `json:"cv"`
Staff string `json:"staff"`
Desc string `json:"description"`
}
// SearUgcCon is used for setting search ugc content
type SearUgcCon struct {
AID int `json:"id"`
Title string `json:"title"`
Cover string `json:"cover"`
Content string `json:"description"`
Pubtime time.Time `json:"pubtime"`
Typeid int `json:"category"`
}
// SearchSug represents the search suggestion unit
type SearchSug struct {
Term string `json:"term"`
ID int `json:"id"`
Type string `json:"type"`
}

View File

@@ -0,0 +1,21 @@
package pgc
// ParamStyle .
type ParamStyle struct {
Name string `json:"name"`
StyleID int `json:"style_id"`
}
// StyleRes .
type StyleRes struct {
ID int
Style string
Category int
}
// LabelRes .
type LabelRes struct {
Name string
Value int
Category int
}

View File

@@ -0,0 +1,28 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = ["report.go"],
importpath = "go-common/app/job/main/tv/model/report",
tags = ["automanaged"],
visibility = ["//visibility:public"],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,50 @@
package report
// table name .
const (
ArchiveClick = "archive_click"
ActiveDuration = "active_duration"
PlayDuration = "play_duration"
VisitEvent = "visit_event"
)
// DpCheckJobResult .
type DpCheckJobResult struct {
Code int `json:"code"`
Msg string `json:"msg"`
StatusID int `json:"statusId"`
StatusMsg string `json:"statusMsg"`
Files []string `json:"hdfsPath"`
}
// ArcClickParam .
func ArcClickParam(b [][]byte) (res map[string]interface{}) {
key := []string{"r_type", "avid", "cid", "part", "mid", "stime", "did", "ip", "ua", "buvid", "cookie_sid", "refer", "type", "sub_type", "sid", "epid", "platform", "device", "request_uri", "time_iso", "ip", "version", "buvid", "fts", "proid", "chid", "pid", "brand", "deviceid", "model", "osver", "ctime", "mid", "ver", "net", "oid", "eid", "start_time", "end_time", "duration", "openudid", "idfa", "mac", "is_coldstart", "session_id", "buvid_ext", "stime", "build", "buvid", "mobi_app", "platform", "session", "mid", "aid", "cid", "sid", "epid", "type", "sub_type", "quality", "total_time", "paused_time", "played_time", "video_duration", "play_type", "network_type", "last_play_progress_time", "max_play_progress_time", "device", "epid_status", "play_status", "user_status", "actual_played_time", "auto_play", "detail_play_time", "list_play_time", "request_uri", "time_iso", "ip", "version", "buvid", "fts", "proid", "chid", "pid", "brand", "deviceid", "model", "osver", "ctime", "mid", "ver", "net", "oid", "page_name", "page_arg", "ua", "h5_chid"}
value := make([]string, len(b))
res = make(map[string]interface{}, 4)
mac := make(map[string]string, 18)
mad := make(map[string]string, 28)
mpd := make(map[string]string, 30)
mve := make(map[string]string, 22)
for k, v := range b {
value[k] = string(v)
}
for k := range key {
if k < len(value) {
if k < 18 {
mac[key[k]] = value[k]
} else if k >= 18 && k < 46 {
mad[key[k]] = value[k]
} else if k >= 46 && k < 76 {
mpd[key[k]] = value[k]
} else if k >= 76 && k < 98 {
mve[key[k]] = value[k]
}
}
}
res[ArchiveClick] = mac
res[ActiveDuration] = mad
res[PlayDuration] = mpd
res[VisitEvent] = mve
return
}

View File

@@ -0,0 +1,38 @@
package(default_visibility = ["//visibility:public"])
load(
"@io_bazel_rules_go//go:def.bzl",
"go_library",
)
go_library(
name = "go_default_library",
srcs = [
"archive.go",
"databus.go",
"media_cache.go",
"sync.go",
"upper.go",
],
importpath = "go-common/app/job/main/tv/model/ugc",
tags = ["automanaged"],
visibility = ["//visibility:public"],
deps = [
"//app/service/main/archive/api:go_default_library",
"//library/time:go_default_library",
],
)
filegroup(
name = "package-srcs",
srcs = glob(["**"]),
tags = ["automanaged"],
visibility = ["//visibility:private"],
)
filegroup(
name = "all-srcs",
srcs = [":package-srcs"],
tags = ["automanaged"],
visibility = ["//visibility:public"],
)

View File

@@ -0,0 +1,138 @@
package ugc
import (
v1 "go-common/app/service/main/archive/api"
"go-common/library/time"
)
// Archive archive def. corresponding to our table structure
type Archive struct {
ID int
AID int64
MID int64
TypeID int32
Videos int64
Title string
Cover string
Content string
Duration int64
Copyright int32
Pubtime time.Time
Ctime time.Time
Mtime time.Time
State int32
Manual int
Valid int
Submit int
Retry int
Result int
Deleted int
}
// FromArcReply def
func (a *Archive) FromArcReply(arc *v1.Arc) {
a.AID = arc.Aid
a.MID = arc.Author.Mid
a.Videos = arc.Videos
a.TypeID = arc.TypeID
a.Title = arc.Title
a.Cover = arc.Pic
a.Content = arc.Desc
a.Duration = arc.Duration
a.Copyright = arc.Copyright
a.Pubtime = arc.PubDate
a.State = arc.State
}
// ArcAllow is the struct used to check whether the arc is allowed to enter TV database
type ArcAllow struct {
Aid int64
State int32
Ugcpay int32
Typeid int32
Copyright int32
}
// FromArcReply takes info from grpc result
func (a *ArcAllow) FromArcReply(reply *v1.Arc) {
a.Aid = reply.Aid
a.State = reply.State
a.Ugcpay = reply.Rights.UGCPay
a.Typeid = reply.TypeID
a.Copyright = reply.Copyright
}
// FromArcmdl takes info from gorpc result
func (a *ArcAllow) FromArcmdl(mdl *v1.Arc) {
a.Aid = mdl.Aid
a.State = mdl.State
a.Ugcpay = mdl.Rights.UGCPay
a.Typeid = mdl.TypeID
a.Copyright = mdl.Copyright
}
// FromDatabus takes info from databus result ( archive-notify T )
func (a *ArcAllow) FromDatabus(db *ArchDatabus) {
a.Aid = db.Aid
a.State = db.State
a.Typeid = db.TypeID
a.Copyright = db.Copyright
}
// FromArcFull takes info from arcFull structure ( db )
func (a *ArcAllow) FromArcFull(full *ArcFull) {
a.Aid = full.AID
a.State = full.State
a.Copyright = full.Copyright
a.Typeid = full.TypeID
}
// FromArchive takes info from DB
func (a *ArcAllow) FromArchive(arc *Archive) {
a.Aid = arc.AID
a.State = arc.State
a.Copyright = arc.Copyright
a.Typeid = arc.TypeID
}
// CanPlay distinguishes whether an archive can play or not
func (a *ArcAllow) CanPlay() bool {
return a.State >= 0 || a.State == -6
}
// IsOrigin distinguishes whether an archive is original or not
func (a *ArcAllow) IsOrigin() bool {
return a.Copyright == 1
}
// ArcMedia is the archive media struct in MC
type ArcMedia struct {
Title string
AID int64
Cover string
TypeID int32
Pubtime time.Time
Videos int64
Deleted int
}
// DelVideos is used to delete videos of an archive
type DelVideos struct {
AID int64
CIDs []int64
}
// ToSimple def.
func (a *Archive) ToSimple() *SimpleArc {
return &SimpleArc{
AID: a.AID,
MID: a.MID,
TypeID: a.TypeID,
Videos: a.Videos,
Title: a.Title,
Cover: a.Cover,
Content: a.Content,
Duration: a.Duration,
Pubtime: a.Pubtime.Time().Format("2006-01-02"),
}
}

View File

@@ -0,0 +1,138 @@
package ugc
import (
"time"
arcmdl "go-common/app/service/main/archive/api"
)
// ArcMsg reprensents the archive Notify-T message structure
type ArcMsg struct {
Action string `json:"action"`
Table string `json:"table"`
Old *ArchDatabus `json:"old"`
New *ArchDatabus `json:"new"`
}
// ArchDatabus model ( we pick the fields that we need )
type ArchDatabus struct {
Aid int64 `json:"aid"`
Mid int64 `json:"mid"`
TypeID int32 `json:"typeid"`
Videos int64 `json:"videos"`
Duration int `json:"duration"`
Title string `json:"title"`
Cover string `json:"cover"`
Content string `json:"content"`
Attribute int32 `json:"attribute"`
Copyright int32 `json:"copyright"`
State int32 `json:"state"`
Access int `json:"access"`
PubTime string `json:"pubtime"`
}
// VideoDiff reprensents the result of videos comparison
type VideoDiff struct {
Aid int64
Equal []int64 // totally equal
New []int64 // new added videos
Updated []*arcmdl.Page
Removed []int64
}
// DatabusVideo is the struct of message for the modification of ugc_Video
type DatabusVideo struct {
New *MarkVideo `json:"new"`
Old *MarkVideo `json:"old"`
}
// DatabusArc is the struct of message for the modification of ugc_archive
type DatabusArc struct {
Old *MarkArc `json:"old"`
New *MarkArc `json:"new"`
}
// MarkVideo contains the main fields that we want to pick up from databus message
type MarkVideo struct {
Mark int `json:"mark"`
Deleted int `json:"deleted"`
CID int64 `json:"cid"`
AID int64 `json:"aid"`
EPTitle string `json:"eptitle"`
IndexOrder int `json:"index_order"`
Valid int `json:"valid"`
Result int `json:"result"`
Submit int `json:"submit"`
Transcoded int `json:"transcoded"`
Retry int64 `json:"retry"`
}
// MarkArc contains the main fields that we want to pick up from databus message
type MarkArc struct {
ID int `json:"id"`
AID int64 `json:"aid"`
MID int `json:"mid"`
TypeID int32 `json:"typeid"`
Videos int `json:"videos"`
Title string `json:"title"`
Cover string `json:"cover"`
Content string `json:"content"`
Duration int `json:"duration"`
Copyright int `json:"copyright"`
Pubtime string `json:"pubtime"`
Ctime string `json:"ctime"`
Mtime string `json:"mtime"`
State int `json:"state"`
Manual int `json:"manual"`
Valid int `json:"valid"`
Submit int `json:"submit"`
Retry int `json:"retry"`
Result int `json:"result"`
Deleted int `json:"deleted"`
InjectTime string `json:"inject_time"`
Reason string `json:"reason"`
}
// IsPass returns whether the arc is able to play
func (a MarkArc) IsPass() bool {
return a.Deleted == 0 && a.Valid == 1 && a.Result == 1
}
// CidReq reprensents the structure for reporting cid
type CidReq struct {
CID int64 `json:"cid"`
}
// CidResp represents the structure of cid reporting API's response
type CidResp struct {
Code int `json:"code"`
Message string `json:"message"`
}
// ToReport distinguishes whether the CID need to be reported to video cloud
func (vm *MarkVideo) ToReport(criCID int64) bool {
return vm.Deleted == 0 && vm.Mark == 0 && vm.CID > criCID
}
// ToAudit distinguishes whether the CID need to be reported to the license owner
func (vm *MarkVideo) ToAudit(criCID int64) bool {
return vm.Submit == 1 && (vm.Transcoded == 1 || vm.CID <= criCID) && vm.Retry < time.Now().Unix() && vm.Deleted == 0
}
// CanPlay tells whether a video can play or not
func (vm *MarkVideo) CanPlay() bool {
return vm.Result == 1 && vm.Deleted == 0 && vm.Valid == 1
}
// ToCMS transforms a databus video to CMS info
func (vm *MarkVideo) ToCMS() *VideoCMS {
return &VideoCMS{
CID: int(vm.CID),
Title: vm.EPTitle,
AID: int(vm.AID),
IndexOrder: vm.IndexOrder,
Valid: vm.Valid,
Deleted: vm.Deleted,
Result: vm.Result,
}
}

View File

@@ -0,0 +1,56 @@
package ugc
import "go-common/library/time"
// ArcCMS represents the archive data structure in MC
type ArcCMS struct {
// Media Info
Title string
AID int64
Content string
Cover string
TypeID int32
Pubtime time.Time
Videos int
// Auth Info
Valid int
Deleted int
Result int
}
// ArcFull is the plus version of ArcCMS
type ArcFull struct {
ArcCMS
Copyright int32
State int32
MID int64
Duration int64
}
// VideoCMS represents the video data structure in MC
type VideoCMS struct {
// Media Info
CID int
Title string
AID int
IndexOrder int
// Auth Info
Valid int
Deleted int
Result int
}
// ToSimple transforms an arcFull to SimpleArc
func (arc *ArcFull) ToSimple() *SimpleArc {
return &SimpleArc{
AID: arc.AID,
MID: arc.MID,
TypeID: arc.TypeID,
Videos: int64(arc.Videos),
Title: arc.Title,
Cover: arc.Cover,
Content: arc.Content,
Duration: arc.Duration,
Pubtime: arc.Pubtime.Time().Format("2006-01-02"),
}
}

View File

@@ -0,0 +1,30 @@
package ugc
// SimpleArc provides the fields for license owner sync
type SimpleArc struct {
AID int64
MID int64
TypeID int32
Videos int64
Title string
Cover string
Content string
Duration int64
Pubtime string
}
// SimpleVideo provides the fields for license owner sync
type SimpleVideo struct {
ID int
CID int64
IndexOrder int64
Eptitle string
Duration int64
Description string
}
// LicSke represents the skeleton of a license audit message
type LicSke struct {
Arc *SimpleArc
Videos []*SimpleVideo
}

View File

@@ -0,0 +1,71 @@
package ugc
import "strings"
// Upper reprensents the uppers
type Upper struct {
MID int64
Toinit int
Submit int // 1=need report
OriName string // original name
CMSName string // cms intervened name
OriFace string // original face
CMSFace string // cms intervened face
Valid int // auth info: 1=online,0=hidden
Deleted int
}
// EasyUp is the simple version of upper
type EasyUp struct {
MID int64
Name string
Face string
}
// ToUpper transform an EasyUp to Upper
func (u *EasyUp) ToUpper(ori *Upper) *Upper {
if ori == nil { // if no original data is given
ori = &Upper{
Valid: 1,
}
}
return &Upper{
MID: u.MID,
OriFace: u.Face,
CMSFace: u.Face,
OriName: u.Name,
CMSName: u.Name,
Toinit: ori.Toinit,
Submit: ori.Submit,
Valid: ori.Valid,
Deleted: ori.Deleted,
}
}
// IsSame returns whether the upper is the same
func (u *Upper) IsSame(name, face string) (f bool, n bool) {
n = u.OriName == name
if strings.Contains(u.OriFace, "bfs") &&
strings.Contains(face, "bfs") {
f = bfsFName(u.OriFace) == bfsFName(face)
} else {
f = u.OriFace == face
}
return
}
// bfsFName picks the file name from bfs url
func bfsFName(bfsurl string) (fileName string) {
var index = strings.LastIndex(bfsurl, "/")
if index >= 0 && index+1 < len(bfsurl) {
fileName = bfsurl[index+1:]
}
return
}
// ReqSetUp is the structure of request to function in Dao, set upper value
type ReqSetUp struct {
Value string
MID int64
UpType int
}