]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/models/video/video-interface.ts
Lazy description and previews to video form
[github/Chocobozzz/PeerTube.git] / server / models / video / video-interface.ts
CommitLineData
e02643f3 1import * as Sequelize from 'sequelize'
6fcd19ba 2import * as Promise 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'
69818c93 16
e02643f3 17export namespace VideoMethods {
70c065d6
C
18 export type GetThumbnailName = (this: VideoInstance) => string
19 export type GetPreviewName = (this: VideoInstance) => string
70c065d6 20 export type IsOwned = (this: VideoInstance) => boolean
0aef76c4 21 export type ToFormattedJSON = (this: VideoInstance) => FormattedVideo
72c7248b 22 export type ToFormattedDetailsJSON = (this: VideoInstance) => FormattedDetailsVideo
69818c93 23
40298b02 24 export type GetOriginalFile = (this: VideoInstance) => VideoFileInstance
93e1258c
C
25 export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string
26 export type GetVideoFilename = (this: VideoInstance, videoFile: VideoFileInstance) => string
27 export type CreatePreview = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
28 export type CreateThumbnail = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
29 export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string
30 export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
31
40298b02
C
32 export type ToAddRemoteJSON = (this: VideoInstance) => Promise<RemoteVideoCreateData>
33 export type ToUpdateRemoteJSON = (this: VideoInstance) => RemoteVideoUpdateData
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
6fcd19ba
C
43
44 // Return thumbnail name
45 export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string>
6fcd19ba
C
46
47 export type List = () => Promise<VideoInstance[]>
48 export type ListOwnedAndPopulateAuthorAndTags = () => Promise<VideoInstance[]>
49 export type ListOwnedByAuthor = (author: string) => Promise<VideoInstance[]>
50
51 export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoInstance> >
52 export type SearchAndPopulateAuthorAndPodAndTags = (
53 value: string,
54 field: string,
55 start: number,
56 count: number,
57 sort: string
58 ) => Promise< ResultList<VideoInstance> >
59
0a6658fd 60 export type Load = (id: number) => Promise<VideoInstance>
72c7248b 61 export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoInstance>
a041b171 62 export type LoadLocalVideoByUUID = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoInstance>
72c7248b 63 export type LoadByHostAndUUID = (fromHost: string, uuid: string, t?: Sequelize.Transaction) => Promise<VideoInstance>
0a6658fd
C
64 export type LoadAndPopulateAuthor = (id: number) => Promise<VideoInstance>
65 export type LoadAndPopulateAuthorAndPodAndTags = (id: number) => Promise<VideoInstance>
66 export type LoadByUUIDAndPopulateAuthorAndPodAndTags = (uuid: string) => Promise<VideoInstance>
93e1258c
C
67
68 export type RemoveThumbnail = (this: VideoInstance) => Promise<void>
69 export type RemovePreview = (this: VideoInstance) => Promise<void>
70 export type RemoveFile = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
71 export type RemoveTorrent = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
e02643f3
C
72}
73
74export interface VideoClass {
e02643f3 75 generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData
e02643f3
C
76 list: VideoMethods.List
77 listForApi: VideoMethods.ListForApi
e02643f3
C
78 listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags
79 listOwnedByAuthor: VideoMethods.ListOwnedByAuthor
80 load: VideoMethods.Load
81 loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor
82 loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags
93e1258c
C
83 loadByHostAndUUID: VideoMethods.LoadByHostAndUUID
84 loadByUUID: VideoMethods.LoadByUUID
a041b171 85 loadLocalVideoByUUID: VideoMethods.LoadLocalVideoByUUID
0a6658fd 86 loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags
e02643f3
C
87 searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags
88}
89
90export interface VideoAttributes {
556ddc31 91 id?: number
0a6658fd 92 uuid?: string
e02643f3 93 name: string
e02643f3
C
94 category: number
95 licence: number
96 language: number
97 nsfw: boolean
98 description: string
e02643f3
C
99 duration: number
100 views?: number
101 likes?: number
102 dislikes?: number
0a6658fd 103 remote: boolean
69818c93 104
72c7248b
C
105 channelId?: number
106
107 VideoChannel?: VideoChannelInstance
6fcd19ba 108 Tags?: TagInstance[]
93e1258c 109 VideoFiles?: VideoFileInstance[]
e02643f3
C
110}
111
112export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
e02643f3
C
113 createdAt: Date
114 updatedAt: Date
154898b0 115
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
154898b0 132 toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
0aef76c4 133 toFormattedJSON: VideoMethods.ToFormattedJSON
72c7248b 134 toFormattedDetailsJSON: VideoMethods.ToFormattedDetailsJSON
154898b0 135 toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
40298b02
C
136 optimizeOriginalVideofile: VideoMethods.OptimizeOriginalVideofile
137 transcodeOriginalVideofile: VideoMethods.TranscodeOriginalVideofile
138 getOriginalFileHeight: VideoMethods.GetOriginalFileHeight
d8755eed 139 getEmbedPath: VideoMethods.GetEmbedPath
9567011b 140 getDescriptionPath: VideoMethods.GetDescriptionPath
2de96f4d 141 getTruncatedDescription: VideoMethods.GetTruncatedDescription
6fcd19ba
C
142
143 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string>
40298b02 144 addVideoFile: Sequelize.HasManyAddAssociationMixin<VideoFileAttributes, string>
93e1258c 145 setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string>
e02643f3
C
146}
147
148export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}