diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 09:45:46 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-06-16 09:45:46 +0200 |
commit | 74889a71fe687dda74f2a687653122327807af36 (patch) | |
tree | e938e8b6401b74fbec80513a877d9967f2c0dbcd /server/models/video/video-interface.ts | |
parent | 15a302943d84bc0978b84fe33110c4daa451d311 (diff) | |
download | PeerTube-74889a71fe687dda74f2a687653122327807af36.tar.gz PeerTube-74889a71fe687dda74f2a687653122327807af36.tar.zst PeerTube-74889a71fe687dda74f2a687653122327807af36.zip |
Reorganize model files
Diffstat (limited to 'server/models/video/video-interface.ts')
-rw-r--r-- | server/models/video/video-interface.ts | 151 |
1 files changed, 151 insertions, 0 deletions
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts new file mode 100644 index 000000000..71b9b0a69 --- /dev/null +++ b/server/models/video/video-interface.ts | |||
@@ -0,0 +1,151 @@ | |||
1 | import * as Sequelize from 'sequelize' | ||
2 | |||
3 | import { AuthorInstance } from './author-interface' | ||
4 | import { VideoTagInstance } from './video-tag-interface' | ||
5 | |||
6 | // Don't use barrel, import just what we need | ||
7 | import { Video as FormatedVideo } from '../../../shared/models/video.model' | ||
8 | |||
9 | export type FormatedAddRemoteVideo = { | ||
10 | name: string | ||
11 | category: number | ||
12 | licence: number | ||
13 | language: number | ||
14 | nsfw: boolean | ||
15 | description: string | ||
16 | infoHash: string | ||
17 | remoteId: string | ||
18 | author: string | ||
19 | duration: number | ||
20 | thumbnailData: string | ||
21 | tags: string[] | ||
22 | createdAt: Date | ||
23 | updatedAt: Date | ||
24 | extname: string | ||
25 | views: number | ||
26 | likes: number | ||
27 | dislikes: number | ||
28 | } | ||
29 | |||
30 | export type FormatedUpdateRemoteVideo = { | ||
31 | name: string | ||
32 | category: number | ||
33 | licence: number | ||
34 | language: number | ||
35 | nsfw: boolean | ||
36 | description: string | ||
37 | infoHash: string | ||
38 | remoteId: string | ||
39 | author: string | ||
40 | duration: number | ||
41 | tags: string[] | ||
42 | createdAt: Date | ||
43 | updatedAt: Date | ||
44 | extname: string | ||
45 | views: number | ||
46 | likes: number | ||
47 | dislikes: number | ||
48 | } | ||
49 | |||
50 | export namespace VideoMethods { | ||
51 | export type GenerateMagnetUri = () => string | ||
52 | export type GetVideoFilename = () => string | ||
53 | export type GetThumbnailName = () => string | ||
54 | export type GetPreviewName = () => string | ||
55 | export type GetTorrentName = () => string | ||
56 | export type IsOwned = () => boolean | ||
57 | export type ToFormatedJSON = () => FormatedVideo | ||
58 | |||
59 | export type ToAddRemoteJSONCallback = (err: Error, videoFormated?: FormatedAddRemoteVideo) => void | ||
60 | export type ToAddRemoteJSON = (callback: ToAddRemoteJSONCallback) => void | ||
61 | |||
62 | export type ToUpdateRemoteJSON = () => FormatedUpdateRemoteVideo | ||
63 | |||
64 | export type TranscodeVideofileCallback = (err: Error) => void | ||
65 | export type TranscodeVideofile = (callback: TranscodeVideofileCallback) => void | ||
66 | |||
67 | export type GenerateThumbnailFromDataCallback = (err: Error, thumbnailName?: string) => void | ||
68 | export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string, callback: GenerateThumbnailFromDataCallback) => void | ||
69 | |||
70 | export type GetDurationFromFileCallback = (err: Error, duration?: number) => void | ||
71 | export type GetDurationFromFile = (videoPath, callback) => void | ||
72 | |||
73 | export type ListCallback = (err: Error, videoInstances: VideoInstance[]) => void | ||
74 | export type List = (callback: ListCallback) => void | ||
75 | |||
76 | export type ListForApiCallback = (err: Error, videoInstances?: VideoInstance[], total?: number) => void | ||
77 | export type ListForApi = (start: number, count: number, sort: string, callback: ListForApiCallback) => void | ||
78 | |||
79 | export type LoadByHostAndRemoteIdCallback = (err: Error, videoInstance: VideoInstance) => void | ||
80 | export type LoadByHostAndRemoteId = (fromHost: string, remoteId: string, callback: LoadByHostAndRemoteIdCallback) => void | ||
81 | |||
82 | export type ListOwnedAndPopulateAuthorAndTagsCallback = (err: Error, videoInstances: VideoInstance[]) => void | ||
83 | export type ListOwnedAndPopulateAuthorAndTags = (callback: ListOwnedAndPopulateAuthorAndTagsCallback) => void | ||
84 | |||
85 | export type ListOwnedByAuthorCallback = (err: Error, videoInstances: VideoInstance[]) => void | ||
86 | export type ListOwnedByAuthor = (author: string, callback: ListOwnedByAuthorCallback) => void | ||
87 | |||
88 | export type LoadCallback = (err: Error, videoInstance: VideoInstance) => void | ||
89 | export type Load = (id: string, callback: LoadCallback) => void | ||
90 | |||
91 | export type LoadAndPopulateAuthorCallback = (err: Error, videoInstance: VideoInstance) => void | ||
92 | export type LoadAndPopulateAuthor = (id: string, callback: LoadAndPopulateAuthorCallback) => void | ||
93 | |||
94 | export type LoadAndPopulateAuthorAndPodAndTagsCallback = (err: Error, videoInstance: VideoInstance) => void | ||
95 | export type LoadAndPopulateAuthorAndPodAndTags = (id: string, callback: LoadAndPopulateAuthorAndPodAndTagsCallback) => void | ||
96 | |||
97 | export type SearchAndPopulateAuthorAndPodAndTagsCallback = (err: Error, videoInstances?: VideoInstance[], total?: number) => void | ||
98 | export type SearchAndPopulateAuthorAndPodAndTags = (value: string, field: string, start: number, count: number, sort: string, callback: SearchAndPopulateAuthorAndPodAndTagsCallback) => void | ||
99 | } | ||
100 | |||
101 | export interface VideoClass { | ||
102 | generateMagnetUri: VideoMethods.GenerateMagnetUri | ||
103 | getVideoFilename: VideoMethods.GetVideoFilename | ||
104 | getThumbnailName: VideoMethods.GetThumbnailName | ||
105 | getPreviewName: VideoMethods.GetPreviewName | ||
106 | getTorrentName: VideoMethods.GetTorrentName | ||
107 | isOwned: VideoMethods.IsOwned | ||
108 | toFormatedJSON: VideoMethods.ToFormatedJSON | ||
109 | toAddRemoteJSON: VideoMethods.ToAddRemoteJSON | ||
110 | toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON | ||
111 | transcodeVideofile: VideoMethods.TranscodeVideofile | ||
112 | |||
113 | generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData | ||
114 | getDurationFromFile: VideoMethods.GetDurationFromFile | ||
115 | list: VideoMethods.List | ||
116 | listForApi: VideoMethods.ListForApi | ||
117 | loadByHostAndRemoteId: VideoMethods.LoadByHostAndRemoteId | ||
118 | listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags | ||
119 | listOwnedByAuthor: VideoMethods.ListOwnedByAuthor | ||
120 | load: VideoMethods.Load | ||
121 | loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor | ||
122 | loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags | ||
123 | searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags | ||
124 | } | ||
125 | |||
126 | export interface VideoAttributes { | ||
127 | name: string | ||
128 | extname: string | ||
129 | remoteId: string | ||
130 | category: number | ||
131 | licence: number | ||
132 | language: number | ||
133 | nsfw: boolean | ||
134 | description: string | ||
135 | infoHash?: string | ||
136 | duration: number | ||
137 | views?: number | ||
138 | likes?: number | ||
139 | dislikes?: number | ||
140 | |||
141 | Author?: AuthorInstance | ||
142 | Tags?: VideoTagInstance[] | ||
143 | } | ||
144 | |||
145 | export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { | ||
146 | id: string | ||
147 | createdAt: Date | ||
148 | updatedAt: Date | ||
149 | } | ||
150 | |||
151 | export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} | ||