Skip to content

[YoutubeCommunityTabsBridge] Rename Community→Posts to fix broken bridge#4606

Merged
dvikan merged 7 commits intoRSS-Bridge:masterfrom
shaunlebron:youtube-posts-bridge-fix
Aug 4, 2025
Merged

[YoutubeCommunityTabsBridge] Rename Community→Posts to fix broken bridge#4606
dvikan merged 7 commits intoRSS-Bridge:masterfrom
shaunlebron:youtube-posts-bridge-fix

Conversation

@shaunlebron
Copy link
Contributor

Fixes #4604. The community tab was renamed to “posts”, causing the bridge to fail.

Context on rename: https://support.google.com/youtube/thread/321825573?hl=en

The Community tab is becoming the Posts tab: To make things clear, we’re giving the “Community” tab a new name: “Posts.” The tab will work just as it does today, just with a new name. Creators can still share updates and announcements via posts and viewers can engage by commenting on those posts like they always have!

I fixed the tab lookup, and renamed the functions, file, and references to match the new “Posts” name.

Tested locally with:

php -S 127.0.0.1:9001

Verified with:
http://localhost:9001/?action=display&bridge=YouTubePostsTabBridge&context=By+channel+ID&channel=UCLYut6IxIvx5PxwUWMXJz8g&format=html

@github-actions
Copy link

github-actions bot commented Jul 7, 2025

Pull request artifacts

Bridge Context Status
YouTubeCommunityTab 1 By channel ID (current) Bridge returned error 0! (20304)
Type: ErrorException
Message: Undefined property: stdClass::$header
YouTubeCommunityTab 1 By channel ID (pr) ✔️
YouTubeCommunityTab 2 By username (current) Bridge returned error 0! (20304)
Type: ErrorException
Message: Undefined property: stdClass::$c4TabbedHeaderRenderer
YouTubeCommunityTab 2 By username (pr) ✔️

last change: Monday 2025-08-04 05:21:40

@shaunlebron
Copy link
Contributor Author

@Mar-Koeh
Copy link
Contributor

Not sure how to fix the errors in the above comment, but they seem to work locally for me:

That's from this line:

$this->feedName = $json->header->c4TabbedHeaderRenderer->title;

There, the result of extractJson is used. This function just does a preg_match for a certain piece of JSON and parses it. If the JSON-parsing fails, then there should be a different error. So it looks like JSON is successfully parsed. I had a look at it in curl. Looks good. However, there c4TabbedHeaderRenderer doesn't occur in the JSON at all. Hence, this line fails. When I looked at it, there were multiple places containing the title:

  • $json->header->pageHeaderRenderer->pageTitle
  • $json->metadata->channelMetadataRenderer->title
  • $json->microformat->microformatDataRenderer->title

The question is why the said line didn't fail when you tried it. I have two theories:

  • YouTube doesn't always output the same JSON. Might be A/B-testing. Might be the guessed device type. Might be based on your location.
  • Your PHP version or config doesn't throw an error but just a warning while using NULL.

You could test this by checking whether your feed has a feedTitle.

Maybe the following line could fix it. It uses the null coalescing operator, which doesn't emit a warning but just attempts the next expression if the previous one would have been NULL.

$this->feedName = $json->header->c4TabbedHeaderRenderer->title ?? $json->header->pageHeaderRenderer->pageTitle ?? $json->metadata->channelMetadataRenderer->title ?? $json->microformat->microformatDataRenderer->title ?? '';

With this line, all currently known locations of the title would be checked and the empty string would be the fallback if none worked.

@shaunlebron
Copy link
Contributor Author

Thanks @Mar-Koeh that seemed to work. The remaining errors are from a file that no longer exists after this PR renamed it.

@dvikan
Copy link
Contributor

dvikan commented Aug 3, 2025

Can you please not rename the class? The fix itself is nice and will resolves issues for existing feeds

also

FILE: /home/runner/work/rss-bridge/rss-bridge/bridges/YouTubePostsTabBridge.php
-------------------------------------------------------------------------------
FOUND 4 ERRORS AFFECTING 4 LINES
-------------------------------------------------------------------------------
 76 | ERROR | [x] Expected 1 space before "??"; newline found
 77 | ERROR | [x] Expected 1 space before "??"; newline found
 78 | ERROR | [x] Expected 1 space before "??"; newline found
 79 | ERROR | [x] Expected 1 space before "??"; newline found
-------------------------------------------------------------------------------
PHPCBF CAN FIX THE 4 MARKED SNIFF VIOLATIONS AUTOMATICALLY
-------------------------------------------------------------------------------

Time: 33.27 secs; Memory: 46.01MB

@dvikan
Copy link
Contributor

dvikan commented Aug 3, 2025

sorry strict linter rules

@shaunlebron
Copy link
Contributor Author

@dvikan Do you prefer I also not rename the functions and comments to reflect the new tab name?

@dvikan
Copy link
Contributor

dvikan commented Aug 3, 2025

goahead and rename everything you want except class name

@shaunlebron shaunlebron changed the title [YoutubePostsTabsBridge] Rename Community→Posts to fix broken bridge [YoutubeCommunityTabsBridge] Rename Community→Posts to fix broken bridge Aug 4, 2025
@shaunlebron
Copy link
Contributor Author

being on php 7 not 8 and the strict linter made the regression fix a bit ugly, but it works and should be good now

@dvikan dvikan merged commit aba3884 into RSS-Bridge:master Aug 4, 2025
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[YoutubeCommunityTabBridge] broken, can’t find community tab

3 participants