diff options
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r-- | server/models/video/video.ts | 26 |
1 files changed, 11 insertions, 15 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 3bb74bf6d..650025205 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -87,7 +87,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
87 | type: DataTypes.STRING, | 87 | type: DataTypes.STRING, |
88 | allowNull: false, | 88 | allowNull: false, |
89 | validate: { | 89 | validate: { |
90 | nameValid: function (value) { | 90 | nameValid: value => { |
91 | const res = isVideoNameValid(value) | 91 | const res = isVideoNameValid(value) |
92 | if (res === false) throw new Error('Video name is not valid.') | 92 | if (res === false) throw new Error('Video name is not valid.') |
93 | } | 93 | } |
@@ -101,7 +101,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
101 | type: DataTypes.INTEGER, | 101 | type: DataTypes.INTEGER, |
102 | allowNull: false, | 102 | allowNull: false, |
103 | validate: { | 103 | validate: { |
104 | categoryValid: function (value) { | 104 | categoryValid: value => { |
105 | const res = isVideoCategoryValid(value) | 105 | const res = isVideoCategoryValid(value) |
106 | if (res === false) throw new Error('Video category is not valid.') | 106 | if (res === false) throw new Error('Video category is not valid.') |
107 | } | 107 | } |
@@ -112,7 +112,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
112 | allowNull: false, | 112 | allowNull: false, |
113 | defaultValue: null, | 113 | defaultValue: null, |
114 | validate: { | 114 | validate: { |
115 | licenceValid: function (value) { | 115 | licenceValid: value => { |
116 | const res = isVideoLicenceValid(value) | 116 | const res = isVideoLicenceValid(value) |
117 | if (res === false) throw new Error('Video licence is not valid.') | 117 | if (res === false) throw new Error('Video licence is not valid.') |
118 | } | 118 | } |
@@ -122,7 +122,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
122 | type: DataTypes.INTEGER, | 122 | type: DataTypes.INTEGER, |
123 | allowNull: true, | 123 | allowNull: true, |
124 | validate: { | 124 | validate: { |
125 | languageValid: function (value) { | 125 | languageValid: value => { |
126 | const res = isVideoLanguageValid(value) | 126 | const res = isVideoLanguageValid(value) |
127 | if (res === false) throw new Error('Video language is not valid.') | 127 | if (res === false) throw new Error('Video language is not valid.') |
128 | } | 128 | } |
@@ -132,7 +132,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
132 | type: DataTypes.BOOLEAN, | 132 | type: DataTypes.BOOLEAN, |
133 | allowNull: false, | 133 | allowNull: false, |
134 | validate: { | 134 | validate: { |
135 | nsfwValid: function (value) { | 135 | nsfwValid: value => { |
136 | const res = isVideoNSFWValid(value) | 136 | const res = isVideoNSFWValid(value) |
137 | if (res === false) throw new Error('Video nsfw attribute is not valid.') | 137 | if (res === false) throw new Error('Video nsfw attribute is not valid.') |
138 | } | 138 | } |
@@ -142,7 +142,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
142 | type: DataTypes.STRING, | 142 | type: DataTypes.STRING, |
143 | allowNull: false, | 143 | allowNull: false, |
144 | validate: { | 144 | validate: { |
145 | descriptionValid: function (value) { | 145 | descriptionValid: value => { |
146 | const res = isVideoDescriptionValid(value) | 146 | const res = isVideoDescriptionValid(value) |
147 | if (res === false) throw new Error('Video description is not valid.') | 147 | if (res === false) throw new Error('Video description is not valid.') |
148 | } | 148 | } |
@@ -152,7 +152,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
152 | type: DataTypes.STRING, | 152 | type: DataTypes.STRING, |
153 | allowNull: false, | 153 | allowNull: false, |
154 | validate: { | 154 | validate: { |
155 | infoHashValid: function (value) { | 155 | infoHashValid: value => { |
156 | const res = isVideoInfoHashValid(value) | 156 | const res = isVideoInfoHashValid(value) |
157 | if (res === false) throw new Error('Video info hash is not valid.') | 157 | if (res === false) throw new Error('Video info hash is not valid.') |
158 | } | 158 | } |
@@ -162,7 +162,7 @@ export default function (sequelize: Sequelize.Sequelize, DataTypes: Sequelize.Da | |||
162 | type: DataTypes.INTEGER, | 162 | type: DataTypes.INTEGER, |
163 | allowNull: false, | 163 | allowNull: false, |
164 | validate: { | 164 | validate: { |
165 | durationValid: function (value) { | 165 | durationValid: value => { |
166 | const res = isVideoDurationValid(value) | 166 | const res = isVideoDurationValid(value) |
167 | if (res === false) throw new Error('Video duration is not valid.') | 167 | if (res === false) throw new Error('Video duration is not valid.') |
168 | } | 168 | } |
@@ -549,9 +549,7 @@ transcodeVideofile = function (this: VideoInstance) { | |||
549 | }) | 549 | }) |
550 | .catch(err => { | 550 | .catch(err => { |
551 | // Autodesctruction... | 551 | // Autodesctruction... |
552 | video.destroy().asCallback(function (err) { | 552 | video.destroy().catch(err => logger.error('Cannot destruct video after transcoding failure.', err)) |
553 | if (err) logger.error('Cannot destruct video after transcoding failure.', err) | ||
554 | }) | ||
555 | 553 | ||
556 | return rej(err) | 554 | return rej(err) |
557 | }) | 555 | }) |
@@ -574,7 +572,7 @@ generateThumbnailFromData = function (video: VideoInstance, thumbnailData: strin | |||
574 | 572 | ||
575 | getDurationFromFile = function (videoPath: string) { | 573 | getDurationFromFile = function (videoPath: string) { |
576 | return new Promise<number>((res, rej) => { | 574 | return new Promise<number>((res, rej) => { |
577 | ffmpeg.ffprobe(videoPath, function (err, metadata) { | 575 | ffmpeg.ffprobe(videoPath, (err, metadata) => { |
578 | if (err) return rej(err) | 576 | if (err) return rej(err) |
579 | 577 | ||
580 | return res(Math.floor(metadata.format.duration)) | 578 | return res(Math.floor(metadata.format.duration)) |
@@ -865,9 +863,7 @@ function generateImage (video: VideoInstance, videoPath: string, folder: string, | |||
865 | return new Promise<string>((res, rej) => { | 863 | return new Promise<string>((res, rej) => { |
866 | ffmpeg(videoPath) | 864 | ffmpeg(videoPath) |
867 | .on('error', rej) | 865 | .on('error', rej) |
868 | .on('end', function () { | 866 | .on('end', () => res(imageName)) |
869 | return res(imageName) | ||
870 | }) | ||
871 | .thumbnail(options) | 867 | .thumbnail(options) |
872 | }) | 868 | }) |
873 | } | 869 | } |