]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/video/video-interface.ts
Add oembed endpoint
[github/Chocobozzz/PeerTube.git] / server / models / video / video-interface.ts
1 import * as Sequelize from 'sequelize'
2 import * as Promise from 'bluebird'
3
4 import { AuthorInstance } from './author-interface'
5 import { TagAttributes, TagInstance } from './tag-interface'
6 import { VideoFileAttributes, VideoFileInstance } from './video-file-interface'
7
8 // Don't use barrel, import just what we need
9 import { Video as FormattedVideo } from '../../../shared/models/videos/video.model'
10 import { RemoteVideoUpdateData } from '../../../shared/models/pods/remote-video/remote-video-update-request.model'
11 import { RemoteVideoCreateData } from '../../../shared/models/pods/remote-video/remote-video-create-request.model'
12 import { ResultList } from '../../../shared/models/result-list.model'
13
14 export namespace VideoMethods {
15 export type GetThumbnailName = (this: VideoInstance) => string
16 export type GetPreviewName = (this: VideoInstance) => string
17 export type IsOwned = (this: VideoInstance) => boolean
18 export type ToFormattedJSON = (this: VideoInstance) => FormattedVideo
19
20 export type GetOriginalFile = (this: VideoInstance) => VideoFileInstance
21 export type GenerateMagnetUri = (this: VideoInstance, videoFile: VideoFileInstance) => string
22 export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string
23 export type GetVideoFilename = (this: VideoInstance, videoFile: VideoFileInstance) => string
24 export type CreatePreview = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
25 export type CreateThumbnail = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
26 export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string
27 export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
28
29 export type ToAddRemoteJSON = (this: VideoInstance) => Promise<RemoteVideoCreateData>
30 export type ToUpdateRemoteJSON = (this: VideoInstance) => RemoteVideoUpdateData
31
32 export type OptimizeOriginalVideofile = (this: VideoInstance) => Promise<void>
33 export type TranscodeOriginalVideofile = (this: VideoInstance, resolution: number) => Promise<void>
34 export type GetOriginalFileHeight = (this: VideoInstance) => Promise<number>
35 export type GetEmbedPath = (this: VideoInstance) => string
36 export type GetThumbnailPath = (this: VideoInstance) => string
37 export type GetPreviewPath = (this: VideoInstance) => string
38
39 // Return thumbnail name
40 export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string>
41
42 export type List = () => Promise<VideoInstance[]>
43 export type ListOwnedAndPopulateAuthorAndTags = () => Promise<VideoInstance[]>
44 export type ListOwnedByAuthor = (author: string) => Promise<VideoInstance[]>
45
46 export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoInstance> >
47 export type SearchAndPopulateAuthorAndPodAndTags = (
48 value: string,
49 field: string,
50 start: number,
51 count: number,
52 sort: string
53 ) => Promise< ResultList<VideoInstance> >
54
55 export type Load = (id: number) => Promise<VideoInstance>
56 export type LoadByUUID = (uuid: string) => Promise<VideoInstance>
57 export type LoadByHostAndUUID = (fromHost: string, uuid: string) => Promise<VideoInstance>
58 export type LoadAndPopulateAuthor = (id: number) => Promise<VideoInstance>
59 export type LoadAndPopulateAuthorAndPodAndTags = (id: number) => Promise<VideoInstance>
60 export type LoadByUUIDAndPopulateAuthorAndPodAndTags = (uuid: string) => Promise<VideoInstance>
61
62 export type RemoveThumbnail = (this: VideoInstance) => Promise<void>
63 export type RemovePreview = (this: VideoInstance) => Promise<void>
64 export type RemoveFile = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
65 export type RemoveTorrent = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
66 }
67
68 export interface VideoClass {
69 generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData
70 list: VideoMethods.List
71 listForApi: VideoMethods.ListForApi
72 listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags
73 listOwnedByAuthor: VideoMethods.ListOwnedByAuthor
74 load: VideoMethods.Load
75 loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor
76 loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags
77 loadByHostAndUUID: VideoMethods.LoadByHostAndUUID
78 loadByUUID: VideoMethods.LoadByUUID
79 loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags
80 searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags
81 }
82
83 export interface VideoAttributes {
84 id?: number
85 uuid?: string
86 name: string
87 category: number
88 licence: number
89 language: number
90 nsfw: boolean
91 description: string
92 duration: number
93 views?: number
94 likes?: number
95 dislikes?: number
96 remote: boolean
97
98 Author?: AuthorInstance
99 Tags?: TagInstance[]
100 VideoFiles?: VideoFileInstance[]
101 }
102
103 export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
104 createdAt: Date
105 updatedAt: Date
106
107 createPreview: VideoMethods.CreatePreview
108 createThumbnail: VideoMethods.CreateThumbnail
109 createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash
110 getOriginalFile: VideoMethods.GetOriginalFile
111 generateMagnetUri: VideoMethods.GenerateMagnetUri
112 getPreviewName: VideoMethods.GetPreviewName
113 getPreviewPath: VideoMethods.GetPreviewPath
114 getThumbnailName: VideoMethods.GetThumbnailName
115 getThumbnailPath: VideoMethods.GetThumbnailPath
116 getTorrentFileName: VideoMethods.GetTorrentFileName
117 getVideoFilename: VideoMethods.GetVideoFilename
118 getVideoFilePath: VideoMethods.GetVideoFilePath
119 isOwned: VideoMethods.IsOwned
120 removeFile: VideoMethods.RemoveFile
121 removePreview: VideoMethods.RemovePreview
122 removeThumbnail: VideoMethods.RemoveThumbnail
123 removeTorrent: VideoMethods.RemoveTorrent
124 toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
125 toFormattedJSON: VideoMethods.ToFormattedJSON
126 toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
127 optimizeOriginalVideofile: VideoMethods.OptimizeOriginalVideofile
128 transcodeOriginalVideofile: VideoMethods.TranscodeOriginalVideofile
129 getOriginalFileHeight: VideoMethods.GetOriginalFileHeight
130 getEmbedPath: VideoMethods.GetEmbedPath
131
132 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string>
133 addVideoFile: Sequelize.HasManyAddAssociationMixin<VideoFileAttributes, string>
134 setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string>
135 }
136
137 export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}