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'
7 // Don't use barrel, import just what we need
8 import { Video as FormatedVideo } from '../../../shared/models/video.model'
9 import { ResultList } from '../../../shared/models/result-list.model'
11 export type FormatedAddRemoteVideo = {
32 export type FormatedUpdateRemoteVideo = {
52 export namespace VideoMethods {
53 export type GenerateMagnetUri = (this: VideoInstance) => string
54 export type GetVideoFilename = (this: VideoInstance) => string
55 export type GetThumbnailName = (this: VideoInstance) => string
56 export type GetPreviewName = (this: VideoInstance) => string
57 export type GetTorrentName = (this: VideoInstance) => string
58 export type IsOwned = (this: VideoInstance) => boolean
59 export type ToFormatedJSON = (this: VideoInstance) => FormatedVideo
61 export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormatedAddRemoteVideo>
62 export type ToUpdateRemoteJSON = (this: VideoInstance) => FormatedUpdateRemoteVideo
64 export type TranscodeVideofile = (this: VideoInstance) => Promise<void>
66 // Return thumbnail name
67 export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string>
68 export type GetDurationFromFile = (videoPath: string) => Promise<number>
70 export type List = () => Promise<VideoInstance[]>
71 export type ListOwnedAndPopulateAuthorAndTags = () => Promise<VideoInstance[]>
72 export type ListOwnedByAuthor = (author: string) => Promise<VideoInstance[]>
74 export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoInstance> >
75 export type SearchAndPopulateAuthorAndPodAndTags = (
81 ) => Promise< ResultList<VideoInstance> >
83 export type Load = (id: string) => Promise<VideoInstance>
84 export type LoadByHostAndRemoteId = (fromHost: string, remoteId: string) => Promise<VideoInstance>
85 export type LoadAndPopulateAuthor = (id: string) => Promise<VideoInstance>
86 export type LoadAndPopulateAuthorAndPodAndTags = (id: string) => Promise<VideoInstance>
89 export interface VideoClass {
90 generateMagnetUri: VideoMethods.GenerateMagnetUri
91 getVideoFilename: VideoMethods.GetVideoFilename
92 getThumbnailName: VideoMethods.GetThumbnailName
93 getPreviewName: VideoMethods.GetPreviewName
94 getTorrentName: VideoMethods.GetTorrentName
95 isOwned: VideoMethods.IsOwned
96 toFormatedJSON: VideoMethods.ToFormatedJSON
97 toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
98 toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
99 transcodeVideofile: VideoMethods.TranscodeVideofile
101 generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData
102 getDurationFromFile: VideoMethods.GetDurationFromFile
103 list: VideoMethods.List
104 listForApi: VideoMethods.ListForApi
105 loadByHostAndRemoteId: VideoMethods.LoadByHostAndRemoteId
106 listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags
107 listOwnedByAuthor: VideoMethods.ListOwnedByAuthor
108 load: VideoMethods.Load
109 loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor
110 loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags
111 searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags
114 export interface VideoAttributes {
129 Author?: AuthorInstance
133 export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
138 generateMagnetUri: VideoMethods.GenerateMagnetUri
139 getVideoFilename: VideoMethods.GetVideoFilename
140 getThumbnailName: VideoMethods.GetThumbnailName
141 getPreviewName: VideoMethods.GetPreviewName
142 getTorrentName: VideoMethods.GetTorrentName
143 isOwned: VideoMethods.IsOwned
144 toFormatedJSON: VideoMethods.ToFormatedJSON
145 toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
146 toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
147 transcodeVideofile: VideoMethods.TranscodeVideofile
149 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string>
152 export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}