Skip to content

Commit 9737546

Browse files
committed
Add support for PC2.0 block tag. Release 0.6.5.
1 parent 737dcf9 commit 9737546

File tree

8 files changed

+142
-27
lines changed

8 files changed

+142
-27
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.5
2+
3+
- Add support for PC2.0 `<podcast:block>` tag.
4+
15
## 0.6.4
26

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

README.md

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,28 +41,17 @@ main() async {
4141

4242
### Podcasting 2.0
4343

44-
- [x] Chapters
45-
- [x] Funding
46-
- [x] GUID
47-
- [x] Locked
48-
- [x] Person
49-
- [x] Transcripts
50-
- [ ] Alternate enclosure
51-
- [ ] Block
52-
- [ ] Episode
53-
- [ ] Images
54-
- [ ] Licence
55-
- [ ] Live item
56-
- [ ] Location
57-
- [ ] Medium
58-
- [ ] Podping
59-
- [ ] Podroll
60-
- [ ] Remote item
61-
- [ ] Season
62-
- [ ] Social interact
63-
- [ ] Soundbite
64-
- [ ] Trailer
65-
- [ ] Update frequency
66-
- [ ] Value
67-
- [ ] Value time split
68-
44+
- Block
45+
- Chapters
46+
- Funding
47+
- GUID
48+
- Locked
49+
- Person
50+
- Transcripts
51+
- Value
52+
53+
### iTunes
54+
55+
- Author
56+
- Episode
57+
- Season

lib/src/model/block.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// Copyright (c) 2019 Ben Hills and the project contributors. Use of this source
2+
// code is governed by a MIT license that can be found in the LICENSE file.
3+
4+
/// This class represents a PC2.0 [block](https://github.com/Podcastindex-org/podcast-namespace/blob/main/docs/1.0.md#block) tag.
5+
class Block {
6+
final bool block;
7+
String? id;
8+
9+
Block({
10+
required this.block,
11+
this.id,
12+
});
13+
}

lib/src/model/podcast.dart

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'dart:async';
55
import 'dart:convert';
66
import 'dart:io';
77

8+
import 'package:podcast_search/src/model/block.dart';
89
import 'package:podcast_search/src/model/value_recipient.dart';
910
import 'package:rss_dart/dart_rss.dart';
1011
import 'package:dio/dio.dart';
@@ -57,6 +58,9 @@ class Podcast {
5758
/// A list of [Value], each can contain 0 or more [ValueRecipient]
5859
final List<Value> value;
5960

61+
/// A list of [Block] tags.
62+
final List<Block> block;
63+
6064
/// A list of current episodes.
6165
final List<Episode> episodes;
6266

@@ -72,6 +76,7 @@ class Podcast {
7276
this.funding = const <Funding>[],
7377
this.persons = const <Person>[],
7478
this.value = const <Value>[],
79+
this.block = const <Block>[],
7580
this.episodes = const <Episode>[],
7681
});
7782

@@ -170,6 +175,7 @@ class Podcast {
170175

171176
var funding = <Funding>[];
172177
var persons = <Person>[];
178+
var block = <Block>[];
173179
var value = <Value>[];
174180

175181
var guid = rssFeed.podcastIndex?.guid;
@@ -195,6 +201,14 @@ class Podcast {
195201
}
196202
}
197203

204+
if (rssFeed.podcastIndex!.block != null) {
205+
for (var b in rssFeed.podcastIndex!.block!) {
206+
block.add(
207+
Block(block: b?.block ?? false, id: b?.id)
208+
);
209+
}
210+
}
211+
198212
if (rssFeed.podcastIndex!.value != null) {
199213
for (var v in rssFeed.podcastIndex!.value!) {
200214
var recipients = <ValueRecipient>[];
@@ -238,6 +252,7 @@ class Podcast {
238252
locked: locked,
239253
funding: funding,
240254
persons: persons,
255+
block: block,
241256
value: value,
242257
episodes: episodes,
243258
);

pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: podcast_search
2-
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.
2+
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.4
4+
version: 0.6.5
55
homepage: https://github.com/amugofjava/podcast_search
66

77
environment:

test/podcast_load_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,28 @@ void main() {
5151
expect(episode2.publicationDate, null);
5252
});
5353
});
54+
55+
group('Block tag test', () {
56+
test('Load podcast with block tags', () async {
57+
var podcast =
58+
await Podcast.loadFeedFile(file: 'test_resources/podcast1.rss');
59+
60+
expect(podcast.block.length, 3);
61+
expect(podcast.block[0].block, true);
62+
expect(podcast.block[0].id, null);
63+
64+
expect(podcast.block[1].block, false);
65+
expect(podcast.block[1].id, 'google');
66+
67+
expect(podcast.block[2].block, true);
68+
expect(podcast.block[2].id, 'amazon');
69+
});
70+
71+
test('Load podcast with no block tags', () async {
72+
var podcast =
73+
await Podcast.loadFeedFile(file: 'test_resources/podcast-no-block.rss');
74+
75+
expect(podcast.block.length, 0);
76+
});
77+
});
5478
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<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/">
3+
<channel>
4+
<title>Podcast Load Test 2</title>
5+
<description>Unit test podcast test 1</description>
6+
<link>https://nowhere.com/podcastsearchtest1</link>
7+
<pubDate>Thu, 24 Jun 2021 18:00:20 +0000</pubDate>
8+
<language>en</language>
9+
<image>
10+
<url>https://nowhere.com/podcastsearchtest1/image1.png</url>
11+
<title>Podcast Load Test 1</title>
12+
<link>https://nowhere.com/podcastsearchtest1</link>
13+
</image>
14+
<itunes:image href="https://nowhere.com/podcastsearchtest1/image1.png" />
15+
<itunes:category text="Comedy"><itunes:category text="Comedy Interviews" /></itunes:category>
16+
<itunes:category text="Society &amp; Culture"><itunes:category text="Relationships" /></itunes:category>
17+
<itunes:category text="TV &amp; Film"><itunes:category text="After Shows" /></itunes:category>
18+
<itunes:explicit>no</itunes:explicit>
19+
<itunes:summary>Unit test podcast test 1</itunes:summary>
20+
<itunes:author>Podcast Search Author</itunes:author>
21+
<itunes:owner>
22+
<itunes:name>Ben Hills</itunes:name>
23+
<itunes:email>[email protected]</itunes:email>
24+
</itunes:owner>
25+
<itunes:new-feed-url>podcast1.rss</itunes:new-feed-url>
26+
<itunes:type>episodic</itunes:type>
27+
<podcast:value type="lightning" method="keysend" suggested="0.00000005000">
28+
<podcast:valueRecipient name="channel recipient1" type="node" address="03ae9f91a0cb8ff43840e3c322c55341a19d8c1c3cea15a25cfc425ac60a34e14a" split="80"/>
29+
<podcast:valueRecipient name="channel recipient2" type="node" address="03ae9f91a0cb8ff43840e3c322c55341a19d8c1c3cea15a25cfc425ac60a34e14b" split="20"/>
30+
</podcast:value>
31+
32+
<item>
33+
<title>Episode 001</title>
34+
<link>https://nowhere.com/podcastsearchtest1/podcast1</link>
35+
<enclosure url="https://nowhere.com/podcastsearchtest1/podcast1/episode001.mp3" length="0" type="audio/mpeg" />
36+
<itunes:duration>1200</itunes:duration>
37+
<itunes:explicit>yes</itunes:explicit>
38+
<itunes:episodeType>full</itunes:episodeType>
39+
<description><![CDATA[<div>Test of episode 001</div>]]></description>
40+
<itunes:summary>Episode summary 001</itunes:summary>
41+
<pubDate>Thu, 24 Jun 2021 18:00:00 +0000</pubDate>
42+
<guid isPermaLink="true"></guid>
43+
<itunes:author>Ben Hills</itunes:author>
44+
<dc:creator>Ben Hills</dc:creator>
45+
<itunes:keywords>Podcast, NowPlaying, Listen, Test</itunes:keywords>
46+
<media:keywords>Podcast, NowPlaying, Listen, Test</media:keywords>
47+
<media:rights status="userCreated" />
48+
</item>
49+
50+
<item>
51+
<title>Episode 002</title>
52+
<link>https://nowhere.com/podcastsearchtest1/podcast2</link>
53+
<enclosure url="https://nowhere.com/podcastsearchtest1/podcast1/episode002.mp3" length="0" type="audio/mpeg" />
54+
<itunes:duration>1200</itunes:duration>
55+
<itunes:explicit>no</itunes:explicit>
56+
<itunes:episodeType>full</itunes:episodeType>
57+
<description><![CDATA[<div>Test of episode 002</div>]]></description>
58+
<itunes:summary>Episode summary 002</itunes:summary>
59+
<guid isPermaLink="true"></guid>
60+
<itunes:author>Ben Hills</itunes:author>
61+
<dc:creator>Ben Hills</dc:creator>
62+
<itunes:keywords>Podcast, NowPlaying, Listen, Test</itunes:keywords>
63+
<media:keywords>Podcast, NowPlaying, Listen, Test</media:keywords>
64+
<media:rights status="userCreated" />
65+
</item>
66+
</channel>
67+
</rss>

test_resources/podcast1.rss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@
2424
</itunes:owner>
2525
<itunes:new-feed-url>podcast1.rss</itunes:new-feed-url>
2626
<itunes:type>episodic</itunes:type>
27+
<podcast:block>yes</podcast:block>
28+
<podcast:block id="google">no</podcast:block>
29+
<podcast:block id="amazon">yes</podcast:block>
2730
<podcast:value type="lightning" method="keysend" suggested="0.00000005000">
2831
<podcast:valueRecipient name="channel recipient1" type="node" address="03ae9f91a0cb8ff43840e3c322c55341a19d8c1c3cea15a25cfc425ac60a34e14a" split="80"/>
2932
<podcast:valueRecipient name="channel recipient2" type="node" address="03ae9f91a0cb8ff43840e3c322c55341a19d8c1c3cea15a25cfc425ac60a34e14b" split="20"/>

0 commit comments

Comments
 (0)