Skip to content

Commit

Permalink
Add support for PC2.0 block tag. Release 0.6.5.
Browse files Browse the repository at this point in the history
  • Loading branch information
amugofjava committed Dec 27, 2023
1 parent 737dcf9 commit 9737546
Show file tree
Hide file tree
Showing 8 changed files with 142 additions and 27 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.5

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

## 0.6.4

- Add support for PC2.0 `<podcast:value>` tag.
Expand Down
39 changes: 14 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
13 changes: 13 additions & 0 deletions lib/src/model/block.dart
Original file line number Diff line number Diff line change
@@ -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,
});
}
15 changes: 15 additions & 0 deletions lib/src/model/podcast.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -57,6 +58,9 @@ class Podcast {
/// A list of [Value], each can contain 0 or more [ValueRecipient]
final List<Value> value;

/// A list of [Block] tags.
final List<Block> block;

/// A list of current episodes.
final List<Episode> episodes;

Expand All @@ -72,6 +76,7 @@ class Podcast {
this.funding = const <Funding>[],
this.persons = const <Person>[],
this.value = const <Value>[],
this.block = const <Block>[],
this.episodes = const <Episode>[],
});

Expand Down Expand Up @@ -170,6 +175,7 @@ class Podcast {

var funding = <Funding>[];
var persons = <Person>[];
var block = <Block>[];
var value = <Value>[];

var guid = rssFeed.podcastIndex?.guid;
Expand All @@ -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 = <ValueRecipient>[];
Expand Down Expand Up @@ -238,6 +252,7 @@ class Podcast {
locked: locked,
funding: funding,
persons: persons,
block: block,
value: value,
episodes: episodes,
);
Expand Down
4 changes: 2 additions & 2 deletions 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.
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:
Expand Down
24 changes: 24 additions & 0 deletions test/podcast_load_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
});
}
67 changes: 67 additions & 0 deletions test_resources/podcast-no-block.rss
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:itunes="http://www.itunes.com/dtds/podcast-1.0.dtd" xmlns:media="http://search.yahoo.com/mrss/" xmlns:georss="http://www.georss.org/georss" xmlns:audioboom="https://audioboom.com/rss/1.0" version="2.0" xml:base="https://audioboom.com/">
<channel>
<title>Podcast Load Test 2</title>
<description>Unit test podcast test 1</description>
<link>https://nowhere.com/podcastsearchtest1</link>
<pubDate>Thu, 24 Jun 2021 18:00:20 +0000</pubDate>
<language>en</language>
<image>
<url>https://nowhere.com/podcastsearchtest1/image1.png</url>
<title>Podcast Load Test 1</title>
<link>https://nowhere.com/podcastsearchtest1</link>
</image>
<itunes:image href="https://nowhere.com/podcastsearchtest1/image1.png" />
<itunes:category text="Comedy"><itunes:category text="Comedy Interviews" /></itunes:category>
<itunes:category text="Society &amp; Culture"><itunes:category text="Relationships" /></itunes:category>
<itunes:category text="TV &amp; Film"><itunes:category text="After Shows" /></itunes:category>
<itunes:explicit>no</itunes:explicit>
<itunes:summary>Unit test podcast test 1</itunes:summary>
<itunes:author>Podcast Search Author</itunes:author>
<itunes:owner>
<itunes:name>Ben Hills</itunes:name>
<itunes:email>anytime@amugofjava.me.uk</itunes:email>
</itunes:owner>
<itunes:new-feed-url>podcast1.rss</itunes:new-feed-url>
<itunes:type>episodic</itunes:type>
<podcast:value type="lightning" method="keysend" suggested="0.00000005000">
<podcast:valueRecipient name="channel recipient1" type="node" address="03ae9f91a0cb8ff43840e3c322c55341a19d8c1c3cea15a25cfc425ac60a34e14a" split="80"/>
<podcast:valueRecipient name="channel recipient2" type="node" address="03ae9f91a0cb8ff43840e3c322c55341a19d8c1c3cea15a25cfc425ac60a34e14b" split="20"/>
</podcast:value>

<item>
<title>Episode 001</title>
<link>https://nowhere.com/podcastsearchtest1/podcast1</link>
<enclosure url="https://nowhere.com/podcastsearchtest1/podcast1/episode001.mp3" length="0" type="audio/mpeg" />
<itunes:duration>1200</itunes:duration>
<itunes:explicit>yes</itunes:explicit>
<itunes:episodeType>full</itunes:episodeType>
<description><![CDATA[<div>Test of episode 001</div>]]></description>
<itunes:summary>Episode summary 001</itunes:summary>
<pubDate>Thu, 24 Jun 2021 18:00:00 +0000</pubDate>
<guid isPermaLink="true"></guid>
<itunes:author>Ben Hills</itunes:author>
<dc:creator>Ben Hills</dc:creator>
<itunes:keywords>Podcast, NowPlaying, Listen, Test</itunes:keywords>
<media:keywords>Podcast, NowPlaying, Listen, Test</media:keywords>
<media:rights status="userCreated" />
</item>

<item>
<title>Episode 002</title>
<link>https://nowhere.com/podcastsearchtest1/podcast2</link>
<enclosure url="https://nowhere.com/podcastsearchtest1/podcast1/episode002.mp3" length="0" type="audio/mpeg" />
<itunes:duration>1200</itunes:duration>
<itunes:explicit>no</itunes:explicit>
<itunes:episodeType>full</itunes:episodeType>
<description><![CDATA[<div>Test of episode 002</div>]]></description>
<itunes:summary>Episode summary 002</itunes:summary>
<guid isPermaLink="true"></guid>
<itunes:author>Ben Hills</itunes:author>
<dc:creator>Ben Hills</dc:creator>
<itunes:keywords>Podcast, NowPlaying, Listen, Test</itunes:keywords>
<media:keywords>Podcast, NowPlaying, Listen, Test</media:keywords>
<media:rights status="userCreated" />
</item>
</channel>
</rss>
3 changes: 3 additions & 0 deletions test_resources/podcast1.rss
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
</itunes:owner>
<itunes:new-feed-url>podcast1.rss</itunes:new-feed-url>
<itunes:type>episodic</itunes:type>
<podcast:block>yes</podcast:block>
<podcast:block id="google">no</podcast:block>
<podcast:block id="amazon">yes</podcast:block>
<podcast:value type="lightning" method="keysend" suggested="0.00000005000">
<podcast:valueRecipient name="channel recipient1" type="node" address="03ae9f91a0cb8ff43840e3c322c55341a19d8c1c3cea15a25cfc425ac60a34e14a" split="80"/>
<podcast:valueRecipient name="channel recipient2" type="node" address="03ae9f91a0cb8ff43840e3c322c55341a19d8c1c3cea15a25cfc425ac60a34e14b" split="20"/>
Expand Down

0 comments on commit 9737546

Please sign in to comment.