]>
Commit | Line | Data |
---|---|---|
1 | import * as Sequelize from 'sequelize' | |
2 | import * as Bluebird 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 | import { VideoTorrentObject } from '../../../shared/models/activitypub/objects/video-torrent-object' | |
17 | ||
18 | export namespace VideoMethods { | |
19 | export type GetThumbnailName = (this: VideoInstance) => string | |
20 | export type GetPreviewName = (this: VideoInstance) => string | |
21 | export type IsOwned = (this: VideoInstance) => boolean | |
22 | export type ToFormattedJSON = (this: VideoInstance) => FormattedVideo | |
23 | export type ToFormattedDetailsJSON = (this: VideoInstance) => FormattedDetailsVideo | |
24 | ||
25 | export type GetOriginalFile = (this: VideoInstance) => VideoFileInstance | |
26 | export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string | |
27 | export type GetVideoFilename = (this: VideoInstance, videoFile: VideoFileInstance) => string | |
28 | export type CreatePreview = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string> | |
29 | export type CreateThumbnail = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string> | |
30 | export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string | |
31 | export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void> | |
32 | ||
33 | export type ToActivityPubObject = (this: VideoInstance) => VideoTorrentObject | |
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 | export type GetCategoryLabel = (this: VideoInstance) => string | |
44 | export type GetLicenceLabel = (this: VideoInstance) => string | |
45 | export type GetLanguageLabel = (this: VideoInstance) => string | |
46 | ||
47 | // Return thumbnail name | |
48 | export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string> | |
49 | ||
50 | export type List = () => Bluebird<VideoInstance[]> | |
51 | export type ListOwnedAndPopulateAccountAndTags = () => Bluebird<VideoInstance[]> | |
52 | export type ListOwnedByAccount = (account: string) => Bluebird<VideoInstance[]> | |
53 | ||
54 | export type ListForApi = (start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> > | |
55 | export type ListUserVideosForApi = (userId: number, start: number, count: number, sort: string) => Bluebird< ResultList<VideoInstance> > | |
56 | export type SearchAndPopulateAccountAndPodAndTags = ( | |
57 | value: string, | |
58 | field: string, | |
59 | start: number, | |
60 | count: number, | |
61 | sort: string | |
62 | ) => Bluebird< ResultList<VideoInstance> > | |
63 | ||
64 | export type Load = (id: number) => Bluebird<VideoInstance> | |
65 | export type LoadByUUID = (uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> | |
66 | export type LoadByUrl = (url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> | |
67 | export type LoadLocalVideoByUUID = (uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> | |
68 | export type LoadByHostAndUUID = (fromHost: string, uuid: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> | |
69 | export type LoadAndPopulateAccount = (id: number) => Bluebird<VideoInstance> | |
70 | export type LoadAndPopulateAccountAndPodAndTags = (id: number) => Bluebird<VideoInstance> | |
71 | export type LoadByUUIDAndPopulateAccountAndPodAndTags = (uuid: string) => Bluebird<VideoInstance> | |
72 | export type LoadByUUIDOrURL = (uuid: string, url: string, t?: Sequelize.Transaction) => Bluebird<VideoInstance> | |
73 | ||
74 | export type RemoveThumbnail = (this: VideoInstance) => Promise<void> | |
75 | export type RemovePreview = (this: VideoInstance) => Promise<void> | |
76 | export type RemoveFile = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void> | |
77 | export type RemoveTorrent = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void> | |
78 | } | |
79 | ||
80 | export interface VideoClass { | |
81 | generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData | |
82 | list: VideoMethods.List | |
83 | listForApi: VideoMethods.ListForApi | |
84 | listUserVideosForApi: VideoMethods.ListUserVideosForApi | |
85 | listOwnedAndPopulateAccountAndTags: VideoMethods.ListOwnedAndPopulateAccountAndTags | |
86 | listOwnedByAccount: VideoMethods.ListOwnedByAccount | |
87 | load: VideoMethods.Load | |
88 | loadAndPopulateAccount: VideoMethods.LoadAndPopulateAccount | |
89 | loadAndPopulateAccountAndPodAndTags: VideoMethods.LoadAndPopulateAccountAndPodAndTags | |
90 | loadByHostAndUUID: VideoMethods.LoadByHostAndUUID | |
91 | loadByUUID: VideoMethods.LoadByUUID | |
92 | loadByUrl: VideoMethods.LoadByUrl | |
93 | loadByUUIDOrURL: VideoMethods.LoadByUUIDOrURL | |
94 | loadLocalVideoByUUID: VideoMethods.LoadLocalVideoByUUID | |
95 | loadByUUIDAndPopulateAccountAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAccountAndPodAndTags | |
96 | searchAndPopulateAccountAndPodAndTags: VideoMethods.SearchAndPopulateAccountAndPodAndTags | |
97 | } | |
98 | ||
99 | export interface VideoAttributes { | |
100 | id?: number | |
101 | uuid?: string | |
102 | name: string | |
103 | category: number | |
104 | licence: number | |
105 | language: number | |
106 | nsfw: boolean | |
107 | description: string | |
108 | duration: number | |
109 | privacy: number | |
110 | views?: number | |
111 | likes?: number | |
112 | dislikes?: number | |
113 | remote: boolean | |
114 | url?: string | |
115 | ||
116 | createdAt?: Date | |
117 | updatedAt?: Date | |
118 | ||
119 | parentId?: number | |
120 | channelId?: number | |
121 | ||
122 | VideoChannel?: VideoChannelInstance | |
123 | Tags?: TagInstance[] | |
124 | VideoFiles?: VideoFileInstance[] | |
125 | } | |
126 | ||
127 | export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { | |
128 | createPreview: VideoMethods.CreatePreview | |
129 | createThumbnail: VideoMethods.CreateThumbnail | |
130 | createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash | |
131 | getOriginalFile: VideoMethods.GetOriginalFile | |
132 | getPreviewName: VideoMethods.GetPreviewName | |
133 | getPreviewPath: VideoMethods.GetPreviewPath | |
134 | getThumbnailName: VideoMethods.GetThumbnailName | |
135 | getThumbnailPath: VideoMethods.GetThumbnailPath | |
136 | getTorrentFileName: VideoMethods.GetTorrentFileName | |
137 | getVideoFilename: VideoMethods.GetVideoFilename | |
138 | getVideoFilePath: VideoMethods.GetVideoFilePath | |
139 | isOwned: VideoMethods.IsOwned | |
140 | removeFile: VideoMethods.RemoveFile | |
141 | removePreview: VideoMethods.RemovePreview | |
142 | removeThumbnail: VideoMethods.RemoveThumbnail | |
143 | removeTorrent: VideoMethods.RemoveTorrent | |
144 | toActivityPubObject: VideoMethods.ToActivityPubObject | |
145 | toFormattedJSON: VideoMethods.ToFormattedJSON | |
146 | toFormattedDetailsJSON: VideoMethods.ToFormattedDetailsJSON | |
147 | optimizeOriginalVideofile: VideoMethods.OptimizeOriginalVideofile | |
148 | transcodeOriginalVideofile: VideoMethods.TranscodeOriginalVideofile | |
149 | getOriginalFileHeight: VideoMethods.GetOriginalFileHeight | |
150 | getEmbedPath: VideoMethods.GetEmbedPath | |
151 | getDescriptionPath: VideoMethods.GetDescriptionPath | |
152 | getTruncatedDescription: VideoMethods.GetTruncatedDescription | |
153 | getCategoryLabel: VideoMethods.GetCategoryLabel | |
154 | getLicenceLabel: VideoMethods.GetLicenceLabel | |
155 | getLanguageLabel: VideoMethods.GetLanguageLabel | |
156 | ||
157 | setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string> | |
158 | addVideoFile: Sequelize.HasManyAddAssociationMixin<VideoFileAttributes, string> | |
159 | setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string> | |
160 | } | |
161 | ||
162 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} |