TeamNewPipe / TeamNewPipe/NewPipeExtractor
[YouTube] Improve lockup view model metadata extraction
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2k
- Forks
- 602
- Avg merge
- 3d 6h
- Merged PRs (30d)
- 6
Description
The metadata in the lockup view model is distributed across 2/3 rows and possibly there are multiple items per row. As of #1320 the YouTubeStreamInfoItemLockupExtractor accesses specific rows and columns by index, expecting to always find the same piece of data (uploader name, view count, upload date) in the same place.
The following was originally posted by @Stypox in https://github.com/TeamNewPipe/NewPipeExtractor/pull/1320#discussion_r2205778179
Can we trust the indices to be stable? I guess we can't do much better anyway, so let's try like this for now. If it creates problems, we can always use other ways to detect the right metadata parts in the future, e.g.:
- the uploader name object has "attachmentRuns" and "styleRuns" attached to it, which view count and upload date don't have
- the view count contains the "views" string or the "watching" string (for lives)
- the remaining item is the upload date
See here
[
{
"metadataParts": [
{
"text": {
"content": "Justin Bieber",
"styleRuns": [
{
"startIndex": 13,
"styleRunExtensions": {
"styleRunColorMapExtension": {
"colorMap": [
{
"key": "USER_INTERFACE_THEME_LIGHT",
"value": 4284506208
},
{
"key": "USER_INTERFACE_THEME_DARK",
"value": 4289374890
}
]
}
}
}
],
"attachmentRuns": [
{
"startIndex": 13,
"length": 0,
"element": {
"type": {
"imageType": {
"image": {
"sources": [
{
"clientResource": {
"imageName": "AUDIO_BADGE"
},
"width": 14,
"height": 14
}
]
}
}
},
"properties": {
"layoutProperties": {
"height": {
"value": 14,
"unit": "DIMENSION_UNIT_POINT"
},
"width": {
"value": 14,
"unit": "DIMENSION_UNIT_POINT"
},
"margin": {
"left": {
"value": 4,
"unit": "DIMENSION_UNIT_POINT"
}
}
}
}
},
"alignment": "ALIGNMENT_VERTICAL_CENTER"
}
]
}
}
]
},
{
"metadataParts": [
{
"text": {
"content": "157M views"
}
},
{
"text": {
"content": "5 years ago"
}
}
]
},
{
"badges": [
{
"badgeViewModel": {
"badgeText": "Free with ads",
"badgeStyle": "BADGE_COMMERCE",
"trackingParams": "COcBENTEDBgBIhMIs6r8_ZS9jgMVOxYGAB1LCied"
}
},
{
"badgeViewModel": {
"badgeText": "T",
"badgeStyle": "BADGE_DEFAULT",
"trackingParams": "COcBENTEDBgBIhMIs6r8_ZS9jgMVOxYGAB1LCied"
}
}
]
}
]
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with YouTubeStreamInfoItemLockupExtractor and inspect how it reads metadata rows and columns from the lockup view-model response. Use the JSON example in this issue to compare the uploader, view-count, and upload-date entries, then make the extraction identify those parts reliably rather than relying only on fixed indices. Done means the three metadata values remain correctly identified when rows contain multiple items or change order.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100