]>
Commit | Line | Data |
---|---|---|
e02643f3 | 1 | import * as Sequelize from 'sequelize' |
6fcd19ba | 2 | import * as Promise from 'bluebird' |
e02643f3 | 3 | |
69818c93 | 4 | import { AuthorInstance } from './author-interface' |
6fcd19ba | 5 | import { TagAttributes, TagInstance } from './tag-interface' |
93e1258c | 6 | import { VideoFileAttributes, VideoFileInstance } from './video-file-interface' |
69818c93 C |
7 | |
8 | // Don't use barrel, import just what we need | |
0aef76c4 | 9 | import { Video as FormattedVideo } from '../../../shared/models/videos/video.model' |
6fcd19ba | 10 | import { ResultList } from '../../../shared/models/result-list.model' |
69818c93 | 11 | |
0aef76c4 | 12 | export type FormattedRemoteVideoFile = { |
93e1258c C |
13 | infoHash: string |
14 | resolution: number | |
15 | extname: string | |
16 | size: number | |
17 | } | |
18 | ||
0aef76c4 | 19 | export type FormattedAddRemoteVideo = { |
0a6658fd | 20 | uuid: string |
69818c93 C |
21 | name: string |
22 | category: number | |
23 | licence: number | |
24 | language: number | |
25 | nsfw: boolean | |
26 | description: string | |
69818c93 C |
27 | author: string |
28 | duration: number | |
29 | thumbnailData: string | |
30 | tags: string[] | |
31 | createdAt: Date | |
32 | updatedAt: Date | |
69818c93 C |
33 | views: number |
34 | likes: number | |
35 | dislikes: number | |
0aef76c4 | 36 | files: FormattedRemoteVideoFile[] |
69818c93 C |
37 | } |
38 | ||
0aef76c4 | 39 | export type FormattedUpdateRemoteVideo = { |
0a6658fd | 40 | uuid: string |
69818c93 C |
41 | name: string |
42 | category: number | |
43 | licence: number | |
44 | language: number | |
45 | nsfw: boolean | |
46 | description: string | |
69818c93 C |
47 | author: string |
48 | duration: number | |
49 | tags: string[] | |
50 | createdAt: Date | |
51 | updatedAt: Date | |
69818c93 C |
52 | views: number |
53 | likes: number | |
54 | dislikes: number | |
0aef76c4 | 55 | files: FormattedRemoteVideoFile[] |
69818c93 C |
56 | } |
57 | ||
e02643f3 | 58 | export namespace VideoMethods { |
70c065d6 C |
59 | export type GetThumbnailName = (this: VideoInstance) => string |
60 | export type GetPreviewName = (this: VideoInstance) => string | |
70c065d6 | 61 | export type IsOwned = (this: VideoInstance) => boolean |
0aef76c4 | 62 | export type ToFormattedJSON = (this: VideoInstance) => FormattedVideo |
69818c93 | 63 | |
93e1258c C |
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> | |
71 | ||
0aef76c4 C |
72 | export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormattedAddRemoteVideo> |
73 | export type ToUpdateRemoteJSON = (this: VideoInstance) => FormattedUpdateRemoteVideo | |
69818c93 | 74 | |
93e1258c | 75 | export type TranscodeVideofile = (this: VideoInstance, inputVideoFile: VideoFileInstance) => Promise<void> |
6fcd19ba C |
76 | |
77 | // Return thumbnail name | |
78 | export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string> | |
79 | export type GetDurationFromFile = (videoPath: string) => Promise<number> | |
80 | ||
81 | export type List = () => Promise<VideoInstance[]> | |
82 | export type ListOwnedAndPopulateAuthorAndTags = () => Promise<VideoInstance[]> | |
83 | export type ListOwnedByAuthor = (author: string) => Promise<VideoInstance[]> | |
84 | ||
85 | export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoInstance> > | |
86 | export type SearchAndPopulateAuthorAndPodAndTags = ( | |
87 | value: string, | |
88 | field: string, | |
89 | start: number, | |
90 | count: number, | |
91 | sort: string | |
92 | ) => Promise< ResultList<VideoInstance> > | |
93 | ||
0a6658fd C |
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> | |
93e1258c C |
100 | |
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> | |
e02643f3 C |
105 | } |
106 | ||
107 | export interface VideoClass { | |
e02643f3 C |
108 | generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData |
109 | getDurationFromFile: VideoMethods.GetDurationFromFile | |
110 | list: VideoMethods.List | |
111 | listForApi: VideoMethods.ListForApi | |
e02643f3 C |
112 | listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags |
113 | listOwnedByAuthor: VideoMethods.ListOwnedByAuthor | |
114 | load: VideoMethods.Load | |
115 | loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor | |
116 | loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags | |
93e1258c C |
117 | loadByHostAndUUID: VideoMethods.LoadByHostAndUUID |
118 | loadByUUID: VideoMethods.LoadByUUID | |
0a6658fd | 119 | loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags |
e02643f3 C |
120 | searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags |
121 | } | |
122 | ||
123 | export interface VideoAttributes { | |
556ddc31 | 124 | id?: number |
0a6658fd | 125 | uuid?: string |
e02643f3 | 126 | name: string |
e02643f3 C |
127 | category: number |
128 | licence: number | |
129 | language: number | |
130 | nsfw: boolean | |
131 | description: string | |
e02643f3 C |
132 | duration: number |
133 | views?: number | |
134 | likes?: number | |
135 | dislikes?: number | |
0a6658fd | 136 | remote: boolean |
69818c93 C |
137 | |
138 | Author?: AuthorInstance | |
6fcd19ba | 139 | Tags?: TagInstance[] |
93e1258c | 140 | VideoFiles?: VideoFileInstance[] |
e02643f3 C |
141 | } |
142 | ||
143 | export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { | |
e02643f3 C |
144 | createdAt: Date |
145 | updatedAt: Date | |
154898b0 | 146 | |
93e1258c C |
147 | createPreview: VideoMethods.CreatePreview |
148 | createThumbnail: VideoMethods.CreateThumbnail | |
149 | createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash | |
154898b0 | 150 | generateMagnetUri: VideoMethods.GenerateMagnetUri |
154898b0 | 151 | getPreviewName: VideoMethods.GetPreviewName |
93e1258c C |
152 | getThumbnailName: VideoMethods.GetThumbnailName |
153 | getTorrentFileName: VideoMethods.GetTorrentFileName | |
154 | getVideoFilename: VideoMethods.GetVideoFilename | |
155 | getVideoFilePath: VideoMethods.GetVideoFilePath | |
154898b0 | 156 | isOwned: VideoMethods.IsOwned |
93e1258c C |
157 | removeFile: VideoMethods.RemoveFile |
158 | removePreview: VideoMethods.RemovePreview | |
159 | removeThumbnail: VideoMethods.RemoveThumbnail | |
160 | removeTorrent: VideoMethods.RemoveTorrent | |
154898b0 | 161 | toAddRemoteJSON: VideoMethods.ToAddRemoteJSON |
0aef76c4 | 162 | toFormattedJSON: VideoMethods.ToFormattedJSON |
154898b0 C |
163 | toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON |
164 | transcodeVideofile: VideoMethods.TranscodeVideofile | |
6fcd19ba C |
165 | |
166 | setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string> | |
93e1258c | 167 | setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string> |
e02643f3 C |
168 | } |
169 | ||
170 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} |