]>
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' |
69818c93 C |
6 | |
7 | // Don't use barrel, import just what we need | |
4771e000 | 8 | import { Video as FormatedVideo } from '../../../shared/models/videos/video.model' |
6fcd19ba | 9 | import { ResultList } from '../../../shared/models/result-list.model' |
69818c93 C |
10 | |
11 | export type FormatedAddRemoteVideo = { | |
0a6658fd | 12 | uuid: string |
69818c93 C |
13 | name: string |
14 | category: number | |
15 | licence: number | |
16 | language: number | |
17 | nsfw: boolean | |
18 | description: string | |
19 | infoHash: string | |
69818c93 C |
20 | author: string |
21 | duration: number | |
22 | thumbnailData: string | |
23 | tags: string[] | |
24 | createdAt: Date | |
25 | updatedAt: Date | |
26 | extname: string | |
27 | views: number | |
28 | likes: number | |
29 | dislikes: number | |
30 | } | |
31 | ||
32 | export type FormatedUpdateRemoteVideo = { | |
0a6658fd | 33 | uuid: string |
69818c93 C |
34 | name: string |
35 | category: number | |
36 | licence: number | |
37 | language: number | |
38 | nsfw: boolean | |
39 | description: string | |
40 | infoHash: string | |
69818c93 C |
41 | author: string |
42 | duration: number | |
43 | tags: string[] | |
44 | createdAt: Date | |
45 | updatedAt: Date | |
46 | extname: string | |
47 | views: number | |
48 | likes: number | |
49 | dislikes: number | |
50 | } | |
51 | ||
e02643f3 | 52 | export namespace VideoMethods { |
70c065d6 C |
53 | export type GenerateMagnetUri = (this: VideoInstance) => string |
54 | export type GetVideoFilename = (this: VideoInstance) => string | |
55 | export type GetThumbnailName = (this: VideoInstance) => string | |
56 | export type GetPreviewName = (this: VideoInstance) => string | |
57 | export type GetTorrentName = (this: VideoInstance) => string | |
58 | export type IsOwned = (this: VideoInstance) => boolean | |
59 | export type ToFormatedJSON = (this: VideoInstance) => FormatedVideo | |
69818c93 | 60 | |
6fcd19ba | 61 | export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormatedAddRemoteVideo> |
70c065d6 | 62 | export type ToUpdateRemoteJSON = (this: VideoInstance) => FormatedUpdateRemoteVideo |
69818c93 | 63 | |
6fcd19ba C |
64 | export type TranscodeVideofile = (this: VideoInstance) => Promise<void> |
65 | ||
66 | // Return thumbnail name | |
67 | export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string> | |
68 | export type GetDurationFromFile = (videoPath: string) => Promise<number> | |
69 | ||
70 | export type List = () => Promise<VideoInstance[]> | |
71 | export type ListOwnedAndPopulateAuthorAndTags = () => Promise<VideoInstance[]> | |
72 | export type ListOwnedByAuthor = (author: string) => Promise<VideoInstance[]> | |
73 | ||
74 | export type ListForApi = (start: number, count: number, sort: string) => Promise< ResultList<VideoInstance> > | |
75 | export type SearchAndPopulateAuthorAndPodAndTags = ( | |
76 | value: string, | |
77 | field: string, | |
78 | start: number, | |
79 | count: number, | |
80 | sort: string | |
81 | ) => Promise< ResultList<VideoInstance> > | |
82 | ||
0a6658fd C |
83 | export type Load = (id: number) => Promise<VideoInstance> |
84 | export type LoadByUUID = (uuid: string) => Promise<VideoInstance> | |
85 | export type LoadByHostAndUUID = (fromHost: string, uuid: string) => Promise<VideoInstance> | |
86 | export type LoadAndPopulateAuthor = (id: number) => Promise<VideoInstance> | |
87 | export type LoadAndPopulateAuthorAndPodAndTags = (id: number) => Promise<VideoInstance> | |
88 | export type LoadByUUIDAndPopulateAuthorAndPodAndTags = (uuid: string) => Promise<VideoInstance> | |
e02643f3 C |
89 | } |
90 | ||
91 | export interface VideoClass { | |
92 | generateMagnetUri: VideoMethods.GenerateMagnetUri | |
93 | getVideoFilename: VideoMethods.GetVideoFilename | |
94 | getThumbnailName: VideoMethods.GetThumbnailName | |
95 | getPreviewName: VideoMethods.GetPreviewName | |
96 | getTorrentName: VideoMethods.GetTorrentName | |
97 | isOwned: VideoMethods.IsOwned | |
98 | toFormatedJSON: VideoMethods.ToFormatedJSON | |
99 | toAddRemoteJSON: VideoMethods.ToAddRemoteJSON | |
100 | toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON | |
101 | transcodeVideofile: VideoMethods.TranscodeVideofile | |
102 | ||
103 | generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData | |
104 | getDurationFromFile: VideoMethods.GetDurationFromFile | |
105 | list: VideoMethods.List | |
106 | listForApi: VideoMethods.ListForApi | |
0a6658fd | 107 | loadByHostAndUUID: VideoMethods.LoadByHostAndUUID |
e02643f3 C |
108 | listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags |
109 | listOwnedByAuthor: VideoMethods.ListOwnedByAuthor | |
110 | load: VideoMethods.Load | |
0a6658fd | 111 | loadByUUID: VideoMethods.LoadByUUID |
e02643f3 C |
112 | loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor |
113 | loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags | |
0a6658fd | 114 | loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags |
e02643f3 C |
115 | searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags |
116 | } | |
117 | ||
118 | export interface VideoAttributes { | |
0a6658fd | 119 | uuid?: string |
e02643f3 C |
120 | name: string |
121 | extname: string | |
e02643f3 C |
122 | category: number |
123 | licence: number | |
124 | language: number | |
125 | nsfw: boolean | |
126 | description: string | |
127 | infoHash?: string | |
128 | duration: number | |
129 | views?: number | |
130 | likes?: number | |
131 | dislikes?: number | |
0a6658fd | 132 | remote: boolean |
69818c93 C |
133 | |
134 | Author?: AuthorInstance | |
6fcd19ba | 135 | Tags?: TagInstance[] |
e02643f3 C |
136 | } |
137 | ||
138 | export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { | |
0a6658fd | 139 | id: number |
e02643f3 C |
140 | createdAt: Date |
141 | updatedAt: Date | |
154898b0 C |
142 | |
143 | generateMagnetUri: VideoMethods.GenerateMagnetUri | |
144 | getVideoFilename: VideoMethods.GetVideoFilename | |
145 | getThumbnailName: VideoMethods.GetThumbnailName | |
146 | getPreviewName: VideoMethods.GetPreviewName | |
147 | getTorrentName: VideoMethods.GetTorrentName | |
148 | isOwned: VideoMethods.IsOwned | |
149 | toFormatedJSON: VideoMethods.ToFormatedJSON | |
150 | toAddRemoteJSON: VideoMethods.ToAddRemoteJSON | |
151 | toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON | |
152 | transcodeVideofile: VideoMethods.TranscodeVideofile | |
6fcd19ba C |
153 | |
154 | setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string> | |
e02643f3 C |
155 | } |
156 | ||
157 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} |