Skip to content

Commit eaa03cf

Browse files
committed
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.
1 parent eec379c commit eaa03cf

File tree

5 files changed

+29
-14
lines changed

5 files changed

+29
-14
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 0.6.7
2+
3+
- Update example to handle null feed.
4+
- Default podcast image to take iTunes version if available and fallback to channel version to be consistent with episode image handling.
5+
16
## 0.6.6
27

38
- Minor bug fixes to the SRT parser.

README.md

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,30 @@ examples limit to 10 results and are set for the United Kingdom:
88
```dart
99
import 'package:podcast_search/podcast_search.dart';
1010
11-
main() async {
11+
// ignore_for_file: avoid_print
12+
void main() async {
1213
var search = Search();
1314
1415
/// Search for podcasts with 'widgets' in the title.
15-
var results = await search.search('widgets', country: Country.unitedKingdom, limit: 10);
16+
var results =
17+
await search.search('widgets', country: Country.unitedKingdom, limit: 10);
1618
1719
/// List the name of each podcast found.
1820
for (var result in results.items) {
1921
print('Found podcast: ${result.trackName}');
2022
}
2123
2224
/// Parse the first podcast.
23-
var podcast = await Podcast.loadFeed(url: results.items[0].feedUrl!);
25+
final feed = results.items[0].feedUrl;
2426
25-
/// Display episode titles.
26-
///
27-
for (var episode in podcast.episodes) {
28-
print('Episode title: ${episode.title}');
27+
/// It is possible to get back a podcast with a missing feed URL, so check that.
28+
if (feed != null) {
29+
var podcast = await Podcast.loadFeed(url: feed);
30+
31+
/// Display episode titles.
32+
for (var episode in podcast.episodes) {
33+
print('Episode title: ${episode.title}');
34+
}
2935
}
3036
3137
/// Find the top 10 podcasts in the UK.

example/podcast_search_example.dart

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,16 @@ void main() async {
1717
}
1818

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

22-
/// Display episode titles.
23-
///
24-
for (var episode in podcast.episodes) {
25-
print('Episode title: ${episode.title}');
22+
/// It is possible to get back a podcast with a missing feed URL, so check that.
23+
if (feed != null) {
24+
var podcast = await Podcast.loadFeed(url: feed);
25+
26+
/// Display episode titles.
27+
for (var episode in podcast.episodes) {
28+
print('Episode title: ${episode.title}');
29+
}
2630
}
2731

2832
/// Find the top 10 podcasts in the UK.

lib/src/model/podcast.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class Podcast {
245245
link: rssFeed.link,
246246
title: rssFeed.title,
247247
description: rssFeed.description,
248-
image: rssFeed.image?.url ?? rssFeed.itunes?.image?.href,
248+
image: rssFeed.itunes?.image?.href ?? rssFeed.image?.url,
249249
copyright: author,
250250
locked: locked,
251251
funding: funding,

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: podcast_search
22
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.
33

4-
version: 0.6.6
4+
version: 0.6.7
55
homepage: https://github.com/amugofjava/podcast_search
66

77
environment:

0 commit comments

Comments
 (0)