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