1 import * as Sequelize from 'sequelize'
2 import * as Promise from 'bluebird'
4 import { AuthorInstance } from './author-interface'
5 import { TagAttributes, TagInstance } from './tag-interface'
6 import { VideoFileAttributes, VideoFileInstance } from './video-file-interface'
8 // Don't use barrel, import just what we need
9 import { Video as FormattedVideo } from '../../../shared/models/videos/video.model'
10 import { ResultList } from '../../../shared/models/result-list.model'
12 export type FormattedRemoteVideoFile = {
19 export type FormattedAddRemoteVideo = {
36 files: FormattedRemoteVideoFile[]
39 export type FormattedUpdateRemoteVideo = {
55 files: FormattedRemoteVideoFile[]
58 export namespace VideoMethods {
59 export type GetThumbnailName = (this: VideoInstance) => string
60 export type GetPreviewName = (this: VideoInstance) => string
61 export type IsOwned = (this: VideoInstance) => boolean
62 export type ToFormattedJSON = (this: VideoInstance) => FormattedVideo
64 export type GenerateMagnetUri = (this: VideoInstance, videoFile: VideoFileInstance) => string
65 export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string
66 export type GetVideoFilename = (this: VideoInstance, videoFile: VideoFileInstance) => string
67 export type CreatePreview = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
68 export type CreateThumbnail = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
69 export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string
70 export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
72 export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormattedAddRemoteVideo>
73 export type ToUpdateRemoteJSON = (this: VideoInstance) => FormattedUpdateRemoteVideo
75 export type TranscodeVideofile = (this: VideoInstance, inputVideoFile: VideoFileInstance) => Promise<void>
77 // Return thumbnail name
78 export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string>
79 export type GetDurationFromFile = (videoPath: string) => Promise<number>
81 export type List = () => Promise<VideoInstance[]>
82 export type ListOwnedAndPopulateAuthorAndTags = () => Promise<VideoInstance[]>
83 export type ListOwnedByAuthor = (author: string) => Promise<VideoInstance[]>
85 export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoInstance> >
86 export type SearchAndPopulateAuthorAndPodAndTags = (
92 ) => Promise< ResultList<VideoInstance> >
94 export type Load = (id: number) => Promise<VideoInstance>
95 export type LoadByUUID = (uuid: string) => Promise<VideoInstance>
96 export type LoadByHostAndUUID = (fromHost: string, uuid: string) => Promise<VideoInstance>
97 export type LoadAndPopulateAuthor = (id: number) => Promise<VideoInstance>
98 export type LoadAndPopulateAuthorAndPodAndTags = (id: number) => Promise<VideoInstance>
99 export type LoadByUUIDAndPopulateAuthorAndPodAndTags = (uuid: string) => Promise<VideoInstance>
101 export type RemoveThumbnail = (this: VideoInstance) => Promise<void>
102 export type RemovePreview = (this: VideoInstance) => Promise<void>
103 export type RemoveFile = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
104 export type RemoveTorrent = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
107 export interface VideoClass {
108 generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData
109 getDurationFromFile: VideoMethods.GetDurationFromFile
110 list: VideoMethods.List
111 listForApi: VideoMethods.ListForApi
112 listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags
113 listOwnedByAuthor: VideoMethods.ListOwnedByAuthor
114 load: VideoMethods.Load
115 loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor
116 loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags
117 loadByHostAndUUID: VideoMethods.LoadByHostAndUUID
118 loadByUUID: VideoMethods.LoadByUUID
119 loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags
120 searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags
123 export interface VideoAttributes {
138 Author?: AuthorInstance
140 VideoFiles?: VideoFileInstance[]
143 export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
147 createPreview: VideoMethods.CreatePreview
148 createThumbnail: VideoMethods.CreateThumbnail
149 createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash
150 generateMagnetUri: VideoMethods.GenerateMagnetUri
151 getPreviewName: VideoMethods.GetPreviewName
152 getThumbnailName: VideoMethods.GetThumbnailName
153 getTorrentFileName: VideoMethods.GetTorrentFileName
154 getVideoFilename: VideoMethods.GetVideoFilename
155 getVideoFilePath: VideoMethods.GetVideoFilePath
156 isOwned: VideoMethods.IsOwned
157 removeFile: VideoMethods.RemoveFile
158 removePreview: VideoMethods.RemovePreview
159 removeThumbnail: VideoMethods.RemoveThumbnail
160 removeTorrent: VideoMethods.RemoveTorrent
161 toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
162 toFormattedJSON: VideoMethods.ToFormattedJSON
163 toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
164 transcodeVideofile: VideoMethods.TranscodeVideofile
166 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string>
167 setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string>
170 export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}