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

后端 未结 4 1262
小蘑菇
小蘑菇 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:30

    To elaborate on @juhariis' answer, here's the basics of extracting the feed url from the json (python3):

    from urllib.request import urlopen
    from urllib.parse import urlparse
    import codecs
    import json
    
    podcast_url = 'https://itunes.apple.com/us/podcast/grow-big-always/id1060318873'
    ITUNES_URL = 'https://itunes.apple.com/lookup?id='
    parsed = urlparse(podcast_url)
    id = parsed.path.split('/')[-1][2:]
    reader = codecs.getreader('utf-8')
    with urlopen(ITUNES_URL + id) as response:
        feed = json.load(reader(response))['results'][0]['feedUrl']
    print(feed)
    

    Here's a script/module I made, that makes use of this: https://gist.github.com/theychx/f9fad123bef27bebac665847c7884cd9

提交回复
热议问题