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