]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/models/video/video-interface.ts
Add previews cache system between pods
[github/Chocobozzz/PeerTube.git] / server / models / video / video-interface.ts
1 import * as Sequelize from 'sequelize'
2 import * as Promise from 'bluebird'
3
4 import { AuthorInstance } from './author-interface'
5 import { TagAttributes, TagInstance } from './tag-interface'
6
7 // Don't use barrel, import just what we need
8 import { Video as FormatedVideo } from '../../../shared/models/videos/video.model'
9 import { ResultList } from '../../../shared/models/result-list.model'
10
11 export type FormatedAddRemoteVideo = {
12 uuid: string
13 name: string
14 category: number
15 licence: number
16 language: number
17 nsfw: boolean
18 description: string
19 infoHash: 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 uuid: string
34 name: string
35 category: number
36 licence: number
37 language: number
38 nsfw: boolean
39 description: string
40 infoHash: 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
52 export namespace VideoMethods {
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
60
61 export type ToAddRemoteJSON = (this: VideoInstance) => Promise<FormatedAddRemoteVideo>
62 export type ToUpdateRemoteJSON = (this: VideoInstance) => FormatedUpdateRemoteVideo
63
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: 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>
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
107 loadByHostAndUUID: VideoMethods.LoadByHostAndUUID
108 listOwnedAndPopulateAuthorAndTags: VideoMethods.ListOwnedAndPopulateAuthorAndTags
109 listOwnedByAuthor: VideoMethods.ListOwnedByAuthor
110 load: VideoMethods.Load
111 loadByUUID: VideoMethods.LoadByUUID
112 loadAndPopulateAuthor: VideoMethods.LoadAndPopulateAuthor
113 loadAndPopulateAuthorAndPodAndTags: VideoMethods.LoadAndPopulateAuthorAndPodAndTags
114 loadByUUIDAndPopulateAuthorAndPodAndTags: VideoMethods.LoadByUUIDAndPopulateAuthorAndPodAndTags
115 searchAndPopulateAuthorAndPodAndTags: VideoMethods.SearchAndPopulateAuthorAndPodAndTags
116 }
117
118 export interface VideoAttributes {
119 uuid?: string
120 name: string
121 extname: string
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
132 remote: boolean
133
134 Author?: AuthorInstance
135 Tags?: TagInstance[]
136 }
137
138 export interface VideoInstance extends VideoClass, VideoAttributes, Sequelize.Instance<VideoAttributes> {
139 id: number
140 createdAt: Date
141 updatedAt: Date
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
153
154 setTags: Sequelize.HasManySetAssociationsMixin<TagAttributes, string>
155 }
156
157 export interface VideoModel extends VideoClass, Sequelize.Model<VideoInstance, VideoAttributes> {}