aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video-interface.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-08-25 11:36:23 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-08-25 11:36:23 +0200
commit93e1258c7cbc0d1235ca6d2a1f7c1875985328b8 (patch)
treeb0a1f77af7ab54dc5f58f569fcd1e9d84b04c533 /server/models/video/video-interface.ts
parent69f224587e99d56008e1fa129d0641840a486620 (diff)
downloadPeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.tar.gz
PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.tar.zst
PeerTube-93e1258c7cbc0d1235ca6d2a1f7c1875985328b8.zip
Move video file metadata in their own table
Will be used for user video quotas and multiple video resolutions
Diffstat (limited to 'server/models/video/video-interface.ts')
-rw-r--r--server/models/video/video-interface.ts67
1 files changed, 40 insertions, 27 deletions
diff --git a/server/models/video/video-interface.ts b/server/models/video/video-interface.ts
index 2fabcd906..976c70b5e 100644
--- a/server/models/video/video-interface.ts
+++ b/server/models/video/video-interface.ts
@@ -3,11 +3,19 @@ import * as Promise from 'bluebird'
3 3
4import { AuthorInstance } from './author-interface' 4import { AuthorInstance } from './author-interface'
5import { TagAttributes, TagInstance } from './tag-interface' 5import { TagAttributes, TagInstance } from './tag-interface'
6import { VideoFileAttributes, VideoFileInstance } from './video-file-interface'
6 7
7// Don't use barrel, import just what we need 8// Don't use barrel, import just what we need
8import { Video as FormatedVideo } from '../../../shared/models/videos/video.model' 9import { Video as FormatedVideo } from '../../../shared/models/videos/video.model'
9import { ResultList } from '../../../shared/models/result-list.model' 10import { ResultList } from '../../../shared/models/result-list.model'
10 11
12export type FormatedRemoteVideoFile = {
13 infoHash: string
14 resolution: number
15 extname: string
16 size: number
17}
18
11export type FormatedAddRemoteVideo = { 19export type FormatedAddRemoteVideo = {
12 uuid: string 20 uuid: string
13 name: string 21 name: string
@@ -16,17 +24,16 @@ export type FormatedAddRemoteVideo = {
16 language: number 24 language: number
17 nsfw: boolean 25 nsfw: boolean
18 description: string 26 description: string
19 infoHash: string
20 author: string 27 author: string
21 duration: number 28 duration: number
22 thumbnailData: string 29 thumbnailData: string
23 tags: string[] 30 tags: string[]
24 createdAt: Date 31 createdAt: Date
25 updatedAt: Date 32 updatedAt: Date
26 extname: string
27 views: number 33 views: number
28 likes: number 34 likes: number
29 dislikes: number 35 dislikes: number
36 files: FormatedRemoteVideoFile[]
30} 37}
31 38
32export type FormatedUpdateRemoteVideo = { 39export type FormatedUpdateRemoteVideo = {
@@ -37,31 +44,35 @@ export type FormatedUpdateRemoteVideo = {
37 language: number 44 language: number
38 nsfw: boolean 45 nsfw: boolean
39 description: string 46 description: string
40 infoHash: string
41 author: string 47 author: string
42 duration: number 48 duration: number
43 tags: string[] 49 tags: string[]
44 createdAt: Date 50 createdAt: Date
45 updatedAt: Date 51 updatedAt: Date
46 extname: string
47 views: number 52 views: number
48 likes: number 53 likes: number
49 dislikes: number 54 dislikes: number
55 files: FormatedRemoteVideoFile[]
50} 56}
51 57
52export namespace VideoMethods { 58export namespace VideoMethods {
53 export type GenerateMagnetUri = (this: VideoInstance) => string
54 export type GetVideoFilename = (this: VideoInstance) => string
55 export type GetThumbnailName = (this: VideoInstance) => string 59 export type GetThumbnailName = (this: VideoInstance) => string
56 export type GetPreviewName = (this: VideoInstance) => string 60 export type GetPreviewName = (this: VideoInstance) => string
57 export type GetTorrentName = (this: VideoInstance) => string
58 export type IsOwned = (this: VideoInstance) => boolean 61 export type IsOwned = (this: VideoInstance) => boolean
59 export type ToFormatedJSON = (this: VideoInstance) => FormatedVideo 62 export type ToFormatedJSON = (this: VideoInstance) => FormatedVideo
60 63
64 export type GenerateMagnetUri = (this: VideoInstance, videoFile: VideoFileInstance) => string
65 export type GetTorrentFileName = (this: VideoInstance, videoFile: VideoFileInstance) => string
66 export type GetVideoFilename = (this: VideoInstance, videoFile: VideoFileInstance) => string
67 export type CreatePreview = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
68 export type CreateThumbnail = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<string>
69 export type GetVideoFilePath = (this: VideoInstance, videoFile: VideoFileInstance) => string
70 export type CreateTorrentAndSetInfoHash = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
71
61 export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormatedAddRemoteVideo> 72 export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormatedAddRemoteVideo>
62 export type ToUpdateRemoteJSON = (this: VideoInstance) => FormatedUpdateRemoteVideo 73 export type ToUpdateRemoteJSON = (this: VideoInstance) => FormatedUpdateRemoteVideo
63 74
64 export type TranscodeVideofile = (this: VideoInstance) => Promise<void> 75 export type TranscodeVideofile = (this: VideoInstance, inputVideoFile: VideoFileInstance) => Promise<void>
65 76
66 // Return thumbnail name 77 // Return thumbnail name
67 export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string> 78 export type GenerateThumbnailFromData = (video: VideoInstance, thumbnailData: string) => Promise<string>
@@ -86,31 +97,25 @@ export namespace VideoMethods {
86 export type LoadAndPopulateAuthor = (id: number) => Promise<VideoInstance> 97 export type LoadAndPopulateAuthor = (id: number) => Promise<VideoInstance>
87 export type LoadAndPopulateAuthorAndPodAndTags = (id: number) => Promise<VideoInstance> 98 export type LoadAndPopulateAuthorAndPodAndTags = (id: number) => Promise<VideoInstance>
88 export type LoadByUUIDAndPopulateAuthorAndPodAndTags = (uuid: string) => Promise<VideoInstance> 99 export type LoadByUUIDAndPopulateAuthorAndPodAndTags = (uuid: string) => Promise<VideoInstance>
100
101 export type RemoveThumbnail = (this: VideoInstance) => Promise<void>
102 export type RemovePreview = (this: VideoInstance) => Promise<void>
103 export type RemoveFile = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
104 export type RemoveTorrent = (this: VideoInstance, videoFile: VideoFileInstance) => Promise<void>
89} 105}
90 106
91export interface VideoClass { 107export 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 108 generateThumbnailFromData: VideoMethods.GenerateThumbnailFromData
104 getDurationFromFile: VideoMethods.GetDurationFromFile 109 getDurationFromFile: VideoMethods.GetDurationFromFile
105 list: VideoMethods.List 110 list: VideoMethods.List
106 listForApi: VideoMethods.ListForApi 111 listForApi: VideoMethods.ListForApi
107 loadByHostAndUUID: VideoMethods.LoadByHostAndUUID
108 listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags 112 listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags
109 listOwnedByAuthor: VideoMethods.ListOwnedByAuthor 113 listOwnedByAuthor: VideoMethods.ListOwnedByAuthor
110 load: VideoMethods.Load 114 load: VideoMethods.Load
111 loadByUUID: VideoMethods.LoadByUUID
112 loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor 115 loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor
113 loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags 116 loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags
117 loadByHostAndUUID: VideoMethods.LoadByHostAndUUID
118 loadByUUID: VideoMethods.LoadByUUID
114 loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags 119 loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags
115 searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags 120 searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags
116} 121}
@@ -118,13 +123,11 @@ export interface VideoClass {
118export interface VideoAttributes { 123export interface VideoAttributes {
119 uuid?: string 124 uuid?: string
120 name: string 125 name: string
121 extname: string
122 category: number 126 category: number
123 licence: number 127 licence: number
124 language: number 128 language: number
125 nsfw: boolean 129 nsfw: boolean
126 description: string 130 description: string
127 infoHash?: string
128 duration: number 131 duration: number
129 views?: number 132 views?: number
130 likes?: number 133 likes?: number
@@ -133,6 +136,7 @@ export interface VideoAttributes {
133 136
134 Author?: AuthorInstance 137 Author?: AuthorInstance
135 Tags?: TagInstance[] 138 Tags?: TagInstance[]
139 VideoFiles?: VideoFileInstance[]
136} 140}
137 141
138export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> { 142export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
@@ -140,18 +144,27 @@ export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.In
140 createdAt: Date 144 createdAt: Date
141 updatedAt: Date 145 updatedAt: Date
142 146
147 createPreview: VideoMethods.CreatePreview
148 createThumbnail: VideoMethods.CreateThumbnail
149 createTorrentAndSetInfoHash: VideoMethods.CreateTorrentAndSetInfoHash
143 generateMagnetUri: VideoMethods.GenerateMagnetUri 150 generateMagnetUri: VideoMethods.GenerateMagnetUri
144 getVideoFilename: VideoMethods.GetVideoFilename
145 getThumbnailName: VideoMethods.GetThumbnailName
146 getPreviewName: VideoMethods.GetPreviewName 151 getPreviewName: VideoMethods.GetPreviewName
147 getTorrentName: VideoMethods.GetTorrentName 152 getThumbnailName: VideoMethods.GetThumbnailName
153 getTorrentFileName: VideoMethods.GetTorrentFileName
154 getVideoFilename: VideoMethods.GetVideoFilename
155 getVideoFilePath: VideoMethods.GetVideoFilePath
148 isOwned: VideoMethods.IsOwned 156 isOwned: VideoMethods.IsOwned
149 toFormatedJSON: VideoMethods.ToFormatedJSON 157 removeFile: VideoMethods.RemoveFile
158 removePreview: VideoMethods.RemovePreview
159 removeThumbnail: VideoMethods.RemoveThumbnail
160 removeTorrent: VideoMethods.RemoveTorrent
150 toAddRemoteJSON: VideoMethods.ToAddRemoteJSON 161 toAddRemoteJSON: VideoMethods.ToAddRemoteJSON
162 toFormatedJSON: VideoMethods.ToFormatedJSON
151 toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON 163 toUpdateRemoteJSON: VideoMethods.ToUpdateRemoteJSON
152 transcodeVideofile: VideoMethods.TranscodeVideofile 164 transcodeVideofile: VideoMethods.TranscodeVideofile
153 165
154 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string> 166 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string>
167 setVideoFiles: Sequelize.HasManySetAssociationsMixin<VideoFileAttributes, string>
155} 168}
156 169
157export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {} 170export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}