luandersonn / iTunesPodcastFinder

iTunes Podcast Finder & RSS feed Parser

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

iTunes Podcast Finder

iTunes logo

iTunes Podcast Finder is a .NET Standard 2.0 library that allows you to search for podcasts through the iTunes API and get episodes of podcasts from the RSS feed. Get the Nuget package.

PM> Install-Package Luandersonn.iTunesPodcastFinder

Features

Usage

PodcastFinder finder = new PodcastFinder();

Search

// Default: retrieve 100 items using the US search
IEnumerable<Podcast> results = await finder.SearchPodcastsAsync("Games");
foreach (Podcast podcast in results)
{
    Debug.WriteLine($"Name = {podcast.Name}");
    Debug.WriteLine($"Editor = {podcast.Editor}");
    Debug.WriteLine($"Genre = {podcast.Genre}");
}		

Optimized search for another country

int maxItems = 30; // Min:1 - max:200
string country = "br" // Two-letter country code (ISO 3166-1 alpha-2)

// Results optimized for Brazil
IEnumerable<Podcast> results = await finder.SearchPodcastsAsync("Games", maxItems, country);
foreach (Podcast podcast in results)
{
    Debug.WriteLine($"Name = {podcast.Name}");
    Debug.WriteLine($"Editor = {podcast.Editor}");
    Debug.WriteLine($"Genre = {podcast.Genre}");
}

Get top podcasts

// Get the 100 most popular podcasts from the US in Games & Hobbies category
IEnumerable<Podcast> results = await finder.GetTopPodcastsAsync(PodcastGenre.GamesAndHobbies);
foreach (Podcast podcast in results)
{
    Debug.WriteLine($"Name = {podcast.Name}");
    Debug.WriteLine($"Editor = {podcast.Editor}");
    Debug.WriteLine($"Genre = {podcast.Genre}");
}

❗ WARNING: In this method, the resolution of the art images of the podcasts is 170x170 and the feedUrl is null, this is a behavior of the iTunes API!. To get better resolution images and feedUrl, use the GetPodcastAsync method with the iTunes ID

Get a podcast by iTunes ID

string iTunesID = "1200361736"; // ID from 'The Daily' Podcast

Podcast podcast = await finder.GetPodcastAsync(iTunesID);

Debug.WriteLine($"Name = {podcast.Name}");      // The Daily
Debug.WriteLine($"Editor = {podcast.Editor}");	// The New York Times
Debug.WriteLine($"Genre = {podcast.Genre}");    // News & Politics

You can get the iTunes ID with the pocast link from iTunes using the static method PodcastFinder.GetItunesID(iTunesLink) Podcast class now has iTunesId property.

IEnumerable<Podcast> brazilTopPodcasts = await finder.GetTopPodcastsAsync(PodcastGenre.All, 50, "br");
Podcast mostPopularPodcast = brazilTopPodcasts.First();

Podcast podcast = await finder.GetPodcastAsync(mostPopularPodcast.ItunesId);

Debug.WriteLine($"Name = {podcast.Name}");
Debug.WriteLine($"Editor = {podcast.Editor}");
Debug.WriteLine($"Genre = {podcast.Genre}");	

Get podcasts and episodes by RSS feed link

If you have a RSS feed URL of a podcast and want to get the episodes...

string feedUrl = "http://rss.art19.com/the-daily";
PodcastRequestResult result = await finder.GetPodcastEpisodesAsync(feedUrl);

Debug.WriteLine($"Podcast name = {result.Podcast.Name}");
foreach (PodcastEpisode episode in result.Episodes)
{
    Debug.WriteLine($"Episode number = {episode.EpisodeNumber}");
    Debug.WriteLine($"Title = {episode.Title}");
    Debug.WriteLine($"Summary = {episode.Summary}");
    Debug.WriteLine($"Published Date = {episode.PublishedDate}");
    // In some cases, the duration is not reported by the RSS feed.
    // In these scenarios, the 'Duration' value is "00:00:00"
    Debug.WriteLine($"Duration = {episode.Duration}");
}

Dependencies

Newtonsoft.Json 12.0.2

About

iTunes Podcast Finder & RSS feed Parser

License:MIT License


Languages

Language:C# 100.0%