Skip to content

Commit

Permalink
Add support for PC2.0 value-for-value.
Browse files Browse the repository at this point in the history
  • Loading branch information
amugofjava committed Dec 27, 2023
1 parent 93a7941 commit 737dcf9
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 30 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 0.6.4

- Add support for PC2.0 `<podcast:value>` tag.

## 0.6.3

- Bug fix: Handle lookup failures when fetching iTunes charts.
Expand Down
3 changes: 2 additions & 1 deletion example/podcast_search_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ 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) {
Expand Down
12 changes: 12 additions & 0 deletions lib/src/model/chapter.dart
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
// Copyright (c) 2019 Ben Hills and the project contributors. Use of this source
// code is governed by a MIT license that can be found in the LICENSE file.

/// This class represents and individual chapter within a podcast episode.
class Chapter {
/// The optional title of the chapter.
final String title;

/// Optional image artwork for the chapter.
final String imageUrl;

/// Optional HTML link for the chapter.
final String url;

/// If false, this is considered a silent chapter and should not appear in a chapter selector.
final bool toc;

/// The start time of this chapter in seconds.
final double startTime;

/// Optional end time of this chapter in seconds.
final double endTime;

Chapter({
Expand Down
12 changes: 12 additions & 0 deletions lib/src/model/chapters.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@
import 'package:podcast_search/src/model/chapter.dart';
import 'package:podcast_search/src/model/chapter_headers.dart';

/// This class represents a set of PC2.0 [chapters](https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#chapters).
/// 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
/// such as separate artwork and HTML links.
class Chapters {
/// The url of a chapter file.
final String url;

/// The mime type of the chapter file (JSON preferred).
final String type;

/// Have we loaded a set of chapters?
var loaded = false;

/// Chapter headers.
var headers = ChapterHeaders();

/// A list of individual chapters.
var chapters = <Chapter>[];

Chapters({
Expand Down
42 changes: 18 additions & 24 deletions lib/src/model/podcast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,12 @@ import 'dart:async';
import 'dart:convert';
import 'dart:io';

import 'package:podcast_search/src/model/value.dart';
import 'package:podcast_search/src/model/value_recipient.dart';
import 'package:rss_dart/dart_rss.dart';
import 'package:dio/dio.dart';
import 'package:podcast_search/podcast_search.dart';
import 'package:podcast_search/src/model/chapter.dart';
import 'package:podcast_search/src/model/chapter_headers.dart';
import 'package:podcast_search/src/model/funding.dart';
import 'package:podcast_search/src/model/locked.dart';
import 'package:podcast_search/src/model/person.dart';
import 'package:podcast_search/src/search/base_search.dart';
Expand Down Expand Up @@ -204,17 +202,15 @@ class Podcast {
if (v?.recipients != null) {
for (var r in v!.recipients!) {
if (r != null) {
recipients.add(
ValueRecipient(
name: r.name,
customKey: r.customKey,
type: r.type,
address: r.address,
split: r.split,
customValue: r.customValue,
fee: r.fee,
)
);
recipients.add(ValueRecipient(
name: r.name,
customKey: r.customKey,
type: r.type,
address: r.address,
split: r.split,
customValue: r.customValue,
fee: r.fee,
));
}
}
}
Expand Down Expand Up @@ -517,17 +513,15 @@ class Podcast {
if (v?.recipients != null) {
for (var r in v!.recipients!) {
if (r != null) {
recipients.add(
ValueRecipient(
name: r.name,
customKey: r.customKey,
type: r.type,
address: r.address,
split: r.split,
customValue: r.customValue,
fee: r.fee,
)
);
recipients.add(ValueRecipient(
name: r.name,
customKey: r.customKey,
type: r.type,
address: r.address,
split: r.split,
customValue: r.customValue,
fee: r.fee,
));
}
}
}
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, parsing podcast RSS feeds and obtaining episodes details. Supports iTunes and PodcastIndex directories, and newer features such as chapters, transcripts, funding and persons.

version: 0.6.3
version: 0.6.4
homepage: https://github.com/amugofjava/podcast_search

environment:
Expand Down
13 changes: 9 additions & 4 deletions test/podcast_load_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,30 @@ import 'package:test/test.dart';
void main() {
group('Podcast load test', () {
test('Load podcast', () async {
var podcast = await Podcast.loadFeed(url: 'https://podcasts.files.bbci.co.uk/p06tqsg3.rss');
var podcast = await Podcast.loadFeed(
url: 'https://podcasts.files.bbci.co.uk/p06tqsg3.rss');

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

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

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

group('Podcast local file load test', () {
test('Load podcast', () async {
var podcast = await Podcast.loadFeedFile(file: 'test_resources/podcast1.rss');
var podcast =
await Podcast.loadFeedFile(file: 'test_resources/podcast1.rss');

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

0 comments on commit 737dcf9

Please sign in to comment.