Skip to content
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

Merged
merged 2 commits into from
Feb 13, 2024
Merged

Conversation

Lcchy
Copy link
Contributor

@Lcchy Lcchy commented Feb 9, 2024

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:

enclosure.set_length("0".to_string());
enclosure
});
}
Copy link
Member

@Nutomic Nutomic Feb 12, 2024

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.

Copy link
Contributor Author

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

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Member

@dessalines dessalines left a 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.

@Nutomic Nutomic merged commit 8a6a86c into LemmyNet:main Feb 13, 2024
1 check passed
@Nutomic
Copy link
Member

Nutomic commented Feb 13, 2024

Thank you!

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.

None yet

3 participants