model

package
v0.0.0-...-83adff0 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2020 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// default name of folder
	InitFolderName = "默认收藏夹"
	// state
	StateNormal = int8(0)
	StateIsDel  = int8(1)
	// attr bit bit  from left
	AttrBitPublic      = uint(0)
	AttrBitDefault     = uint(1)
	AttrBitAudit       = uint(2)
	AttrBitAdminDelete = uint(3)
	AttrBitName        = uint(4)
	AttrBitDesc        = uint(5)
	AttrBitCover       = uint(6)
	AttrBitSensitive   = uint(7)

	AttrIsPublic  = int32(0) // 公开
	AttrIsDefault = int32(0) // 默认
	// foler attr
	AttrBitPrivate      = int32(1)
	AttrBitNoDefault    = int32(1) << AttrBitDefault
	AttrBitNeedAudit    = int32(1) << AttrBitAudit
	AttrBitHitSensitive = int32(1) << AttrBitSensitive

	AttrDefaultPublic   = 0                                 // binary 0 / int 0
	AttrDefaultNoPublic = AttrBitPrivate                    // binary 01 / int 1
	AttrNormalPublic    = AttrBitNoDefault                  // binary 10 / int 2
	AttrNormalNoPublic  = AttrBitNoDefault | AttrBitPrivate // binary 11 / int 3
	// limit
	DefaultFolderLimit = 50000
	NormalFolderLimit  = 999
	// cache
	CacheNotFound = -1
	// max type
	TypeMax = 20
	// sort field
	SortPubtime = "pubtime"
	SortMtime   = "mtime"
	SortView    = "view"
)
View Source
const (
	// type
	FieldFav      = "folder"
	FieldArc      = "video"
	FieldResource = "resource"
	// action
	ActionAdd                    = "add"
	ActionDel                    = "del"
	ActionMove                   = "move"
	ActionCopy                   = "copy"
	ActionMdel                   = "mdel"
	ActionIndef                  = "indef"
	ActionIncol                  = "incol"
	ActionClean                  = "clean"
	ActionInitRelationFids       = "initRelationFids"
	ActionInitFolderRelations    = "initFolderRelations"
	ActionInitAllFolderRelations = "initAllFolderRelations"
	ActionMultiAdd               = "multiAdd"
	ActionMultiDel               = "multiDel"
	ActionFolderAdd              = "folderAdd"
	ActionFolderDel              = "folderDel"
	ActionSortFavs               = "sortFavs"
)
View Source
const (
	Article       = int8(1)
	TypeVideo     = int8(2)
	TypeMusic     = int8(3)
	TypeTopic     = int8(4)
	TypePlayVideo = int8(5)
	TypePlayList  = int8(6)
	TypeBangumi   = int8(7)
	TypeMoe       = int8(8)
	TypeComic     = int8(9)
	TypeEsports   = int8(10)
	TypeMediaList = int8(11)
	TypeMusicNew  = int8(12)
)
View Source
const (
	TopicCacheMiss = -1
	// http mode
	HttpMode4Http  = 1 // eg "http://a.bilibili.com"
	HttpMode4Https = 2 // eg "https://a.bilibili.com"
	HttpMode4Both  = 3 // eg "//a.bilibili.com"
)
View Source
const (
	StateDefaultPublic   = int8(0)        // binary 00 / int 0
	StateDefaultNoPublic = int8(0) | bit1 // binary 01 / int 1
	StateNormalPublic    = bit2 | int8(0) // binary 10 / int 2
	StateNormalNoPublic  = bit2 | bit1    // binary 11 / int 3
	// DefaultFolderName default name of favorite folder
	DefaultFolderName = "默认收藏夹"
	// AllFidFlag all folder id flag
	AllFidFlag = -1
	// CDFlag cool down flag
	CDFlag = -1
	// search error code
	SearchErrWordIllegal = -110 // 非法搜索词错误
	// clean state
	StateAllowToClean = 0
	StateCleaning     = 1
	StateCleanCD      = 2
)

Variables

View Source
var (
	ErrInvalidLengthFav = fmt.Errorf("proto: negative length found during unmarshaling")
	ErrIntOverflowFav   = fmt.Errorf("proto: integer overflow")
)

Functions

func CheckArg

func CheckArg(tp int8, oid int64) error

func CheckPublic

func CheckPublic(state int8) bool

CheckPublic check user update public value in [0, 1].

func CheckType

func CheckType(typ int8) error

func CleanURL

func CleanURL(url string) (path string)

CleanURL cuts host.

func CompleteURL

func CompleteURL(path string) (url string)

CompleteURL adds host on path.

func IsDefault

func IsDefault(state int8) bool

IsDefault return true if state is default state.

func IsMediaList

func IsMediaList(typ int32) bool

func ToBytes

func ToBytes(ids []int64) []byte

ToBytes return []byte for ids.

func ToInt64s

func ToInt64s(b []byte) (ids []int64, err error)

ToInt64s bytes to int64s.

Types

type AppInfo

type AppInfo struct {
	Platform string
	Build    string
	MobiApp  string
	Device   string
}

type Archive

type Archive struct {
	Id    int64      `json:"id"`
	Mid   int64      `json:"mid"`
	Fid   int64      `json:"fid"`
	Aid   int64      `json:"aid"`
	CTime xtime.Time `json:"-"`
	MTime xtime.Time `json:"-"`
}

type ArgAdd

type ArgAdd struct {
	Type   int8
	Mid    int64
	Oid    int64
	Fid    int64
	RealIP string
}

type ArgAddFolder

type ArgAddFolder struct {
	Type        int8
	Mid         int64
	Name        string
	Description string
	Cover       string
	Public      int8
	Cookie      string
	AccessKey   string
	RealIP      string
}

type ArgAddVideo

type ArgAddVideo struct {
	Mid       int64
	Fids      []int64
	Aid       int64
	Cookie    string
	AccessKey string
	RealIP    string
}

type ArgAdds

type ArgAdds struct {
	Type   int8
	Mid    int64
	Oid    int64
	Fids   []int64
	RealIP string
}

type ArgAllFolders

type ArgAllFolders struct {
	Type   int8
	Mid    int64
	Vmid   int64
	Oid    int64
	RealIP string
}

type ArgCntUserFolders

type ArgCntUserFolders struct {
	Type   int8
	Mid    int64
	Vmid   int64
	RealIP string
}

type ArgDel

type ArgDel struct {
	Type   int8
	Mid    int64
	Oid    int64
	Fid    int64
	RealIP string
}

type ArgDelFolder

type ArgDelFolder struct {
	Type   int8
	Mid    int64
	Fid    int64
	RealIP string
}

type ArgDels

type ArgDels struct {
	Type   int8
	Mid    int64
	Oid    int64
	Fids   []int64
	RealIP string
}

type ArgFVmid

type ArgFVmid struct {
	Fid  int64
	Vmid int64
}

func (*ArgFVmid) MediaID

func (f *ArgFVmid) MediaID() int64

type ArgFavoredVideos

type ArgFavoredVideos struct {
	Mid    int64
	Aids   []int64
	RealIP string
}

type ArgFavs

type ArgFavs struct {
	Type    int8
	Mid     int64
	Vmid    int64
	Fid     int64
	Tv      int
	Tid     int
	Pn      int
	Ps      int
	Keyword string
	Order   string
	RealIP  string
}

type ArgFolder

type ArgFolder struct {
	Type   int8
	Fid    int64
	Mid    int64
	Vmid   int64
	RealIP string
}

type ArgFolders

type ArgFolders struct {
	Type   int8
	Mid    int64
	FVmids []*ArgFVmid
	RealIP string
}

type ArgInDefaultFolder

type ArgInDefaultFolder struct {
	Type   int8
	Mid    int64
	Oid    int64
	RealIP string
}

type ArgIsFav

type ArgIsFav struct {
	Type   int8
	Mid    int64
	Oid    int64
	RealIP string
}

type ArgIsFavedByFid

type ArgIsFavedByFid struct {
	Type   int8
	Mid    int64
	Oid    int64
	Fid    int64
	RealIP string
}

type ArgIsFavs

type ArgIsFavs struct {
	Type   int8
	Mid    int64
	Oids   []int64
	RealIP string
}

type ArgMultiAdd

type ArgMultiAdd struct {
	Type   int8
	Mid    int64
	Oids   []int64
	Fid    int64
	RealIP string
}

type ArgMultiDel

type ArgMultiDel struct {
	Type   int8
	Mid    int64
	Oids   []int64
	Fid    int64
	RealIP string
}

type ArgRecents

type ArgRecents struct {
	Type   int8
	Mid    int64
	Size   int
	RealIP string
}

type ArgTlists

type ArgTlists struct {
	Type   int8
	Mid    int64
	Vmid   int64
	Fid    int64
	RealIP string
}

type ArgUpdateFolder

type ArgUpdateFolder struct {
	Type        int8
	Fid         int64
	Mid         int64
	Name        string
	Description string
	Cover       string
	Public      int8
	Cookie      string
	AccessKey   string
	RealIP      string
}

type ArgUsers

type ArgUsers struct {
	Type   int8
	Oid    int64
	Pn     int
	Ps     int
	RealIP string
}

type Cover

type Cover struct {
	Aid  int64  `json:"aid"`
	Pic  string `json:"pic"`
	Type int32  `json:"type"`
}

Cover image

type FavArchive

type FavArchive struct {
	*api.Arc
	FavAt          int64  `json:"fav_at"`
	PlayNum        string `json:"play_num"`
	HighlightTitle string `json:"highlight_title"`
}

type Favorite

type Favorite struct {
	ID       int64     `json:"id"`
	Oid      int64     `json:"oid"`
	Mid      int64     `json:"mid"`
	Fid      int64     `json:"fid"`
	Type     int8      `json:"type"`
	State    int8      `json:"state"`
	CTime    time.Time `json:"ctime"`
	MTime    time.Time `json:"mtime"`
	Sequence uint64    `json:"sequence"`
}

func (*Favorite) ResourceID

func (f *Favorite) ResourceID() int64

type Favorites

type Favorites struct {
	Page struct {
		Num   int `json:"num"`
		Size  int `json:"size"`
		Count int `json:"count"`
	} `json:"page"`
	List []*Favorite `json:"list"`
}

type Folder

type Folder struct {
	ID                   int64                       `protobuf:"varint,1,opt,name=ID,proto3" json:"id"`
	Mid                  int64                       `protobuf:"varint,2,opt,name=Mid,proto3" json:"mid"`
	Count                int                         `protobuf:"varint,3,opt,name=Count,proto3,casttype=int" json:"count"`
	Name                 string                      `protobuf:"bytes,4,opt,name=Name,proto3" json:"name"`
	Cover                string                      `protobuf:"bytes,5,opt,name=Cover,proto3" json:"cover"`
	Description          string                      `protobuf:"bytes,6,opt,name=Description,proto3" json:"description"`
	Type                 int8                        `protobuf:"varint,7,opt,name=Type,proto3,casttype=int8" json:"type"`
	Attr                 int32                       `protobuf:"varint,8,opt,name=Attr,proto3" json:"attr"`
	State                int8                        `protobuf:"varint,9,opt,name=State,proto3,casttype=int8" json:"state"`
	Favored              int8                        `protobuf:"varint,10,opt,name=Favored,proto3,casttype=int8" json:"favored"`
	CTime                go_common_library_time.Time `protobuf:"varint,11,opt,name=CTime,proto3,casttype=go-common/library/time.Time" json:"ctime"`
	MTime                go_common_library_time.Time `protobuf:"varint,12,opt,name=MTime,proto3,casttype=go-common/library/time.Time" json:"mtime"`
	RecentOids           []int64                     `protobuf:"varint,13,rep,packed,name=RecentOids" json:"recent_oids"`
	FavedCount           int32                       `protobuf:"varint,14,opt,name=FavedCount,proto3" json:"faved_count"`
	PlayCount            int32                       `protobuf:"varint,15,opt,name=PlayCount,proto3" json:"play_count"`
	ShareCount           int32                       `protobuf:"varint,16,opt,name=ShareCount,proto3" json:"share_count"`
	LikeCount            int32                       `protobuf:"varint,17,opt,name=LikeCount,proto3" json:"like_count"`
	ReplyCount           int32                       `protobuf:"varint,18,opt,name=ReplyCount,proto3" json:"reply_count"`
	RecentRes            []*Resource                 `protobuf:"bytes,19,rep,name=RecentRes" json:"recent_res"`
	XXX_NoUnkeyedLiteral struct{}                    `json:"-"`
	XXX_unrecognized     []byte                      `json:"-"`
	XXX_sizecache        int32                       `json:"-"`
}

func (*Folder) Access

func (f *Folder) Access(mid int64) bool

Access return true if the user has the access permission to the folder.

func (*Folder) AttrSet

func (f *Folder) AttrSet(v int32, bit uint)

AttrSet set attr value by bit.

func (*Folder) AttrVal

func (f *Folder) AttrVal(bit uint) int32

AttrVal get attr val by bit.

func (*Folder) Descriptor

func (*Folder) Descriptor() ([]byte, []int)

func (*Folder) IsDefault

func (f *Folder) IsDefault() bool

IsDefault return true if folder is default.

func (*Folder) IsLimited

func (f *Folder) IsLimited(cnt int, defaultLimit int, normalLimit int) bool

IsLimited return true if folder count is eq or gt conf limit.

func (*Folder) IsPublic

func (f *Folder) IsPublic() bool

IsPublic return true if folder is public.

func (*Folder) Marshal

func (m *Folder) Marshal() (dAtA []byte, err error)

func (*Folder) MarshalTo

func (m *Folder) MarshalTo(dAtA []byte) (int, error)

func (*Folder) MediaID

func (f *Folder) MediaID() int64

func (*Folder) ProtoMessage

func (*Folder) ProtoMessage()

func (*Folder) Reset

func (m *Folder) Reset()

func (*Folder) Size

func (m *Folder) Size() (n int)

func (*Folder) String

func (this *Folder) String() string

func (*Folder) Unmarshal

func (m *Folder) Unmarshal(dAtA []byte) error

func (*Folder) XXX_DiscardUnknown

func (m *Folder) XXX_DiscardUnknown()

func (*Folder) XXX_Marshal

func (m *Folder) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Folder) XXX_Merge

func (dst *Folder) XXX_Merge(src proto.Message)

func (*Folder) XXX_Size

func (m *Folder) XXX_Size() int

func (*Folder) XXX_Unmarshal

func (m *Folder) XXX_Unmarshal(b []byte) error

type FolderSort

type FolderSort struct {
	ID    int64              `json:"id"`
	Type  int8               `json:"type"`
	Mid   int64              `json:"mid"`
	Sort  []int64            `json:"sort"`
	Map   map[int64]struct{} `json:"-"`
	CTime time.Time          `json:"ctime"`
	MTime time.Time          `json:"mtime"`
}

FolderSort folder index.

func (*FolderSort) Index

func (f *FolderSort) Index() []byte

Index return index for fids.

func (*FolderSort) SetIndex

func (f *FolderSort) SetIndex(b []byte) (err error)

SetIndex set sort fids.

func (*FolderSort) SortFolders

func (f *FolderSort) SortFolders(fs map[int64]*Folder, isSelf bool) (res []*Folder, update bool)

SortFolders sort the favorites by index.

type Folders

type Folders []*Folder

Folders .

func (Folders) Len

func (f Folders) Len() int

func (Folders) Less

func (f Folders) Less(i, j int) bool

func (Folders) Swap

func (f Folders) Swap(i, j int)

type Message

type Message struct {
	Field         string    `json:"field,omitempty"`
	Action        string    `json:"action,omitempty"`
	Oid           int64     `json:"oid,omitempty"`
	Otype         int8      `json:"otype,omitempty"`
	Type          int8      `json:"type,omitempty"`
	Mid           int64     `json:"mid,omitempty"`
	OldMid        int64     `json:"old_mid,omitempty"`
	Fid           int64     `json:"fid,omitempty"`
	FidState      int8      `json:"fid_state,omitempty"`
	FolderAttr    int32     `json:"folder_attr,omitempty"`
	OldFolderAttr int32     `json:"old_folder_attr,omitempty"`
	NewFolderAttr int32     `json:"new_folder_attr,omitempty"`
	Aid           int64     `json:"aid,omitempty"`
	OldFid        int64     `json:"old_fid,omitempty"`
	OldFidState   int8      `json:"old_fid_state,omitempty"`
	NewFid        int64     `json:"new_fid,omitempty"`
	NewFidState   int8      `json:"new_fid_state,omitempty"`
	Affected      int64     `json:"affected,omitempty"`
	Aids          []int64   `json:"aids,omitempty"`
	Oids          []int64   `json:"oids,omitempty"`
	Mids          []int64   `json:"mids,omitempty"`
	FTime         int64     `json:"ftime,omitempty"`
	SortFavs      []SortFav `json:"sort_favs,omitempty"`
}

type Partition

type Partition struct {
	Tid   int    `json:"tid"`
	Name  string `json:"name"`
	Count int    `json:"count"`
}

type Resource

type Resource struct {
	Oid                  int64    `protobuf:"varint,1,opt,name=Oid,proto3" json:"oid"`
	Typ                  int32    `protobuf:"varint,2,opt,name=Typ,proto3" json:"typ"`
	XXX_NoUnkeyedLiteral struct{} `json:"-"`
	XXX_unrecognized     []byte   `json:"-"`
	XXX_sizecache        int32    `json:"-"`
}

func (*Resource) Descriptor

func (*Resource) Descriptor() ([]byte, []int)

func (*Resource) Marshal

func (m *Resource) Marshal() (dAtA []byte, err error)

func (*Resource) MarshalTo

func (m *Resource) MarshalTo(dAtA []byte) (int, error)

func (*Resource) ProtoMessage

func (*Resource) ProtoMessage()

func (*Resource) Reset

func (m *Resource) Reset()

func (*Resource) ResourceID

func (r *Resource) ResourceID() int64

func (*Resource) Size

func (m *Resource) Size() (n int)

func (*Resource) String

func (this *Resource) String() string

func (*Resource) Unmarshal

func (m *Resource) Unmarshal(dAtA []byte) error

func (*Resource) XXX_DiscardUnknown

func (m *Resource) XXX_DiscardUnknown()

func (*Resource) XXX_Marshal

func (m *Resource) XXX_Marshal(b []byte, deterministic bool) ([]byte, error)

func (*Resource) XXX_Merge

func (dst *Resource) XXX_Merge(src proto.Message)

func (*Resource) XXX_Size

func (m *Resource) XXX_Size() int

func (*Resource) XXX_Unmarshal

func (m *Resource) XXX_Unmarshal(b []byte) error

type SearchArchive

type SearchArchive struct {
	Code           int    `json:"code,omitempty"`
	Seid           string `json:"seid"`
	Page           int    `json:"page"`
	PageSize       int    `json:"pagesize"`
	NumPages       int    `json:"numPages,omitempty"`
	PageCount      int    `json:"pagecount"`
	NumResults     int    `json:"numResults,omitempty"`
	Total          int    `json:"total"`
	SuggestKeyword string `json:"suggest_keyword"`
	Mid            int64  `json:"mid"`
	Fid            int64  `json:"fid"`
	Tid            int    `json:"tid"`
	Order          string `json:"order"`
	Keyword        string `json:"keyword"`
	TList          []struct {
		Tid   int    `json:"tid"`
		Name  string `json:"name"`
		Count int    `json:"count"`
	} `json:"tlist,omitempty"`
	Result   []*SearchArchiveResult `json:"result,omitempty"`
	Archives []*FavArchive          `json:"archives"`
}

type SearchArchiveResult

type SearchArchiveResult struct {
	ID      int64  `json:"id"`
	Title   string `json:"title"`
	Play    string `json:"play"`
	FavTime int64  `json:"fav_time"`
}

type SortFav

type SortFav struct {
	Pre    *Resource `json:"preID,omitempty"`
	Insert *Resource `json:"id,omitempty"`
}

type Topic

type Topic struct {
	ID       int64     `json:"id"`
	TpID     int64     `json:"tp_id"`
	MID      int64     `json:"mid"`
	FavAt    time.Time `json:"fav_at"`
	State    int64     `json:"state"`
	Stime    string    `json:"stime"`
	Etime    string    `json:"etime"`
	Ctime    string    `json:"ctime"`
	Mtime    string    `json:"mtime"`
	Name     string    `json:"name"`
	Author   string    `json:"author"`
	PCUrl    string    `json:"pc_url"`
	H5Url    string    `json:"h5_url"`
	PCCover  string    `json:"pc_cover"`
	H5Cover  string    `json:"h5_cover"`
	Rank     int64     `json:"rank"`
	PageName string    `json:"page_name"`
	Plat     int64     `json:"plat"`
	Desc     string    `json:"desc"`
	Click    int64     `json:"click"`
	TPType   int64     `json:"type"`
	Mold     int64     `json:"mold"`
	Series   int64     `json:"series"`
	Dept     int64     `json:"dept"`
	ReplyID  int64     `json:"reply_id"`
}

type TopicFav

type TopicFav struct {
	ID    int64     `json:"id"`
	Mid   int64     `json:"mid"`
	TpID  int64     `json:"tpid"`
	Ctime time.Time `json:"ctime"`
	Mtime time.Time `json:"mtime"`
}

type TopicList

type TopicList struct {
	PageNum  int      `json:"page"`
	PageSize int      `json:"pagesize"`
	Total    int64    `json:"total"`
	List     []*Topic `json:"list"`
}

type User

type User struct {
	ID    int64     `json:"id"`
	Oid   int64     `json:"oid"`
	Mid   int64     `json:"mid"`
	Type  int8      `json:"type"`
	State int8      `json:"state"`
	CTime time.Time `json:"ctime"`
	MTime time.Time `json:"mtime"`
}

type UserList

type UserList struct {
	Page struct {
		Num   int `json:"num"`
		Size  int `json:"size"`
		Total int `json:"total"`
	} `json:"page"`
	List []*User `json:"list"`
}

type VideoFolder

type VideoFolder struct {
	MediaId    int64      `json:"media_id"`
	Fid        int64      `json:"fid"`
	Mid        int64      `json:"mid"`
	Name       string     `json:"name"`
	MaxCount   int        `json:"max_count"`
	CurCount   int        `json:"cur_count"`
	AttenCount int        `json:"atten_count"`
	Favoured   int8       `json:"favoured"`
	State      int8       `json:"state"`
	CTime      xtime.Time `json:"ctime"`
	MTime      xtime.Time `json:"mtime"`
	Cover      []*Cover   `json:"cover,omitempty"`
}

func (*VideoFolder) IsDefault

func (f *VideoFolder) IsDefault() bool

IsDefault return true if folder is default.

func (*VideoFolder) IsPublic

func (f *VideoFolder) IsPublic() bool

IsPublic return true if folder is public.

func (*VideoFolder) StateDef

func (f *VideoFolder) StateDef() int8

StateDef return folder's default state.

func (*VideoFolder) StatePub

func (f *VideoFolder) StatePub() int8

StatePub return folder's public state.

type VideoFolderSort

type VideoFolderSort struct {
	ID    int64              `json:"id"`
	Mid   int64              `json:"mid"`
	Sort  []int64            `json:"sort"`
	Map   map[int64]struct{} `json:"map"`
	CTime xtime.Time         `json:"ctime"`
	MTime xtime.Time         `json:"mtime"`
}

VideoFolderSort folder index.

func (*VideoFolderSort) Index

func (f *VideoFolderSort) Index() []byte

Index return index for fids.

func (*VideoFolderSort) SetIndex

func (f *VideoFolderSort) SetIndex(b []byte) (err error)

SetIndex set sort fids.

func (*VideoFolderSort) SortFavs

func (f *VideoFolderSort) SortFavs(fs map[int64]*VideoFolder, isSelf bool) (res []*VideoFolder, update bool)

SortFavs sort the favorites by index.

type VideoFolders

type VideoFolders []*VideoFolder

func (VideoFolders) Len

func (f VideoFolders) Len() int

func (VideoFolders) Less

func (f VideoFolders) Less(i, j int) bool

func (VideoFolders) Swap

func (f VideoFolders) Swap(i, j int)

Jump to

Keyboard shortcuts

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