]>
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 | |
74889a71 | 8 | import { Video as FormatedVideo } from '../../../shared/models/video.model' |
6fcd19ba | 9 | import { ResultList } from '../../../shared/models/result-list.model' |
69818c93 C |
10 | |
11 | export type FormatedAddRemoteVideo = { | |
12 | name: string | |
13 | category: number | |
14 | licence: number | |
15 | language: number | |
16 | nsfw: boolean | |
17 | description: string | |
18 | infoHash: string | |
19 | remoteId: string | |
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 = { | |
33 | name: string | |
34 | category: number | |
35 | licence: number | |
36 | language: number | |
37 | nsfw: boolean | |
38 | description: string | |
39 | infoHash: string | |
40 | remoteId: string | |
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 | ||
83 | export type Load = (id: string) => Promise<VideoInstance> | |
84 | export type LoadByHostAndRemoteId = (fromHost: string, remoteId: string) => Promise<VideoInstance> | |
85 | export type LoadAndPopulateAuthor = (id: string) => Promise<VideoInstance> | |
86 | export type LoadAndPopulateAuthorAndPodAndTags = (id: string) => Promise<VideoInstance> | |
e02643f3 C |
87 | } |
88 | ||
89 | export interface VideoClass { | |
90 | generateMagnetUri: VideoMethods.GenerateMagnetUri | |
91 | getVideoFilename: VideoMethods.GetVideoFilename | |
92 | getThumbnailName: VideoMethods.GetThumbnailName | |
93 | getPreviewName: VideoMethods.GetPreviewName | |
94 | getTorrentName: VideoMethods.GetTorrentName | |
95 | isOwned: VideoMethods.IsOwned | |
96 | toFormatedJSON: VideoMethods.ToFormatedJSON | |
97 | toAddRemoteJSON: VideoMethods.ToAddRemoteJSON | |
98 | toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON | |
99 | transcodeVideofile: VideoMethods.TranscodeVideofile | |
100 | ||
101 | generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData | |
102 | getDurationFromFile: VideoMethods.GetDurationFromFile | |
103 | list: VideoMethods.List | |
104 | listForApi: VideoMethods.ListForApi | |
105 | loadByHostAndRemoteId: VideoMethods.LoadByHostAndRemoteId | |
106 | listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags | |
107 | listOwnedByAuthor: VideoMethods.ListOwnedByAuthor | |
108 | load: VideoMethods.Load | |
109 | loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor | |
110 | loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags | |
111 | searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags | |
112 | } | |
113 | ||
114 | export interface VideoAttributes { | |
115 | name: string | |
116 | extname: string | |
117 | remoteId: string | |
118 | category: number | |
119 | licence: number | |
120 | language: number | |
121 | nsfw: boolean | |
122 | description: string | |
123 | infoHash?: string | |
124 | duration: number | |
125 | views?: number | |
126 | likes?: number | |
127 | dislikes?: number | |
69818c93 C |
128 | |
129 | Author?: AuthorInstance | |
6fcd19ba | 130 | Tags?: TagInstance[] |
e02643f3 C |
131 | } |
132 | ||
133 | export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { | |
134 | id: string | |
135 | createdAt: Date | |
136 | updatedAt: Date | |
154898b0 C |
137 | |
138 | generateMagnetUri: VideoMethods.GenerateMagnetUri | |
139 | getVideoFilename: VideoMethods.GetVideoFilename | |
140 | getThumbnailName: VideoMethods.GetThumbnailName | |
141 | getPreviewName: VideoMethods.GetPreviewName | |
142 | getTorrentName: VideoMethods.GetTorrentName | |
143 | isOwned: VideoMethods.IsOwned | |
144 | toFormatedJSON: VideoMethods.ToFormatedJSON | |
145 | toAddRemoteJSON: VideoMethods.ToAddRemoteJSON | |
146 | toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON | |
147 | transcodeVideofile: VideoMethods.TranscodeVideofile | |
6fcd19ba C |
148 | |
149 | setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string> | |
e02643f3 C |
150 | } |
151 | ||
152 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} |