Finding the URL for podcast feeds from an iTunes id. (iTMS API)

后端 未结 4 1294
小蘑菇
小蘑菇 2021-01-30 10:03

I\'m look at a way of turning an iTunes podcast id into the RSS feed that the podcast producer serves.

I\'m aware of the RSS generator, which can be used to generate a f

4条回答
  •  青春惊慌失措
    2021-01-30 10:11

    Through a combination of answers from these two questions, I have found a way to do what I want.

    Example of finding podcasts

    First: grab a list of podcasts from iTunes, using the RSS generator. I'm not sure how the query parameters work yet, but here is an RSS feed for top tech podcasts in the US.

    http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppodcasts/sf=143441/limit=25/genre=1318/xml
    
    • sf relates to country, and is optional. I would guess that this defaults to global if absent.
    • genre relates to genre, and is optional. I would guess that this defaults to "all genres" is absent.
    • limit is optional, and seems to default to 9.

    This gives you an Atom feed of podcasts. You'll need to do some sperlunking with XPath to get to the ITMS id of podcast, but you're looking for the numeric id contained in the URL found at the following XPath:

    /atom:feed/atom:entry/atom:link[@rel='alernate']/@href
    

    For example, the excellent JavaPosse has an id of 81157308.

    The Answer to the Question

    Once you have that id, you can get another document which will tell you the last episode, and the original feed URL. The catch here is that you need to use an iTunes user-agent to get this document.

    e.g.

    wget --user-agent iTunes/7.4.1 \
         --no-check-certificate \ 
         "https://buy.itunes.apple.com/WebObjects/MZFinance.woa/wa/com.apple.jingle.app.finance.DirectAction/subscribePodcast?id=81157308&wasWarnedAboutPodcasts=true"
    

    This is a plist containing some metadata about the podcast, including the feed URL.

    feedURLhttp://feeds.feedburner.com/javaposse
    

    The XPath for this could be something like:

    //key[@text='feedURL']/following-sibling::string/text()
    

    Disclaimer

    Not entirely sure how stable any of this is, or how legal it is. YMMV.

提交回复
热议问题