python-feedgen icon indicating copy to clipboard operation
python-feedgen copied to clipboard

AttributeError: 'PodcastExtension' object has no attribute 'itunes_duration'

Open Miloszun opened this issue 4 years ago • 2 comments

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.

Miloszun avatar Sep 10 '20 18:09 Miloszun

The library, as of 0.9.0, does not yet support itunes_duration.

limburgher avatar Sep 24 '21 21:09 limburgher

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

calpaterson avatar Sep 11 '22 15:09 calpaterson

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'

??

hanscees avatar Dec 11 '22 21:12 hanscees

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.

image

gftabor avatar Dec 16 '22 20:12 gftabor

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()

lkiesow avatar Dec 22 '23 10:12 lkiesow