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

Can't add enclosure to atom correctly #143

Open
BlackLotus opened this issue Nov 30, 2024 · 0 comments
Open

Can't add enclosure to atom correctly #143

BlackLotus opened this issue Nov 30, 2024 · 0 comments

Comments

@BlackLotus
Copy link

BlackLotus commented Nov 30, 2024

I'm probably doing something horribly wrong here, but if I generate an rss feed I can add enclosures with this code without any problems

fe.enclosure(url=original_image_url, length='0', type=f"image/{imgtype}")
fe.enclosure(url=proxy_image_url, length='0', type=f"image/{imgtype}")

When I generate the feed as rss

    rss_feed = fg.rss_str(pretty=True)                                                                                                                         

the last enclosure is shown as attachment/enclosure which is what I expected when I create an atom feed

    atom_feed = fg.atom_str(pretty=True)

I just get multiple link objects without any reference of them being an enclosure.
Here is example code to reproduce this behaviour

from feedgen.feed import FeedGenerator

fg = FeedGenerator()
fg.load_extension('podcast')

# Set required fields using the appropriate methods
fg.id('bla')
fg.title('a')
fg.link({'href': 'http://ponyhof.de'})  # Pass a dictionary with 'href' key
fg.description('http://ponyhof.de')
fg.podcast.itunes_category('Technology', 'Podcasting')

fe = fg.add_entry()
fe.id('http://lernfunk.de/media/654321/1/file.mp3')
fe.title('The First Episode')
fe.description('Enjoy our first episode.')
fe.enclosure('http://lernfunk.de/media/654321/1/file.mp3', 0, 'audio/mpeg')
fe.enclosure('http://lernfunk.de/media/654321/2/file.mp3', 0, 'audio/mpeg')

# Generate the RSS feed
rss_feed = fg.rss_str(pretty=True)
print(rss_feed)  # Optional: print the RSS feed to the console
fg.rss_file('podcast-rss.xml')
fg.atom_file('podcast-atom.xml')

Here is your documentation specifying that it should work https://python-feedgen.readthedocs.io/en/latest/api.entry.html#feedgen.entry.FeedEntry.enclosure
Here is the atom rfc specifying how it should look https://validator.w3.org/feed/docs/rfc4287.html

    <link rel="enclosure" type="audio/mpeg" length="1337"
     href="http://example.org/audio/ph34r_my_podcast.mp3"/>

please tell me I'm doing something wrong

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

No branches or pull requests

1 participant