Parse channel handle and display it on channel page and API#5640
Parse channel handle and display it on channel page and API#5640Fijxu wants to merge 5 commits intoiv-org:masterfrom
Conversation
It also fixes some inconsistencies with the CSS and HTML that was introduced in iv-org#5617 but I didn't really noticed about because it looked fine in the Invidious frontend. I also added a comment about the `break` statement in the metadata_rows row iteration because I didn't get why that `break` was there. Closes iv-org#5638
Co-authored-by: ChunkyProgrammer <78101139+ChunkyProgrammer@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds channel handle parsing and display functionality to Invidious, addressing issue #5638. It extracts the channel handle (e.g., @username) from YouTube's metadata and displays it on the channel page alongside the channel name and pronouns. The change also exposes the handle in the API response.
Changes:
- Parses channel handle from YouTube metadata and stores it in the AboutChannel record
- Displays channel handle on the channel page below the channel name
- Adds channel handle to the API response for channel endpoints
- Refactors CSS classes to match the new HTML structure
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.
| File | Description |
|---|---|
| src/invidious/channels/about.cr | Adds author_handle field to AboutChannel record and parsing logic to extract it from metadata |
| src/invidious/routes/api/v1/channels.cr | Adds authorHandle field to the JSON API response |
| src/invidious/views/components/channel_info.ecr | Updates HTML template to display channel handle with restructured CSS classes |
| assets/css/default.css | Updates CSS selectors to match new HTML structure |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
why rename |
Just to be consistent by how is set in |
| channel_handle_part = metadata_parts.try &.as_a.find { |i| i.dig?("text", "content").try &.as_s.includes?("@") } | ||
| if !channel_handle_part.nil? |
There was a problem hiding this comment.
You can combine that in a single if statement:
| channel_handle_part = metadata_parts.try &.as_a.find { |i| i.dig?("text", "content").try &.as_s.includes?("@") } | |
| if !channel_handle_part.nil? | |
| if channel_handle_part = metadata_parts.try &.as_a.find { |i| i.dig?("text", "content").try &.as_s.includes?("@") } |
There was a problem hiding this comment.
(And similarly, you can do this to the other if statements in this .each loop)
It also fixes some inconsistencies with the CSS and HTML that was introduced in #5617 but I didn't really noticed about because it looked fine in the Invidious frontend.
I also added a comment about the
breakstatement in themetadata_rowsrow iteration because I didn't get why thatbreakwas there in the first place.Closes #5638
Looks like this in the Invidious frontend (with borders enabled just to see each element sizes and limits):
The API looks like this: