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