Parse metadata lines on tv feeds

This commit is contained in:
Brahim Hadriche committed 2025-05-15 21:50:40 -04:00
1 parent 4fc44becd2
commit 227a5157a5
8 files changed
+82 -12

No files matched your search

@@ -43,5 +43,6 @@
<field id="statsText" type="string" />
<!-- videoId is Mix continuation (playlistId starts with "RD") -->
<field id="videoId" type="string" />
<field id="lines" type="stringarray" />
</interface>
</component>
@@ -22,5 +22,6 @@
<field id="title" type="string" />
<field id="videoId" type="string" />
<field id="viewCountText" type="string" />
<field id="lines" type="stringarray" />
</interface>
</component>
@@ -975,6 +975,17 @@ namespace Innertube
end if
end if
renderedLines = []
lines = ObjectUtils.Dig(nodeData, ["metadata", "tileMetadataRenderer", "lines"])
if IsArray(lines)
for each line in lines
if not IsAssociativeArray(line)
continue for
end if
renderedLines.Push(ParseLineRenderer(line["lineRenderer"]))
end for
end if
video = {
"type": "video"
"videoId": videoId
@@ -983,6 +994,7 @@ namespace Innertube
"lengthText": lengthText
"liveNow": liveNow
"isUpcoming": isUpcoming
"lines": renderedLines
}
PushFeedItem(video, context)
@@ -1007,12 +1019,24 @@ namespace Innertube
end for
end if
renderedLines = []
lines = ObjectUtils.Dig(nodeData, ["metadata", "tileMetadataRenderer", "lines"])
if IsArray(lines)
for each line in lines
if not IsAssociativeArray(line)
continue for
end if
renderedLines.Push(ParseLineRenderer(line["lineRenderer"]))
end for
end if
playlist = {
"type": "playlist"
"playlistId": playlistId
"title": ParseText(ObjectUtils.Dig(nodeData, ["metadata", "tileMetadataRenderer", "title"]))
"playlistThumbnail": ObjectUtils.Dig(nodeData, ["header", "tileHeaderRenderer", "thumbnail", "thumbnails", 0, "url"])
"videoCountText": videoCountText
"lines": renderedLines
}
PushFeedItem(playlist, context)
@@ -51,6 +51,7 @@ namespace InvidiousContent
SetIfExists(node, "videoId", item, "videoId")
node.viewCountText = VideoGetViewCountText(item)
SetIfExists(node, "index", item, "index")
SetIfExists(node, "lines", item, "lines")
return node
end function
@@ -77,6 +78,7 @@ namespace InvidiousContent
SetIfExists(node, "updated", item, "updated")
node.updatedText = PlaylistGetUpdatedText(item)
SetIfExists(node, "statsText", item, "statsText")
SetIfExists(node, "lines", item, "lines")
if item.videos <> invalid
childCount = node.getChildCount()
@@ -1,4 +1,5 @@
import "pkg:/source/utils/Types.bs"
import "pkg:/source/utils/StringUtils.bs"
function Init()
m.videoCountRect = m.top.FindNode("videoCountRect")
@@ -13,9 +14,24 @@ function OnContentSet() as void
end if
m.top.title = content.title
lines = content.lines
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.top.author = content._author
m.top.updated = content.updatedText
author = content._author
if StringUtils.IsNullOrEmpty(author)
if IsArray(lines) and lines.Count() > 0
author = lines[0]
end if
end if
m.top.author = author
updatedText = content.updatedText
if StringUtils.IsNullOrEmpty(updatedText)
if IsArray(lines) and lines.Count() > 1
updatedText = lines[1]
end if
end if
m.top.updated = updatedText
m.top.thumbnailUri = content.thumbnail
@@ -18,11 +18,20 @@ function OnContentSet() as void
end if
m.top.title = content.title
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
m.top.author = content._author
lines = content.lines
' NOTE: "_author" not "author". See PlaylistContentNode.xml for explanation.
author = content._author
if StringUtils.IsNullOrEmpty(author)
if IsArray(lines) and lines.Count() > 0
author = lines[0]
end if
end if
m.top.author = author
viewCountDate = ""
if content.isUpcoming = true
m.top.viewCountDate = content.premiereTimestampText
viewCountDate = content.premiereTimestampText
else
publishedText = content.publishedText
viewCountText = content.viewCountText
@@ -33,8 +42,14 @@ function OnContentSet() as void
end if
label += viewCountText
m.top.viewCountDate = label
viewCountDate = label
end if
if StringUtils.IsNullOrEmpty(viewCountDate)
if IsArray(lines) and lines.Count() > 1
viewCountDate = lines[1]
end if
end if
m.top.viewCountDate = viewCountDate
m.top.thumbnailUri = content.thumbnail
@@ -12,6 +12,7 @@
export let videoCountText: string | undefined = undefined;
export let videos: any[] | undefined = undefined;
export let updated: number | undefined = undefined;
export let lines: string[] | undefined = undefined;
// svelte-ignore unused-export-let
export let type: string = undefined;
@@ -96,8 +97,10 @@
/>
<div class="card-body">
<h3 class="card-title text-base line-clamp-2 min-h-12">{title}</h3>
<div class="font-semibold">{author}</div>
<div>{getUpdatedText()}</div>
<div class="font-semibold">
{author || (lines?.length > 0 ? lines[0] : "")}
</div>
<div>{getUpdatedText() || (lines?.length > 1 ? lines[1] : "")}</div>
</div>
</div>
</button>
+12 -4
View File
@@ -18,6 +18,7 @@
export let lengthSeconds: number = undefined;
export let lengthText: string | undefined = undefined;
export let liveNow: boolean = undefined;
export let lines: string[] | undefined = undefined;
// svelte-ignore unused-export-let
export let type: string = undefined;
@@ -179,6 +180,13 @@
return trFn("1 minute ago");
}
}
function openChannelModal() {
if (!authorId) {
return;
}
channelModal.show();
}
</script>
<button
@@ -208,18 +216,18 @@
tabindex="0"
on:click={(e) => {
e.stopPropagation();
channelModal.show();
openChannelModal();
}}
on:keydown={(e) => {
if (e.key === "Enter" || e.key === " ") {
e.preventDefault();
channelModal.show();
openChannelModal();
}
}}
>
{author || ""}
{author || (lines?.length > 0 ? lines[0] : "")}
</span>
<div>{getViewCountDateText()}</div>
<div>{getViewCountDateText() || (lines?.length > 1 ? lines[1] : "")}</div>
</div>
</div>
</button>