-
-
Notifications
You must be signed in to change notification settings - Fork 866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for RSS media enclosures in feeds #4442
Conversation
crates/routes/src/feeds.rs
Outdated
enclosure.set_length("0".to_string()); | ||
enclosure | ||
}); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use post.url_content_type
instead which was recently added. For length you might as well leave the default value (empty string), probably causes less confusion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback, I switched to post.url_content_type
but left the 0
as its from the specification:
When an enclosure's size cannot be determined, a publisher should use a length of 0.
https://www.rssboard.org/rss-profile#element-channel-item-enclosure
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its still using mime_guess, did you forget to push your changes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah sorry I misunderstood you, I just pushed a commit to make proper use of it, let me know what you think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, run cargo +nightly fmt
to pass lint.
Thank you! |
Until now the generated RSS feeds would not include a media enclosure if the post in question contains a link to a media file.
Adding this allows for RSS readers to display the media content directly inside of the item instead of just the link.
In order to specify an enclosure we need to give the MIME type of the media. As we cannot fetch the media we just use the url in order to guess it. If it doesn't work we specify it as octet stream which is a universal fallback.
Please let me know if you have any feedback.
Specification: