]>
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' |
40298b02 C |
10 | import { RemoteVideoUpdateData } from '../../../shared/models/pods/remote-video/remote-video-update-request.model' |
11 | import { RemoteVideoCreateData } from '../../../shared/models/pods/remote-video/remote-video-create-request.model' | |
6fcd19ba | 12 | import { ResultList } from '../../../shared/models/result-list.model' |
69818c93 | 13 | |
e02643f3 | 14 | export namespace VideoMethods { |
70c065d6 C |
15 | export type GetThumbnailName = (this: VideoInstance) => string |
16 | export type GetPreviewName = (this: VideoInstance) => string | |
70c065d6 | 17 | export type IsOwned = (this: VideoInstance) => boolean |
0aef76c4 | 18 | export type ToFormattedJSON = (this: VideoInstance) => FormattedVideo |
69818c93 | 19 | |
40298b02 | 20 | export type GetOriginalFile = (this: VideoInstance) => VideoFileInstance |
93e1258c C |
21 | export type GenerateMagnetUri = (this: VideoInstance, videoFile: VideoFileInstance) => string |
22 | export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string | |
23 | export type GetVideoFilename = (this: VideoInstance, videoFile: VideoFileInstance) => string | |
24 | export type CreatePreview = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string> | |
25 | export type CreateThumbnail = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string> | |
26 | export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string | |
27 | export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void> | |
28 | ||
40298b02 C |
29 | export type ToAddRemoteJSON = (this: VideoInstance) => Promise<RemoteVideoCreateData> |
30 | export type ToUpdateRemoteJSON = (this: VideoInstance) => RemoteVideoUpdateData | |
69818c93 | 31 | |
40298b02 C |
32 | export type OptimizeOriginalVideofile = (this: VideoInstance) => Promise<void> |
33 | export type TranscodeOriginalVideofile = (this: VideoInstance, resolution: number) => Promise<void> | |
34 | export type GetOriginalFileHeight = (this: VideoInstance) => Promise<number> | |
d8755eed C |
35 | export type GetEmbedPath = (this: VideoInstance) => string |
36 | export type GetThumbnailPath = (this: VideoInstance) => string | |
37 | export type GetPreviewPath = (this: VideoInstance) => string | |
6fcd19ba C |
38 | |
39 | // Return thumbnail name | |
40 | export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string> | |
6fcd19ba C |
41 | |
42 | export type List = () => Promise<VideoInstance[]> | |
43 | export type ListOwnedAndPopulateAuthorAndTags = () => Promise<VideoInstance[]> | |
44 | export type ListOwnedByAuthor = (author: string) => Promise<VideoInstance[]> | |
45 | ||
46 | export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoInstance> > | |
47 | export type SearchAndPopulateAuthorAndPodAndTags = ( | |
48 | value: string, | |
49 | field: string, | |
50 | start: number, | |
51 | count: number, | |
52 | sort: string | |
53 | ) => Promise< ResultList<VideoInstance> > | |
54 | ||
0a6658fd C |
55 | export type Load = (id: number) => Promise<VideoInstance> |
56 | export type LoadByUUID = (uuid: string) => Promise<VideoInstance> | |
57 | export type LoadByHostAndUUID = (fromHost: string, uuid: string) => Promise<VideoInstance> | |
58 | export type LoadAndPopulateAuthor = (id: number) => Promise<VideoInstance> | |
59 | export type LoadAndPopulateAuthorAndPodAndTags = (id: number) => Promise<VideoInstance> | |
60 | export type LoadByUUIDAndPopulateAuthorAndPodAndTags = (uuid: string) => Promise<VideoInstance> | |
93e1258c C |
61 | |
62 | export type RemoveThumbnail = (this: VideoInstance) => Promise<void> | |
63 | export type RemovePreview = (this: VideoInstance) => Promise<void> | |
64 | export type RemoveFile = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void> | |
65 | export type RemoveTorrent = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void> | |
e02643f3 C |
66 | } |
67 | ||
68 | export interface VideoClass { | |
e02643f3 | 69 | generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData |
e02643f3 C |
70 | list: VideoMethods.List |
71 | listForApi: VideoMethods.ListForApi | |
e02643f3 C |
72 | listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags |
73 | listOwnedByAuthor: VideoMethods.ListOwnedByAuthor | |
74 | load: VideoMethods.Load | |
75 | loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor | |
76 | loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags | |
93e1258c C |
77 | loadByHostAndUUID: VideoMethods.LoadByHostAndUUID |
78 | loadByUUID: VideoMethods.LoadByUUID | |
0a6658fd | 79 | loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags |
e02643f3 C |
80 | searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags |
81 | } | |
82 | ||
83 | export interface VideoAttributes { | |
556ddc31 | 84 | id?: number |
0a6658fd | 85 | uuid?: string |
e02643f3 | 86 | name: string |
e02643f3 C |
87 | category: number |
88 | licence: number | |
89 | language: number | |
90 | nsfw: boolean | |
91 | description: string | |
e02643f3 C |
92 | duration: number |
93 | views?: number | |
94 | likes?: number | |
95 | dislikes?: number | |
0a6658fd | 96 | remote: boolean |
69818c93 C |
97 | |
98 | Author?: AuthorInstance | |
6fcd19ba | 99 | Tags?: TagInstance[] |
93e1258c | 100 | VideoFiles?: VideoFileInstance[] |
e02643f3 C |
101 | } |
102 | ||
103 | export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { | |
e02643f3 C |
104 | createdAt: Date |
105 | updatedAt: Date | |
154898b0 | 106 | |
93e1258c C |
107 | createPreview: VideoMethods.CreatePreview |
108 | createThumbnail: VideoMethods.CreateThumbnail | |
109 | createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash | |
40298b02 | 110 | getOriginalFile: VideoMethods.GetOriginalFile |
154898b0 | 111 | generateMagnetUri: VideoMethods.GenerateMagnetUri |
154898b0 | 112 | getPreviewName: VideoMethods.GetPreviewName |
d8755eed | 113 | getPreviewPath: VideoMethods.GetPreviewPath |
93e1258c | 114 | getThumbnailName: VideoMethods.GetThumbnailName |
d8755eed | 115 | getThumbnailPath: VideoMethods.GetThumbnailPath |
93e1258c C |
116 | getTorrentFileName: VideoMethods.GetTorrentFileName |
117 | getVideoFilename: VideoMethods.GetVideoFilename | |
118 | getVideoFilePath: VideoMethods.GetVideoFilePath | |
154898b0 | 119 | isOwned: VideoMethods.IsOwned |
93e1258c C |
120 | removeFile: VideoMethods.RemoveFile |
121 | removePreview: VideoMethods.RemovePreview | |
122 | removeThumbnail: VideoMethods.RemoveThumbnail | |
123 | removeTorrent: VideoMethods.RemoveTorrent | |
154898b0 | 124 | toAddRemoteJSON: VideoMethods.ToAddRemoteJSON |
0aef76c4 | 125 | toFormattedJSON: VideoMethods.ToFormattedJSON |
154898b0 | 126 | toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON |
40298b02 C |
127 | optimizeOriginalVideofile: VideoMethods.OptimizeOriginalVideofile |
128 | transcodeOriginalVideofile: VideoMethods.TranscodeOriginalVideofile | |
129 | getOriginalFileHeight: VideoMethods.GetOriginalFileHeight | |
d8755eed | 130 | getEmbedPath: VideoMethods.GetEmbedPath |
6fcd19ba C |
131 | |
132 | setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string> | |
40298b02 | 133 | addVideoFile: Sequelize.HasManyAddAssociationMixin<VideoFileAttributes, string> |
93e1258c | 134 | setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string> |
e02643f3 C |
135 | } |
136 | ||
137 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} |