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