1
0
Fork 0
mirror of https://git.sr.ht/~cadence/cloudtube synced 2026-03-02 10:41:36 +00:00

Rebuild second__lengthText if needed

This commit is contained in:
Cadence Ember 2020-10-06 23:43:44 +13:00
parent d5d02bcef9
commit 5c3a4df209
No known key found for this signature in database
GPG key ID: BC1C2C61CF521B17
2 changed files with 16 additions and 0 deletions

View file

@ -3,6 +3,7 @@ const {render} = require("pinski/plugins")
const db = require("../utils/db")
const {getToken, getUser} = require("../utils/getuser")
const pug = require("pug")
const converters = require("../utils/converters")
class InstanceError extends Error {
constructor(error, identifier) {
@ -50,6 +51,11 @@ module.exports = [
if (!format.second__height && format.resolution) format.second__height = +format.resolution.slice(0, -1)
if (!format.second__order) format.second__order = formatOrder(format)
}
for (const rec of video.recommendedVideos) {
if (!rec.second__lengthText && rec.lengthSeconds > 0) {
rec.second__lengthText = converters.lengthSecondsToLengthText(rec.lengthSeconds)
}
}
const subscribed = user.isSubscribed(video.authorId)
return render(200, "pug/video.pug", {video, subscribed})
} catch (e) {