Skip to content

Commit 737dcf9

Browse files
committed
Add support for PC2.0 value-for-value.
1 parent 93a7941 commit 737dcf9

File tree

7 files changed

+58
-30
lines changed

7 files changed

+58
-30
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.6.4
2+
3+
- Add support for PC2.0 `<podcast:value>` tag.
4+
15
## 0.6.3
26

37
- Bug fix: Handle lookup failures when fetching iTunes charts.

example/podcast_search_example.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ void main() async {
88
var search = Search();
99

1010
/// Search for podcasts with 'widgets' in the title.
11-
var results = await search.search('widgets', country: Country.unitedKingdom, limit: 10);
11+
var results =
12+
await search.search('widgets', country: Country.unitedKingdom, limit: 10);
1213

1314
/// List the name of each podcast found.
1415
for (var result in results.items) {

lib/src/model/chapter.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,24 @@
11
// Copyright (c) 2019 Ben Hills and the project contributors. Use of this source
22
// code is governed by a MIT license that can be found in the LICENSE file.
33

4+
/// This class represents and individual chapter within a podcast episode.
45
class Chapter {
6+
/// The optional title of the chapter.
57
final String title;
8+
9+
/// Optional image artwork for the chapter.
610
final String imageUrl;
11+
12+
/// Optional HTML link for the chapter.
713
final String url;
14+
15+
/// If false, this is considered a silent chapter and should not appear in a chapter selector.
816
final bool toc;
17+
18+
/// The start time of this chapter in seconds.
919
final double startTime;
20+
21+
/// Optional end time of this chapter in seconds.
1022
final double endTime;
1123

1224
Chapter({

lib/src/model/chapters.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,23 @@
44
import 'package:podcast_search/src/model/chapter.dart';
55
import 'package:podcast_search/src/model/chapter_headers.dart';
66

7+
/// This class represents a set of PC2.0 [chapters](https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#chapters).
8+
/// A chapter is a way to split a podcast episode into a series of chapters with a start and (optional) end time, and optional additions
9+
/// such as separate artwork and HTML links.
710
class Chapters {
11+
/// The url of a chapter file.
812
final String url;
13+
14+
/// The mime type of the chapter file (JSON preferred).
915
final String type;
16+
17+
/// Have we loaded a set of chapters?
1018
var loaded = false;
19+
20+
/// Chapter headers.
1121
var headers = ChapterHeaders();
22+
23+
/// A list of individual chapters.
1224
var chapters = <Chapter>[];
1325

1426
Chapters({

lib/src/model/podcast.dart

Lines changed: 18 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ import 'dart:async';
55
import 'dart:convert';
66
import 'dart:io';
77

8-
import 'package:podcast_search/src/model/value.dart';
98
import 'package:podcast_search/src/model/value_recipient.dart';
109
import 'package:rss_dart/dart_rss.dart';
1110
import 'package:dio/dio.dart';
1211
import 'package:podcast_search/podcast_search.dart';
1312
import 'package:podcast_search/src/model/chapter.dart';
1413
import 'package:podcast_search/src/model/chapter_headers.dart';
15-
import 'package:podcast_search/src/model/funding.dart';
1614
import 'package:podcast_search/src/model/locked.dart';
1715
import 'package:podcast_search/src/model/person.dart';
1816
import 'package:podcast_search/src/search/base_search.dart';
@@ -204,17 +202,15 @@ class Podcast {
204202
if (v?.recipients != null) {
205203
for (var r in v!.recipients!) {
206204
if (r != null) {
207-
recipients.add(
208-
ValueRecipient(
209-
name: r.name,
210-
customKey: r.customKey,
211-
type: r.type,
212-
address: r.address,
213-
split: r.split,
214-
customValue: r.customValue,
215-
fee: r.fee,
216-
)
217-
);
205+
recipients.add(ValueRecipient(
206+
name: r.name,
207+
customKey: r.customKey,
208+
type: r.type,
209+
address: r.address,
210+
split: r.split,
211+
customValue: r.customValue,
212+
fee: r.fee,
213+
));
218214
}
219215
}
220216
}
@@ -517,17 +513,15 @@ class Podcast {
517513
if (v?.recipients != null) {
518514
for (var r in v!.recipients!) {
519515
if (r != null) {
520-
recipients.add(
521-
ValueRecipient(
522-
name: r.name,
523-
customKey: r.customKey,
524-
type: r.type,
525-
address: r.address,
526-
split: r.split,
527-
customValue: r.customValue,
528-
fee: r.fee,
529-
)
530-
);
516+
recipients.add(ValueRecipient(
517+
name: r.name,
518+
customKey: r.customKey,
519+
type: r.type,
520+
address: r.address,
521+
split: r.split,
522+
customValue: r.customValue,
523+
fee: r.fee,
524+
));
531525
}
532526
}
533527
}

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, parsing podcast RSS feeds and obtaining episodes details. Supports iTunes and PodcastIndex directories, and newer features such as chapters, transcripts, funding and persons.
33

4-
version: 0.6.3
4+
version: 0.6.4
55
homepage: https://github.com/amugofjava/podcast_search
66

77
environment:

test/podcast_load_test.dart

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,25 +7,30 @@ import 'package:test/test.dart';
77
void main() {
88
group('Podcast load test', () {
99
test('Load podcast', () async {
10-
var podcast = await Podcast.loadFeed(url: 'https://podcasts.files.bbci.co.uk/p06tqsg3.rss');
10+
var podcast = await Podcast.loadFeed(
11+
url: 'https://podcasts.files.bbci.co.uk/p06tqsg3.rss');
1112

1213
expect(podcast.title, 'Forest 404');
1314
});
1415

1516
test('Load invalid podcast - unknown host', () async {
16-
await expectLater(() => Podcast.loadFeed(url: 'https://pc.files.bbci.co.uk/p06tqsg3.rss'),
17+
await expectLater(
18+
() =>
19+
Podcast.loadFeed(url: 'https://pc.files.bbci.co.uk/p06tqsg3.rss'),
1720
throwsA(const TypeMatcher<PodcastFailedException>()));
1821
});
1922

2023
test('Load invalid podcast - invalid RSS call 404', () async {
21-
await expectLater(() => Podcast.loadFeed(url: 'https://bbc.co.uk/abcdp06tqsg3.rss'),
24+
await expectLater(
25+
() => Podcast.loadFeed(url: 'https://bbc.co.uk/abcdp06tqsg3.rss'),
2226
throwsA(const TypeMatcher<PodcastFailedException>()));
2327
});
2428
});
2529

2630
group('Podcast local file load test', () {
2731
test('Load podcast', () async {
28-
var podcast = await Podcast.loadFeedFile(file: 'test_resources/podcast1.rss');
32+
var podcast =
33+
await Podcast.loadFeedFile(file: 'test_resources/podcast1.rss');
2934

3035
expect(podcast.title, 'Podcast Load Test 1');
3136
expect(podcast.description, 'Unit test podcast test 1');

0 commit comments

Comments
 (0)