From 9737546704222e399dfdadadb6b6e105af591a75 Mon Sep 17 00:00:00 2001 From: Ben Hills Date: Wed, 27 Dec 2023 19:39:23 +0000 Subject: [PATCH] Add support for PC2.0 block tag. Release 0.6.5. --- CHANGELOG.md | 4 ++ README.md | 39 ++++++----------- lib/src/model/block.dart | 13 ++++++ lib/src/model/podcast.dart | 15 +++++++ pubspec.yaml | 4 +- test/podcast_load_test.dart | 24 +++++++++++ test_resources/podcast-no-block.rss | 67 +++++++++++++++++++++++++++++ test_resources/podcast1.rss | 3 ++ 8 files changed, 142 insertions(+), 27 deletions(-) create mode 100644 lib/src/model/block.dart create mode 100644 test_resources/podcast-no-block.rss diff --git a/CHANGELOG.md b/CHANGELOG.md index 9cd4b6e..a6b9411 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.6.5 + +- Add support for PC2.0 `` tag. + ## 0.6.4 - Add support for PC2.0 `` tag. diff --git a/README.md b/README.md index 8ea7239..b32abab 100644 --- a/README.md +++ b/README.md @@ -41,28 +41,17 @@ main() async { ### Podcasting 2.0 -- [x] Chapters -- [x] Funding -- [x] GUID -- [x] Locked -- [x] Person -- [x] Transcripts -- [ ] Alternate enclosure -- [ ] Block -- [ ] Episode -- [ ] Images -- [ ] Licence -- [ ] Live item -- [ ] Location -- [ ] Medium -- [ ] Podping -- [ ] Podroll -- [ ] Remote item -- [ ] Season -- [ ] Social interact -- [ ] Soundbite -- [ ] Trailer -- [ ] Update frequency -- [ ] Value -- [ ] Value time split - +- Block +- Chapters +- Funding +- GUID +- Locked +- Person +- Transcripts +- Value + +### iTunes + +- Author +- Episode +- Season diff --git a/lib/src/model/block.dart b/lib/src/model/block.dart new file mode 100644 index 0000000..f087315 --- /dev/null +++ b/lib/src/model/block.dart @@ -0,0 +1,13 @@ +// 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 a PC2.0 [block](https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#block) tag. +class Block { + final bool block; + String? id; + + Block({ + required this.block, + this.id, + }); +} diff --git a/lib/src/model/podcast.dart b/lib/src/model/podcast.dart index 2a37fec..be9264a 100644 --- a/lib/src/model/podcast.dart +++ b/lib/src/model/podcast.dart @@ -5,6 +5,7 @@ import 'dart:async'; import 'dart:convert'; import 'dart:io'; +import 'package:podcast_search/src/model/block.dart'; import 'package:podcast_search/src/model/value_recipient.dart'; import 'package:rss_dart/dart_rss.dart'; import 'package:dio/dio.dart'; @@ -57,6 +58,9 @@ class Podcast { /// A list of [Value], each can contain 0 or more [ValueRecipient] final List value; + /// A list of [Block] tags. + final List block; + /// A list of current episodes. final List episodes; @@ -72,6 +76,7 @@ class Podcast { this.funding = const [], this.persons = const [], this.value = const [], + this.block = const [], this.episodes = const [], }); @@ -170,6 +175,7 @@ class Podcast { var funding = []; var persons = []; + var block = []; var value = []; var guid = rssFeed.podcastIndex?.guid; @@ -195,6 +201,14 @@ class Podcast { } } + if (rssFeed.podcastIndex!.block != null) { + for (var b in rssFeed.podcastIndex!.block!) { + block.add( + Block(block: b?.block ?? false, id: b?.id) + ); + } + } + if (rssFeed.podcastIndex!.value != null) { for (var v in rssFeed.podcastIndex!.value!) { var recipients = []; @@ -238,6 +252,7 @@ class Podcast { locked: locked, funding: funding, persons: persons, + block: block, value: value, episodes: episodes, ); diff --git a/pubspec.yaml b/pubspec.yaml index 9c1be0b..421a5dd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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. +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.4 +version: 0.6.5 homepage: https://github.com/amugofjava/podcast_search environment: diff --git a/test/podcast_load_test.dart b/test/podcast_load_test.dart index fc9ab7a..75d1b9a 100644 --- a/test/podcast_load_test.dart +++ b/test/podcast_load_test.dart @@ -51,4 +51,28 @@ void main() { expect(episode2.publicationDate, null); }); }); + + group('Block tag test', () { + test('Load podcast with block tags', () async { + var podcast = + await Podcast.loadFeedFile(file: 'test_resources/podcast1.rss'); + + expect(podcast.block.length, 3); + expect(podcast.block[0].block, true); + expect(podcast.block[0].id, null); + + expect(podcast.block[1].block, false); + expect(podcast.block[1].id, 'google'); + + expect(podcast.block[2].block, true); + expect(podcast.block[2].id, 'amazon'); + }); + + test('Load podcast with no block tags', () async { + var podcast = + await Podcast.loadFeedFile(file: 'test_resources/podcast-no-block.rss'); + + expect(podcast.block.length, 0); + }); + }); } diff --git a/test_resources/podcast-no-block.rss b/test_resources/podcast-no-block.rss new file mode 100644 index 0000000..5c56d32 --- /dev/null +++ b/test_resources/podcast-no-block.rss @@ -0,0 +1,67 @@ + + + +Podcast Load Test 2 +Unit test podcast test 1 +https://nowhere.com/podcastsearchtest1 +Thu, 24 Jun 2021 18:00:20 +0000 +en + + https://nowhere.com/podcastsearchtest1/image1.png + Podcast Load Test 1 + https://nowhere.com/podcastsearchtest1 + + + + + +no +Unit test podcast test 1 +Podcast Search Author + + Ben Hills + anytime@amugofjava.me.uk + +podcast1.rss +episodic + + + + + + + Episode 001 + https://nowhere.com/podcastsearchtest1/podcast1 + + 1200 + yes + full + Test of episode 001]]> + Episode summary 001 + Thu, 24 Jun 2021 18:00:00 +0000 + + Ben Hills + Ben Hills + Podcast, NowPlaying, Listen, Test + Podcast, NowPlaying, Listen, Test + + + + + Episode 002 + https://nowhere.com/podcastsearchtest1/podcast2 + + 1200 + no + full + Test of episode 002]]> + Episode summary 002 + + Ben Hills + Ben Hills + Podcast, NowPlaying, Listen, Test + Podcast, NowPlaying, Listen, Test + + + + diff --git a/test_resources/podcast1.rss b/test_resources/podcast1.rss index 903f8c3..baed7b7 100644 --- a/test_resources/podcast1.rss +++ b/test_resources/podcast1.rss @@ -24,6 +24,9 @@ podcast1.rss episodic +yes +no +yes