mirror of
https://git.sr.ht/~cadence/cloudtube
synced 2026-03-02 10:41:36 +00:00
fallback to number if text format is not available for counts
e.g. subscriber count, view count
This commit is contained in:
parent
b58f1515eb
commit
6186be0a13
4 changed files with 41 additions and 5 deletions
|
|
@ -14,6 +14,9 @@ module.exports = [
|
|||
const subscribed = user.isSubscribed(id)
|
||||
const instanceOrigin = settings.instance
|
||||
// normalise info, apply watched status
|
||||
if (!data.second__subCountText && data.subCount) {
|
||||
data.second__subCountText = converters.subscriberCountToText(data.subCount)
|
||||
}
|
||||
const watchedVideos = user.getWatchedVideos()
|
||||
if (data.latestVideos) {
|
||||
data.latestVideos.forEach(video => {
|
||||
|
|
|
|||
10
api/video.js
10
api/video.js
|
|
@ -47,11 +47,9 @@ async function renderVideo(videoPromise, {user, id, instanceOrigin}, locals = {}
|
|||
if (!format.second__height && format.resolution) format.second__height = +format.resolution.slice(0, -1)
|
||||
if (!format.second__order) format.second__order = formatOrder(format)
|
||||
}
|
||||
// process length text
|
||||
// process length text and view count
|
||||
for (const rec of video.recommendedVideos) {
|
||||
if (!rec.second__lengthText && rec.lengthSeconds > 0) {
|
||||
rec.second__lengthText = converters.lengthSecondsToLengthText(rec.lengthSeconds)
|
||||
}
|
||||
converters.normaliseVideoInfo(rec)
|
||||
}
|
||||
// get subscription data
|
||||
const subscribed = user.isSubscribed(video.authorId)
|
||||
|
|
@ -63,6 +61,10 @@ async function renderVideo(videoPromise, {user, id, instanceOrigin}, locals = {}
|
|||
rec.watched = watchedVideos.includes(rec.videoId)
|
||||
}
|
||||
}
|
||||
// normalise view count
|
||||
if (!video.second__viewCountText && video.viewCount) {
|
||||
video.second__viewCountText = converters.viewCountToText(video.viewCount)
|
||||
}
|
||||
return render(200, "pug/video.pug", Object.assign(locals, {video, subscribed, instanceOrigin}))
|
||||
} catch (e) {
|
||||
// show an appropriate error message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue