python-feedgen
python-feedgen copied to clipboard
AttributeError: 'PodcastExtension' object has no attribute 'itunes_duration'
I have the following code for rss feed generator:
import sys
from feedgen.feed import FeedGenerator
def generator():
fg = FeedGenerator()
fg.load_extension('podcast')
fg.title('xyz')
fg.link(href='https://something.coml', rel='alternate')
fg.language('en')
fg.podcast.itunes_category({"cat":"Leisure", "sub":"Games"})
fe = fg.add_entry()
fe = fg.podcast.itunes_duration('123')
fe.title('The First Episode')
fg.rss_str(pretty=True)
fg.rss_file('podcast.xml')
generator()
Also, I deleted categories that are irrelevant to the problem. For some reason, I get an AttributeError. I have literally no idea why this happens, the library is imported properly.
The library, as of 0.9.0, does not yet support itunes_duration.
The library, as of 0.9.0, does not yet support itunes_duration.
Yes it does:
https://github.com/lkiesow/python-feedgen/blob/ffe3e4d752ac76e23c879c35682c310c2b1ccb86/feedgen/ext/podcast_entry.py#L136
Here's some code I use elsewhere:
https://github.com/calpaterson/dircast/blob/a9c27572b38f9e5d22bce526b6d82196a749b019/dircast/feed.py#L10-L25
I have the same kind of error in extention media, see the question of today " please give an working example of media extention
AttributeError: 'MediaExtension' object has no attribute 'content'
AttributeError: 'MediaExtension' object has no attribute 'media_content'
??
I had similar issue and realized the problem. I assumed fe was a podcast_entry when you loaded the podcast extension and asked for a new entry. The OP's problem is they needed to do fe.podcast.itunes_duration
not fg.podcast.itunes_duration
and my problem had been trying fe.itunes_duration
.
Exactly. The fixed code would be something like:
import sys
from feedgen.feed import FeedGenerator
def generator():
fg = FeedGenerator()
fg.load_extension('podcast')
fg.title('xyz')
fg.link(href='https://something.coml', rel='alternate')
fg.language('en')
fg.description('...')
fg.podcast.itunes_category({"cat":"Leisure", "sub":"Games"})
fe = fg.add_entry()
fe.podcast.itunes_duration('123')
fe.title('The First Episode')
fg.rss_str(pretty=True)
fg.rss_file('podcast.xml')
generator()