从 iTunes id 中查找播客提要的 URL.(iTMS API) [英] Finding the URL for podcast feeds from an iTunes id. (iTMS API)

查看:119
本文介绍了从 iTunes id 中查找播客提要的 URL.(iTMS API)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一种将 iTunes 播客 ID 转换为播客制作人提供的 RSS 提要的方法.

我知道 RSS 生成器,它可用于生成指向播客的链接,但这些链接指向 HTML 页面.

如果您打开了 iTunes,您可以通过导出到 OPML 来手动导出播客列表,因此我们可以推测 iTunes 最终知道如何对它们进行解码(即它们不仅仅通过 iTMS 主机).

我查看了 Affiliate API 文档,其中提供了一些不错的 JSON 回来了.这为您提供了一个 collectionViewUrl,它与 RSS 生成器中给出的相同,顺便说一下,iTunes 链接生成器.它还为您提供 id,以及大量其他内容,包括未托管在火卫一上的预览音频文件.

此时,我正在寻找可以帮助我解决这个问题的任何内容,包括任何语言,无论是否为非官方语言.

(实际上,我更喜欢一些模糊支持的东西,在 Java 中,不涉及 HTML 抓取).

解决方案

通过来自 这些 两个 问题,我找到了一种方法来做我想做的事.

查找播客的示例

首先:使用 RSS 生成器从 iTunes 获取播客列表.我还不确定查询参数是如何工作的,但这里是美国顶级技术播客的 RSS 提要.

http://ax.itunes.apple.com/WebObjects/MZStoreServices.woa/ws/RSS/toppodcasts/sf=143441/limit=25/genre=1318/xml

  • sf 与国家有关,是可选的.如果不存在,我猜这默认为全局.
  • genre 与流派相关,是可选的.我猜这默认为所有类型"不存在.
  • limit 是可选的,似乎默认为 9.

这为您提供 Atom 播客提要.您需要对 XPath 进行一些解析以获取播客的 ITMS id,但您正在寻找包含在以下 XPath 中的 URL 中的数字 id:

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

比如优秀的JavaPosse的id是81157308.

问题的答案

获得该 ID 后,您可以获得另一个文档,该文档会告诉您最后一集以及原始提要 URL.这里的问题是您需要使用 iTunes 用户代理来获取此文档.

例如

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"

这是一个包含有关播客的一些元数据的 plist,包括提要 URL.

feedURLhttp://feeds.feedburner.com/javaposse

用于此的 XPath 可能类似于:

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

免责声明

不完全确定这其中的任何一个有多稳定,或者它有多合法.天啊.

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 feed of links to podcasts, but these links are to HTML pages.

If you have iTunes open, you can manually export the list of podcasts by exporting to OPML, so we can surmise that iTunes eventually knows how to decode them (i.e. they're not exclusively going through an iTMS host).

I have looked at the Affiliate API document which gives you some nice JSON back. This gives you a collectionViewUrl which is the same as the ones given in the RSS generator, and incidentally, the iTunes Link Generator. It also give you the id, and a whole load of other things including a preview audio file which is not hosted on the phobos.

At this point, I'm looking for anything that would help me solve this question, including any language, unofficial or not.

(in actual fact, I'd prefer something vaguely supported, and in Java, that didn't involve HTML scraping).

解决方案

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.

<key>feedURL</key><string>http://feeds.feedburner.com/javaposse</string>

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.

这篇关于从 iTunes id 中查找播客提要的 URL.(iTMS API)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆