Skip to content

Commit

Permalink
Update example to handle null feed. Default podcast image to take iTu…
Browse files Browse the repository at this point in the history
…nes version if available and fallback to channel version to be consistent with episode image handling.
  • Loading branch information
amugofjava committed Jan 23, 2024
1 parent eec379c commit eaa03cf
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 14 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.6.7

- Update example to handle null feed.
- Default podcast image to take iTunes version if available and fallback to channel version to be consistent with episode image handling.

## 0.6.6

- Minor bug fixes to the SRT parser.
Expand Down
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,30 @@ examples limit to 10 results and are set for the United Kingdom:
```dart
import 'package:podcast_search/podcast_search.dart';
main() async {
// ignore_for_file: avoid_print
void main() async {
var search = Search();
/// Search for podcasts with 'widgets' in the title.
var results = await search.search('widgets', country: Country.unitedKingdom, limit: 10);
var results =
await search.search('widgets', country: Country.unitedKingdom, limit: 10);
/// List the name of each podcast found.
for (var result in results.items) {
print('Found podcast: ${result.trackName}');
}
/// Parse the first podcast.
var podcast = await Podcast.loadFeed(url: results.items[0].feedUrl!);
final feed = results.items[0].feedUrl;
/// Display episode titles.
///
for (var episode in podcast.episodes) {
print('Episode title: ${episode.title}');
/// It is possible to get back a podcast with a missing feed URL, so check that.
if (feed != null) {
var podcast = await Podcast.loadFeed(url: feed);
/// Display episode titles.
for (var episode in podcast.episodes) {
print('Episode title: ${episode.title}');
}
}
/// Find the top 10 podcasts in the UK.
Expand Down
14 changes: 9 additions & 5 deletions example/podcast_search_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ void main() async {
}

/// Parse the first podcast.
var podcast = await Podcast.loadFeed(url: results.items[0].feedUrl!);
final feed = results.items[0].feedUrl;

/// Display episode titles.
///
for (var episode in podcast.episodes) {
print('Episode title: ${episode.title}');
/// It is possible to get back a podcast with a missing feed URL, so check that.
if (feed != null) {
var podcast = await Podcast.loadFeed(url: feed);

/// Display episode titles.
for (var episode in podcast.episodes) {
print('Episode title: ${episode.title}');
}
}

/// Find the top 10 podcasts in the UK.
Expand Down
2 changes: 1 addition & 1 deletion lib/src/model/podcast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ class Podcast {
link: rssFeed.link,
title: rssFeed.title,
description: rssFeed.description,
image: rssFeed.image?.url ?? rssFeed.itunes?.image?.href,
image: rssFeed.itunes?.image?.href ?? rssFeed.image?.url,
copyright: author,
locked: locked,
funding: funding,
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: podcast_search
description: A library for searching for podcasts and parsing podcast RSS feeds. Supports iTunes and PodcastIndex directories, and newer features such as chapters and transcripts.

version: 0.6.6
version: 0.6.7
homepage: https://github.com/amugofjava/podcast_search

environment:
Expand Down

0 comments on commit eaa03cf

Please sign in to comment.