7

I'm trying to obtain the list of podcasts episodes from the iTunes Search API. I'm able to make a call to the API and get back all podcast albums based on a search term:

https://itunes.apple.com/search?media=podcast&term=nerdcast

This returns the following json (cropped):

{
"resultCount": 20,
"results": [
    {
        "wrapperType": "track",
        "kind": "podcast",
        "collectionId": 381816509,
        "trackId": 381816509,
        "artistName": "Nerdcast",
        "collectionName": "Nerdcast",
        "trackName": "Nerdcast",
        "collectionCensoredName": "Nerdcast",
        "trackCensoredName": "Nerdcast",
        "collectionViewUrl": "https://itunes.apple.com/us/podcast/nerdcast/id381816509?mt=2&uo=4",
        "feedUrl": "http://jovemnerd.com.br/categoria/nerdcast/feed/",
        "trackViewUrl": "https://itunes.apple.com/us/podcast/nerdcast/id381816509?mt=2&uo=4",
        "artworkUrl30": "http://a5.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.30x30-50.jpg",
        "artworkUrl60": "http://a4.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.60x60-50.jpg",
        "artworkUrl100": "http://a1.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.100x100-75.jpg",
        "collectionPrice": 0,
        "trackPrice": 0,
        "trackRentalPrice": 0,
        "collectionHdPrice": 0,
        "trackHdPrice": 0,
        "trackHdRentalPrice": 0,
        "releaseDate": "2014-05-16T12:12:00Z",
        "collectionExplicitness": "notExplicit",
        "trackExplicitness": "notExplicit",
        "trackCount": 301,
        "country": "USA",
        "currency": "USD",
        "primaryGenreName": "Society & Culture",
        "radioStationUrl": "https://itunes.apple.com/station/idra.381816509",
        "artworkUrl600": "http://a2.mzstatic.com/us/r30/Podcasts/v4/e1/95/35/e1953536-8437-834e-eac8-01147ae11c9e/mza_3422052630315608394.600x600-75.jpg",
        "genreIds": [
            "1324",
            "26"
        ],
        "genres": [
            "Society & Culture",
            "Podcasts"
        ]
    },
.....

I'd like now to get all episodes from that first result. I've tried to do a lookup request using the collectionId, but it just returns back the same output as above instead of all podcasts from that collection.

https://itunes.apple.com/lookup?id=381816509&entity=podcast

From reading the documentation and some other posts this is how I believe it should work, but it doesn't. Is anyone able to help me out? Thanks.

Rafael Alencar
  • 250
  • 3
  • 7

2 Answers2

11

I think what you need to do is to take that feed URL and get the tracks from there directly

"feedUrl": "http://jovemnerd.com.br/categoria/nerdcast/feed/",

I suspect that the iTunes search API documentation and implementation contain caveats that are not written clearly out.

juhariis
  • 568
  • 8
  • 15
  • Question: is there a standard format that used by these feed URLs that can be parsed through some parser in a consistent way? – p0lAris Jan 21 '20 at 02:34
1

For me, this works. I use this code: https://github.com/ijanerik/PHP-iTunes-API/blob/master/README.md

foreach($results as $item){
$url = $item->feedUrl;
}
$xml = simplexml_load_file($url) or die("feed not loading");
print_r($xml);