]>
Commit | Line | Data |
---|---|---|
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 { ResultList } from '../../../shared/models/result-list.model' | |
11 | ||
12 | export type FormattedRemoteVideoFile = { | |
13 | infoHash: string | |
14 | resolution: number | |
15 | extname: string | |
16 | size: number | |
17 | } | |
18 | ||
19 | export type FormattedAddRemoteVideo = { | |
20 | uuid: string | |
21 | name: string | |
22 | category: number | |
23 | licence: number | |
24 | language: number | |
25 | nsfw: boolean | |
26 | description: string | |
27 | author: string | |
28 | duration: number | |
29 | thumbnailData: string | |
30 | tags: string[] | |
31 | createdAt: Date | |
32 | updatedAt: Date | |
33 | views: number | |
34 | likes: number | |
35 | dislikes: number | |
36 | files: FormattedRemoteVideoFile[] | |
37 | } | |
38 | ||
39 | export type FormattedUpdateRemoteVideo = { | |
40 | uuid: string | |
41 | name: string | |
42 | category: number | |
43 | licence: number | |
44 | language: number | |
45 | nsfw: boolean | |
46 | description: string | |
47 | author: string | |
48 | duration: number | |
49 | tags: string[] | |
50 | createdAt: Date | |
51 | updatedAt: Date | |
52 | views: number | |
53 | likes: number | |
54 | dislikes: number | |
55 | files: FormattedRemoteVideoFile[] | |
56 | } | |
57 | ||
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 | |
63 | ||
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 | ||
72 | export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormattedAddRemoteVideo> | |
73 | export type ToUpdateRemoteJSON = (this: VideoInstance) => FormattedUpdateRemoteVideo | |
74 | ||
75 | export type TranscodeVideofile = (this: VideoInstance, inputVideoFile: VideoFileInstance) => Promise<void> | |
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 | ||
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> | |
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> | |
105 | } | |
106 | ||
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 | |
121 | } | |
122 | ||
123 | export interface VideoAttributes { | |
124 | id?: number | |
125 | uuid?: string | |
126 | name: string | |
127 | category: number | |
128 | licence: number | |
129 | language: number | |
130 | nsfw: boolean | |
131 | description: string | |
132 | duration: number | |
133 | views?: number | |
134 | likes?: number | |
135 | dislikes?: number | |
136 | remote: boolean | |
137 | ||
138 | Author?: AuthorInstance | |
139 | Tags?: TagInstance[] | |
140 | VideoFiles?: VideoFileInstance[] | |
141 | } | |
142 | ||
143 | export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { | |
144 | createdAt: Date | |
145 | updatedAt: Date | |
146 | ||
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 | |
165 | ||
166 | setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string> | |
167 | setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string> | |
168 | } | |
169 | ||
170 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} |