我试图将Apple podcast的插曲id映射到RSS Feed中的特定播客条目。假设我有以下链接的情节 https:/podcasts.apple.comuspodcastthe-numberphile-podcastid1441474794?i=1000475383420。 于是 podcast_id=1441474794
和 episode_id=1000475383420
. 现在,我能够通过这段代码获得带有podcast id的RSS feed。
from urllib.request import urlopen
import json
import xmltodict
podcast_id = "1441474794"
ITUNES_URL = 'https://itunes.apple.com/lookup?id='
with urlopen(ITUNES_URL + podcast_id) as response:
res = json.load(response)
feedUrl = res['results'][0]['feedUrl']
print(feedUrl)
with urlopen(feedUrl) as response:
res = xmltodict.parse(response)
with open('res.json', "w") as f:
f.write(json.dumps(res))
这给了我一个JSON,里面有一些关于播客的一般信息 和一个包含所有剧集的数组。对于一个特定的情节,结果看起来像这样。
"item": [
{
"title": "The Parker Quiz - with Matt Parker",
"dc:creator": "Brady Haran",
"pubDate": "Thu, 21 May 2020 16:59:08 +0000",
"link": "https://www.numberphile.com/podcast/matt-parker-quiz",
"guid": {
"@isPermaLink": "false",
"#text": "5b2cf993266c07b1ca7a812f:5bd2f1a04785d353e1b39d76:5ec683354f70a700f9f04555"
},
"description": "some description here...",
"itunes:author": "Numberphile Podcast",
"itunes:subtitle": "Matt Parker takes a quiz prepared by Brady. The YouTube version of this quiz contains a few visuals at https://youtu.be/hMwQwppzrys",
"itunes:explicit": "no",
"itunes:duration": "00:55:34",
"itunes:image": {
"@href": "https://images.squarespace-cdn.com/content/5b2cf993266c07b1ca7a812f/1541821254439-PW3116VHYDC1Y3V7GI0A/podcast_square2_2000x2000.jpg?format=1500w&content-type=image%2Fjpeg"
},
"itunes:title": "The Parker Quiz - with Matt Parker",
"enclosure": {
"@url": "https://traffic.libsyn.com/secure/numberphile/numberphile_parker_quiz.mp3",
"@type": "audio/mpeg"
},
"media:content": {
"@url": "https://traffic.libsyn.com/secure/numberphile/numberphile_parker_quiz.mp3",
"@type": "audio/mpeg",
"@isDefault": "true",
"@medium": "audio",
"media:title": {
"@type": "plain",
"#text": "The Parker Quiz - with Matt Parker"
}
}
},
...]
这个... episode_id=1000475383420
没有出现在任何地方的RSS feed响应,所以没有办法找到这个id所对应的剧集。有没有一个干净的方法来找到的ID的情节吗? 例如,苹果api调用与情节的ID,这将给我关于情节的信息,然后我可以匹配的信息与RSS饲料条目。
在podcast的RSS feed中,用来唯一标识一集的elementtag是:"/podcast.apple.comuspodcastthe-numberphile-podcast"。
<guid>
以下是一些相关信息 苹果播客连接RSS指南 这可能是有帮助的。
如果你能得到一个掌握的 <guid>
那么你就可以从feed中访问该剧集。
一个不太可靠的选择是尝试 <link>
标签的情节。在你提供的那个URL上,有一个名为 "Episode Website "的链接,在页面的末尾。
这也可能让你在RSS订阅中得到一个独特的密钥。但它可能不会像你期望的那样在所有情况下工作。即说,播客RSS的创建者和发布者只是把相同的URL在每一集,而不是一个独特的URL每集。