diff options
author | Chocobozzz <me@florianbigard.com> | 2018-08-17 11:24:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-08-27 09:41:54 +0200 |
commit | 965c4b22d0e4d2f853501e844e6ebbb861bd389d (patch) | |
tree | 519574c83ea070968d9561d493bc16ac2e285090 /server | |
parent | 06a05d5f4784a7cbb27aa1188385b5679845dad8 (diff) | |
download | PeerTube-965c4b22d0e4d2f853501e844e6ebbb861bd389d.tar.gz PeerTube-965c4b22d0e4d2f853501e844e6ebbb861bd389d.tar.zst PeerTube-965c4b22d0e4d2f853501e844e6ebbb861bd389d.zip |
Use height instead of width to represent the video resolution
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/custom-validators/activitypub/videos.ts | 9 | ||||
-rw-r--r-- | server/lib/activitypub/videos.ts | 6 | ||||
-rw-r--r-- | server/models/video/video.ts | 6 |
3 files changed, 12 insertions, 9 deletions
diff --git a/server/helpers/custom-validators/activitypub/videos.ts b/server/helpers/custom-validators/activitypub/videos.ts index 702c09842..0362f43ab 100644 --- a/server/helpers/custom-validators/activitypub/videos.ts +++ b/server/helpers/custom-validators/activitypub/videos.ts | |||
@@ -148,22 +148,25 @@ function setRemoteVideoTruncatedContent (video: any) { | |||
148 | } | 148 | } |
149 | 149 | ||
150 | function isRemoteVideoUrlValid (url: any) { | 150 | function isRemoteVideoUrlValid (url: any) { |
151 | // FIXME: Old bug, we used the width to represent the resolution. Remove it in a few realease (currently beta.11) | ||
152 | if (url.width && !url.height) url.height = url.width | ||
153 | |||
151 | return url.type === 'Link' && | 154 | return url.type === 'Link' && |
152 | ( | 155 | ( |
153 | ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 && | 156 | ACTIVITY_PUB.URL_MIME_TYPES.VIDEO.indexOf(url.mimeType) !== -1 && |
154 | isActivityPubUrlValid(url.href) && | 157 | isActivityPubUrlValid(url.href) && |
155 | validator.isInt(url.width + '', { min: 0 }) && | 158 | validator.isInt(url.height + '', { min: 0 }) && |
156 | validator.isInt(url.size + '', { min: 0 }) && | 159 | validator.isInt(url.size + '', { min: 0 }) && |
157 | (!url.fps || validator.isInt(url.fps + '', { min: 0 })) | 160 | (!url.fps || validator.isInt(url.fps + '', { min: 0 })) |
158 | ) || | 161 | ) || |
159 | ( | 162 | ( |
160 | ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 && | 163 | ACTIVITY_PUB.URL_MIME_TYPES.TORRENT.indexOf(url.mimeType) !== -1 && |
161 | isActivityPubUrlValid(url.href) && | 164 | isActivityPubUrlValid(url.href) && |
162 | validator.isInt(url.width + '', { min: 0 }) | 165 | validator.isInt(url.height + '', { min: 0 }) |
163 | ) || | 166 | ) || |
164 | ( | 167 | ( |
165 | ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 && | 168 | ACTIVITY_PUB.URL_MIME_TYPES.MAGNET.indexOf(url.mimeType) !== -1 && |
166 | validator.isLength(url.href, { min: 5 }) && | 169 | validator.isLength(url.href, { min: 5 }) && |
167 | validator.isInt(url.width + '', { min: 0 }) | 170 | validator.isInt(url.height + '', { min: 0 }) |
168 | ) | 171 | ) |
169 | } | 172 | } |
diff --git a/server/lib/activitypub/videos.ts b/server/lib/activitypub/videos.ts index e2f46bd02..d1888556c 100644 --- a/server/lib/activitypub/videos.ts +++ b/server/lib/activitypub/videos.ts | |||
@@ -11,7 +11,7 @@ import { isVideoFileInfoHashValid } from '../../helpers/custom-validators/videos | |||
11 | import { retryTransactionWrapper } from '../../helpers/database-utils' | 11 | import { retryTransactionWrapper } from '../../helpers/database-utils' |
12 | import { logger } from '../../helpers/logger' | 12 | import { logger } from '../../helpers/logger' |
13 | import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' | 13 | import { doRequest, doRequestAndSaveToFile } from '../../helpers/requests' |
14 | import { ACTIVITY_PUB, CONFIG, REMOTE_SCHEME, sequelizeTypescript, STATIC_PATHS, VIDEO_MIMETYPE_EXT } from '../../initializers' | 14 | import { ACTIVITY_PUB, CONFIG, REMOTE_SCHEME, sequelizeTypescript, VIDEO_MIMETYPE_EXT } from '../../initializers' |
15 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' | 15 | import { AccountVideoRateModel } from '../../models/account/account-video-rate' |
16 | import { ActorModel } from '../../models/activitypub/actor' | 16 | import { ActorModel } from '../../models/activitypub/actor' |
17 | import { TagModel } from '../../models/video/tag' | 17 | import { TagModel } from '../../models/video/tag' |
@@ -147,7 +147,7 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje | |||
147 | for (const fileUrl of fileUrls) { | 147 | for (const fileUrl of fileUrls) { |
148 | // Fetch associated magnet uri | 148 | // Fetch associated magnet uri |
149 | const magnet = videoObject.url.find(u => { | 149 | const magnet = videoObject.url.find(u => { |
150 | return u.mimeType === 'application/x-bittorrent;x-scheme-handler/magnet' && u.width === fileUrl.width | 150 | return u.mimeType === 'application/x-bittorrent;x-scheme-handler/magnet' && u.height === fileUrl.height |
151 | }) | 151 | }) |
152 | 152 | ||
153 | if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href) | 153 | if (!magnet) throw new Error('Cannot find associated magnet uri for file ' + fileUrl.href) |
@@ -160,7 +160,7 @@ function videoFileActivityUrlToDBAttributes (videoCreated: VideoModel, videoObje | |||
160 | const attribute = { | 160 | const attribute = { |
161 | extname: VIDEO_MIMETYPE_EXT[ fileUrl.mimeType ], | 161 | extname: VIDEO_MIMETYPE_EXT[ fileUrl.mimeType ], |
162 | infoHash: parsed.infoHash, | 162 | infoHash: parsed.infoHash, |
163 | resolution: fileUrl.width, | 163 | resolution: fileUrl.height, |
164 | size: fileUrl.size, | 164 | size: fileUrl.size, |
165 | videoId: videoCreated.id, | 165 | videoId: videoCreated.id, |
166 | fps: fileUrl.fps | 166 | fps: fileUrl.fps |
diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 5db718061..25a1cd177 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts | |||
@@ -1402,7 +1402,7 @@ export class VideoModel extends Model<VideoModel> { | |||
1402 | type: 'Link', | 1402 | type: 'Link', |
1403 | mimeType: VIDEO_EXT_MIMETYPE[file.extname], | 1403 | mimeType: VIDEO_EXT_MIMETYPE[file.extname], |
1404 | href: this.getVideoFileUrl(file, baseUrlHttp), | 1404 | href: this.getVideoFileUrl(file, baseUrlHttp), |
1405 | width: file.resolution, | 1405 | height: file.resolution, |
1406 | size: file.size, | 1406 | size: file.size, |
1407 | fps: file.fps | 1407 | fps: file.fps |
1408 | }) | 1408 | }) |
@@ -1411,14 +1411,14 @@ export class VideoModel extends Model<VideoModel> { | |||
1411 | type: 'Link', | 1411 | type: 'Link', |
1412 | mimeType: 'application/x-bittorrent', | 1412 | mimeType: 'application/x-bittorrent', |
1413 | href: this.getTorrentUrl(file, baseUrlHttp), | 1413 | href: this.getTorrentUrl(file, baseUrlHttp), |
1414 | width: file.resolution | 1414 | height: file.resolution |
1415 | }) | 1415 | }) |
1416 | 1416 | ||
1417 | url.push({ | 1417 | url.push({ |
1418 | type: 'Link', | 1418 | type: 'Link', |
1419 | mimeType: 'application/x-bittorrent;x-scheme-handler/magnet', | 1419 | mimeType: 'application/x-bittorrent;x-scheme-handler/magnet', |
1420 | href: this.generateMagnetUri(file, baseUrlHttp, baseUrlWs), | 1420 | href: this.generateMagnetUri(file, baseUrlHttp, baseUrlWs), |
1421 | width: file.resolution | 1421 | height: file.resolution |
1422 | }) | 1422 | }) |
1423 | } | 1423 | } |
1424 | 1424 | ||