]>
Commit | Line | Data |
---|---|---|
1 | import * as Sequelize from 'sequelize' | |
2 | import * as Promise from 'bluebird' | |
3 | ||
4 | import { TagAttributes, TagInstance } from './tag-interface' | |
5 | import { VideoFileAttributes, VideoFileInstance } from './video-file-interface' | |
6 | ||
7 | // Don't use barrel, import just what we need | |
8 | import { | |
9 | Video as FormattedVideo, | |
10 | VideoDetails as FormattedDetailsVideo | |
11 | } from '../../../shared/models/videos/video.model' | |
12 | import { RemoteVideoUpdateData } from '../../../shared/models/pods/remote-video/remote-video-update-request.model' | |
13 | import { RemoteVideoCreateData } from '../../../shared/models/pods/remote-video/remote-video-create-request.model' | |
14 | import { ResultList } from '../../../shared/models/result-list.model' | |
15 | import { VideoChannelInstance } from './video-channel-interface' | |
16 | ||
17 | export namespace VideoMethods { | |
18 | export type GetThumbnailName = (this: VideoInstance) => string | |
19 | export type GetPreviewName = (this: VideoInstance) => string | |
20 | export type IsOwned = (this: VideoInstance) => boolean | |
21 | export type ToFormattedJSON = (this: VideoInstance) => FormattedVideo | |
22 | export type ToFormattedDetailsJSON = (this: VideoInstance) => FormattedDetailsVideo | |
23 | ||
24 | export type GetOriginalFile = (this: VideoInstance) => VideoFileInstance | |
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 | ||
32 | export type ToAddRemoteJSON = (this: VideoInstance) => Promise<RemoteVideoCreateData> | |
33 | export type ToUpdateRemoteJSON = (this: VideoInstance) => RemoteVideoUpdateData | |
34 | ||
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> | |
38 | export type GetEmbedPath = (this: VideoInstance) => string | |
39 | export type GetThumbnailPath = (this: VideoInstance) => string | |
40 | export type GetPreviewPath = (this: VideoInstance) => string | |
41 | export type GetDescriptionPath = (this: VideoInstance) => string | |
42 | export type GetTruncatedDescription = (this: VideoInstance) => string | |
43 | ||
44 | // Return thumbnail name | |
45 | export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string> | |
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 ListUserVideosForApi = (userId: number, start: number, count: number, sort: string) => Promise< ResultList<VideoInstance> > | |
53 | export type SearchAndPopulateAuthorAndPodAndTags = ( | |
54 | value: string, | |
55 | field: string, | |
56 | start: number, | |
57 | count: number, | |
58 | sort: string | |
59 | ) => Promise< ResultList<VideoInstance> > | |
60 | ||
61 | export type Load = (id: number) => Promise<VideoInstance> | |
62 | export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoInstance> | |
63 | export type LoadLocalVideoByUUID = (uuid: string, t?: Sequelize.Transaction) => Promise<VideoInstance> | |
64 | export type LoadByHostAndUUID = (fromHost: string, uuid: string, t?: Sequelize.Transaction) => Promise<VideoInstance> | |
65 | export type LoadAndPopulateAuthor = (id: number) => Promise<VideoInstance> | |
66 | export type LoadAndPopulateAuthorAndPodAndTags = (id: number) => Promise<VideoInstance> | |
67 | export type LoadByUUIDAndPopulateAuthorAndPodAndTags = (uuid: string) => Promise<VideoInstance> | |
68 | ||
69 | export type RemoveThumbnail = (this: VideoInstance) => Promise<void> | |
70 | export type RemovePreview = (this: VideoInstance) => Promise<void> | |
71 | export type RemoveFile = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void> | |
72 | export type RemoveTorrent = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void> | |
73 | } | |
74 | ||
75 | export interface VideoClass { | |
76 | generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData | |
77 | list: VideoMethods.List | |
78 | listForApi: VideoMethods.ListForApi | |
79 | listUserVideosForApi: VideoMethods.ListUserVideosForApi | |
80 | listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags | |
81 | listOwnedByAuthor: VideoMethods.ListOwnedByAuthor | |
82 | load: VideoMethods.Load | |
83 | loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor | |
84 | loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags | |
85 | loadByHostAndUUID: VideoMethods.LoadByHostAndUUID | |
86 | loadByUUID: VideoMethods.LoadByUUID | |
87 | loadLocalVideoByUUID: VideoMethods.LoadLocalVideoByUUID | |
88 | loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags | |
89 | searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags | |
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 | ||
108 | channelId?: number | |
109 | ||
110 | VideoChannel?: VideoChannelInstance | |
111 | Tags?: TagInstance[] | |
112 | VideoFiles?: VideoFileInstance[] | |
113 | } | |
114 | ||
115 | export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { | |
116 | createdAt: Date | |
117 | updatedAt: Date | |
118 | ||
119 | createPreview: VideoMethods.CreatePreview | |
120 | createThumbnail: VideoMethods.CreateThumbnail | |
121 | createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash | |
122 | getOriginalFile: VideoMethods.GetOriginalFile | |
123 | getPreviewName: VideoMethods.GetPreviewName | |
124 | getPreviewPath: VideoMethods.GetPreviewPath | |
125 | getThumbnailName: VideoMethods.GetThumbnailName | |
126 | getThumbnailPath: VideoMethods.GetThumbnailPath | |
127 | getTorrentFileName: VideoMethods.GetTorrentFileName | |
128 | getVideoFilename: VideoMethods.GetVideoFilename | |
129 | getVideoFilePath: VideoMethods.GetVideoFilePath | |
130 | isOwned: VideoMethods.IsOwned | |
131 | removeFile: VideoMethods.RemoveFile | |
132 | removePreview: VideoMethods.RemovePreview | |
133 | removeThumbnail: VideoMethods.RemoveThumbnail | |
134 | removeTorrent: VideoMethods.RemoveTorrent | |
135 | toAddRemoteJSON: VideoMethods.ToAddRemoteJSON | |
136 | toFormattedJSON: VideoMethods.ToFormattedJSON | |
137 | toFormattedDetailsJSON: VideoMethods.ToFormattedDetailsJSON | |
138 | toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON | |
139 | optimizeOriginalVideofile: VideoMethods.OptimizeOriginalVideofile | |
140 | transcodeOriginalVideofile: VideoMethods.TranscodeOriginalVideofile | |
141 | getOriginalFileHeight: VideoMethods.GetOriginalFileHeight | |
142 | getEmbedPath: VideoMethods.GetEmbedPath | |
143 | getDescriptionPath: VideoMethods.GetDescriptionPath | |
144 | getTruncatedDescription: VideoMethods.GetTruncatedDescription | |
145 | ||
146 | setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string> | |
147 | addVideoFile: Sequelize.HasManyAddAssociationMixin<VideoFileAttributes, string> | |
148 | setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string> | |
149 | } | |
150 | ||
151 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} |