Skip to content

[YouTube] Add support for premieres in lockupViewModels#1361

Merged
Stypox merged 5 commits intoTeamNewPipe:devfrom
AudricV:yt_premieres-lockups-support
Oct 5, 2025
Merged

[YouTube] Add support for premieres in lockupViewModels#1361
Stypox merged 5 commits intoTeamNewPipe:devfrom
AudricV:yt_premieres-lockups-support

Conversation

@AudricV
Copy link
Copy Markdown
Member

@AudricV AudricV commented Aug 9, 2025

This PR adds support for upcoming premieres in video lockupViewModels. Their structure looks like the following sample for the en-GB interface language (with several fields not different than on regular videos and running livestreams omitted):

Details
{
  "lockupViewModel": {
    "contentImage": {
      "thumbnailViewModel": {
        "image": {},
        "overlays": [
          {
            "thumbnailOverlayBadgeViewModel": {
              "thumbnailBadges": [
                {
                  "thumbnailBadgeViewModel": {
                    "text": "Upcoming",
                    "badgeStyle": "THUMBNAIL_OVERLAY_BADGE_STYLE_DEFAULT",
                    "animationActivationTargetId": "VIDEO_ID",
                    "animationActivationEntityKey": "REDACTED",
                    "lottieData": {
                      "url": "https://www.gstatic.com/youtube/img/lottie/audio_indicator/audio_indicator_v2.json",
                      "settings": {
                        "loop": true,
                        "autoplay": true
                      }
                    },
                    "animatedText": "Now playing",
                    "animationActivationEntitySelectorType": "THUMBNAIL_BADGE_ANIMATION_ENTITY_SELECTOR_TYPE_PLAYER_STATE"
                  }
                }
              ],
              "position": "THUMBNAIL_OVERLAY_BADGE_POSITION_BOTTOM_END"
            }
          },
          {
            "thumbnailHoverOverlayToggleActionsViewModel": {
              "buttons": []
            }
          }
        ]
      }
    },
    "metadata": {
      "lockupMetadataViewModel": {
        "title": {
          "content": "VIDEO_TITLE"
        },
        "image": {
          "decoratedAvatarViewModel": {}
        },
        "metadata": {
          "contentMetadataViewModel": {
            "metadataRows": [
              {
                "metadataParts": [
                  {
                    "text": {
                      "content": "VIDEO_CHANNEL_NAME",
                      "styleRuns": [],
                      "attachmentRuns": []
                    }
                  }
                ]
              },
              {
                "metadataParts": [
                  {
                    "text": {
                      "content": "56 waiting"
                    }
                  },
                  {
                    "text": {
                      "content": "Premieres 14/08/2025, 13:00"
                    }
                  }
                ]
              }
            ],
            "delimiter": ""
          }
        },
        "menuButton": {}
      }
    },
    "contentId": "VIDEO_ID",
    "contentType": "LOCKUP_CONTENT_TYPE_VIDEO"
  }
}

@AudricV AudricV added bug Issue or PR is related to a bug YouTube Service, https://www.youtube.com/ labels Aug 9, 2025
@litetex
Copy link
Copy Markdown
Member

litetex commented Aug 9, 2025

Cool PR. Can we get a test for it? (maybe one that is mock only)

@AudricV AudricV force-pushed the yt_premieres-lockups-support branch from d0bffcd to 7673ea0 Compare August 9, 2025 21:58
@AudricV
Copy link
Copy Markdown
Member Author

AudricV commented Aug 9, 2025

The issue I see is breaking changes with premieres won't be detected. Free feel to find a way to reliably get them or to add a mock only test :)

}

// As we request a UTC offset of 0 minutes, we get the UTC date
return LocalDateTime.parse(trimmedTextUploadDate, PREMIERES_DATE_FORMATTER);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few lines above you write "This approach is language dependent"

I think parsing this might crash on different languages, so maybe add a try catch block here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not support other localizations than en-GB.

This is still interesting to do a try catch and throw a ParsingException when the date could not be parsed.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a try-catch

@Stypox Stypox force-pushed the yt_premieres-lockups-support branch from 5c66ca7 to 3c404e5 Compare October 5, 2025 11:48
Copy link
Copy Markdown
Member

@Stypox Stypox left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! I implemented the remaining suggestions, now this looks good to me. In particular:

  • I added mock tests, that load the JsonObject from file and pass it to the StreamInfoItemExtractor, and then there are a bunch of assertions checking the returned data. I obtained the JSON data by accessing the YouTube website on my PC.
  • I simplified the date handling code, so that getTextualUploadDate() returns the raw textual date as it's supposed to do, instead of first parsing it and then formatting it again. This way even if parsing fails, at least the textual date can act as a fallback.
  • I added a try-catch around date parsing as suggested in a review comment.

@Stypox Stypox merged commit 8dfb0d3 into TeamNewPipe:dev Oct 5, 2025
4 checks passed
@Stypox Stypox mentioned this pull request Oct 5, 2025
3 tasks
@AudricV AudricV deleted the yt_premieres-lockups-support branch October 5, 2025 15:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Issue or PR is related to a bug YouTube Service, https://www.youtube.com/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants