]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/video/video-interface.ts
First step upload with new design
[github/Chocobozzz/PeerTube.git] / server / models / video / video-interface.ts
CommitLineData
e4f97bab 1import * as Bluebird from 'bluebird'
7a7724e6
C
2import * as Sequelize from 'sequelize'
3import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object'
4import { ResultList } from '../../../shared/models/result-list.model'
5import { Video as FormattedVideo, VideoDetails as FormattedDetailsVideo } from '../../../shared/models/videos/video.model'
39445ead 6import { AccountVideoRateInstance } from '../account/account-video-rate-interface'
e02643f3 7
6fcd19ba 8import { TagAttributes, TagInstance } from './tag-interface'
72c7248b 9import { VideoChannelInstance } from './video-channel-interface'
7a7724e6 10import { VideoFileAttributes, VideoFileInstance } from './video-file-interface'
e71bcc0f 11import { VideoShareInstance } from './video-share-interface'
69818c93 12
e02643f3 13export namespace VideoMethods {
70c065d6
C
14 export type GetThumbnailName = (this: VideoInstance) => string
15 export type GetPreviewName = (this: VideoInstance) => string
70c065d6 16 export type IsOwned = (this: VideoInstance) => boolean
0aef76c4 17 export type ToFormattedJSON = (this: VideoInstance) => FormattedVideo
72c7248b 18 export type ToFormattedDetailsJSON = (this: VideoInstance) => FormattedDetailsVideo
69818c93 19
40298b02 20 export type GetOriginalFile = (this: VideoInstance) => VideoFileInstance
93e1258c
C
21 export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string
22 export type GetVideoFilename = (this: VideoInstance, videoFile: VideoFileInstance) => string
23 export type CreatePreview = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
24 export type CreateThumbnail = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
25 export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string
26 export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
27
e4f97bab 28 export type ToActivityPubObject = (this: VideoInstance) => VideoTorrentObject
69818c93 29
40298b02
C
30 export type OptimizeOriginalVideofile = (this: VideoInstance) => Promise<void>
31 export type TranscodeOriginalVideofile = (this: VideoInstance, resolution: number) => Promise<void>
32 export type GetOriginalFileHeight = (this: VideoInstance) => Promise<number>
d8755eed
C
33 export type GetEmbedPath = (this: VideoInstance) => string
34 export type GetThumbnailPath = (this: VideoInstance) => string
35 export type GetPreviewPath = (this: VideoInstance) => string
9567011b
C
36 export type GetDescriptionPath = (this: VideoInstance) => string
37 export type GetTruncatedDescription = (this: VideoInstance) => string
e4f97bab
C
38 export type GetCategoryLabel = (this: VideoInstance) => string
39 export type GetLicenceLabel = (this: VideoInstance) => string
40 export type GetLanguageLabel = (this: VideoInstance) => string
6fcd19ba 41
e4f97bab 42 export type List = () => Bluebird<VideoInstance[]>
6fcd19ba 43
e71bcc0f
C
44 export type ListAllAndSharedByAccountForOutbox = (
45 accountId: number,
46 start: number,
47 count: number
48 ) => Bluebird< ResultList<VideoInstance> >
e4f97bab
C
49 export type ListForApi = (start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> >
50 export type ListUserVideosForApi = (userId: number, start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> >
60862425 51 export type SearchAndPopulateAccountAndServerAndTags = (
6fcd19ba 52 value: string,
6fcd19ba
C
53 start: number,
54 count: number,
55 sort: string
e4f97bab 56 ) => Bluebird< ResultList<VideoInstance> >
6fcd19ba 57
e4f97bab
C
58 export type Load = (id: number) => Bluebird<VideoInstance>
59 export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
d7d5611c 60 export type LoadByUrlAndPopulateAccount = (url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
60862425
C
61 export type LoadAndPopulateAccountAndServerAndTags = (id: number) => Bluebird<VideoInstance>
62 export type LoadByUUIDAndPopulateAccountAndServerAndTags = (uuid: string) => Bluebird<VideoInstance>
0d0e8dd0 63 export type LoadByUUIDOrURL = (uuid: string, url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance>
93e1258c
C
64
65 export type RemoveThumbnail = (this: VideoInstance) => Promise<void>
66 export type RemovePreview = (this: VideoInstance) => Promise<void>
67 export type RemoveFile = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
68 export type RemoveTorrent = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
e02643f3
C
69}
70
71export interface VideoClass {
e02643f3 72 list: VideoMethods.List
e71bcc0f 73 listAllAndSharedByAccountForOutbox: VideoMethods.ListAllAndSharedByAccountForOutbox
e02643f3 74 listForApi: VideoMethods.ListForApi
fd45e8f4 75 listUserVideosForApi: VideoMethods.ListUserVideosForApi
e02643f3 76 load: VideoMethods.Load
60862425 77 loadAndPopulateAccountAndServerAndTags: VideoMethods.LoadAndPopulateAccountAndServerAndTags
93e1258c 78 loadByUUID: VideoMethods.LoadByUUID
d7d5611c 79 loadByUrlAndPopulateAccount: VideoMethods.LoadByUrlAndPopulateAccount
0d0e8dd0 80 loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL
60862425
C
81 loadByUUIDAndPopulateAccountAndServerAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndServerAndTags
82 searchAndPopulateAccountAndServerAndTags: VideoMethods.SearchAndPopulateAccountAndServerAndTags
e02643f3
C
83}
84
85export interface VideoAttributes {
556ddc31 86 id?: number
0a6658fd 87 uuid?: string
e02643f3 88 name: string
e02643f3
C
89 category: number
90 licence: number
91 language: number
92 nsfw: boolean
93 description: string
e02643f3 94 duration: number
fd45e8f4 95 privacy: number
e02643f3
C
96 views?: number
97 likes?: number
98 dislikes?: number
0a6658fd 99 remote: boolean
0d0e8dd0
C
100 url?: string
101
102 createdAt?: Date
103 updatedAt?: Date
69818c93 104
e4f97bab 105 parentId?: number
72c7248b
C
106 channelId?: number
107
108 VideoChannel?: VideoChannelInstance
6fcd19ba 109 Tags?: TagInstance[]
93e1258c 110 VideoFiles?: VideoFileInstance[]
40ff5707 111 VideoShares?: VideoShareInstance[]
16b90975 112 AccountVideoRates?: AccountVideoRateInstance[]
e02643f3
C
113}
114
115export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
93e1258c
C
116 createPreview: VideoMethods.CreatePreview
117 createThumbnail: VideoMethods.CreateThumbnail
118 createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash
40298b02 119 getOriginalFile: VideoMethods.GetOriginalFile
154898b0 120 getPreviewName: VideoMethods.GetPreviewName
d8755eed 121 getPreviewPath: VideoMethods.GetPreviewPath
93e1258c 122 getThumbnailName: VideoMethods.GetThumbnailName
d8755eed 123 getThumbnailPath: VideoMethods.GetThumbnailPath
93e1258c
C
124 getTorrentFileName: VideoMethods.GetTorrentFileName
125 getVideoFilename: VideoMethods.GetVideoFilename
126 getVideoFilePath: VideoMethods.GetVideoFilePath
154898b0 127 isOwned: VideoMethods.IsOwned
93e1258c
C
128 removeFile: VideoMethods.RemoveFile
129 removePreview: VideoMethods.RemovePreview
130 removeThumbnail: VideoMethods.RemoveThumbnail
131 removeTorrent: VideoMethods.RemoveTorrent
e4f97bab 132 toActivityPubObject: VideoMethods.ToActivityPubObject
0aef76c4 133 toFormattedJSON: VideoMethods.ToFormattedJSON
72c7248b 134 toFormattedDetailsJSON: VideoMethods.ToFormattedDetailsJSON
40298b02
C
135 optimizeOriginalVideofile: VideoMethods.OptimizeOriginalVideofile
136 transcodeOriginalVideofile: VideoMethods.TranscodeOriginalVideofile
137 getOriginalFileHeight: VideoMethods.GetOriginalFileHeight
d8755eed 138 getEmbedPath: VideoMethods.GetEmbedPath
9567011b 139 getDescriptionPath: VideoMethods.GetDescriptionPath
2de96f4d 140 getTruncatedDescription: VideoMethods.GetTruncatedDescription
e4f97bab
C
141 getCategoryLabel: VideoMethods.GetCategoryLabel
142 getLicenceLabel: VideoMethods.GetLicenceLabel
143 getLanguageLabel: VideoMethods.GetLanguageLabel
6fcd19ba
C
144
145 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string>
40298b02 146 addVideoFile: Sequelize.HasManyAddAssociationMixin<VideoFileAttributes, string>
93e1258c 147 setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string>
e02643f3
C
148}
149
150export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}