mirror of
https://github.com/FreeTubeApp/FreeTube
synced 2025-01-25 19:30:24 +01:00
Small community post fixes (#3401)
* Small community post fixes * fix #3387 * Check if post is empty Co-authored-by: absidue <48293849+absidue@users.noreply.github.com> --------- Co-authored-by: absidue <48293849+absidue@users.noreply.github.com>
This commit is contained in:
parent
bc039cd1aa
commit
9612df70cc
@ -159,7 +159,9 @@ export async function invidiousGetCommunityPosts(channelId) {
|
||||
|
||||
function parseInvidiousCommunityData(data) {
|
||||
return {
|
||||
postText: data.contentHtml,
|
||||
// use #/ to support channel YT links.
|
||||
// ex post: https://www.youtube.com/post/UgkxMpGt1SVlHwA1afwqDr2DZLn-hmJJQqKo
|
||||
postText: data.contentHtml.replaceAll('href="/', 'href="#/'),
|
||||
postId: data.commentId,
|
||||
authorThumbnails: data.authorThumbnails.map(thumbnail => {
|
||||
thumbnail.url = youtubeImageUrlToInvidious(thumbnail.url)
|
||||
@ -179,6 +181,15 @@ function parseInvidiousCommunityAttachments(data) {
|
||||
return null
|
||||
}
|
||||
|
||||
// I've only seen this appear when a video was made private.
|
||||
// This is not currently supported on local api.
|
||||
if (data.error) {
|
||||
return {
|
||||
type: 'error',
|
||||
message: data.error
|
||||
}
|
||||
}
|
||||
|
||||
if (data.type === 'image') {
|
||||
return {
|
||||
type: data.type,
|
||||
@ -190,7 +201,7 @@ function parseInvidiousCommunityAttachments(data) {
|
||||
}
|
||||
|
||||
if (data.type === 'video') {
|
||||
data.videoThumbnails = data.videoThumbnails.map(thumbnail => {
|
||||
data.videoThumbnails = data.videoThumbnails?.map(thumbnail => {
|
||||
thumbnail.url = youtubeImageUrlToInvidious(thumbnail.url)
|
||||
return thumbnail
|
||||
})
|
||||
|
@ -679,13 +679,13 @@ export function parseLocalSubscriberCount(text) {
|
||||
* @param {import('youtubei.js/dist/src/parser/classes/BackstagePost').default} post
|
||||
*/
|
||||
export function parseLocalCommunityPost(post) {
|
||||
let replyCount = post.action_buttons.reply_button?.text ?? null
|
||||
let replyCount = post.action_buttons?.reply_button?.text ?? null
|
||||
if (replyCount !== null) {
|
||||
replyCount = parseLocalSubscriberCount(post?.action_buttons.reply_button.text)
|
||||
}
|
||||
|
||||
return {
|
||||
postText: post.content.text === 'N/A' ? '' : post.content.text,
|
||||
postText: post.content.isEmpty() ? '' : Autolinker.link(parseLocalTextRuns(post.content.runs, 16)),
|
||||
postId: post.id,
|
||||
authorThumbnails: post.author.thumbnails,
|
||||
publishedText: post.published.text,
|
||||
|
Loading…
x
Reference in New Issue
Block a user