Skip to content

Commit

Permalink
Rename setting to ITUNES_TYPE so you can also choose episodic or none.
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-xo committed Jan 13, 2023
1 parent e18ccdc commit 589870c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 22 deletions.
7 changes: 4 additions & 3 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
Changelog
=========

1.38 2023-01-05 * Add ITUNES_TYPE_SERIAL option to dir2cast.ini. When enabled,
the feed will have <itunes:type>serial<itunes:type> set.
For each episode, the "Part Of A Set" tag (TPOS), if filled,
1.38 2023-01-05 * Add <itunes:type> defaulting to "episodic". The ITUNES_TYPE
option in dir2cast.ini will let you set the feed to
<itunes:type>serial<itunes:type> set, and then,
for each episode, the "Part Of A Set" tag (TPOS), if filled,
will be used to output an <itunes:season> tag, and the
"Track Number" tag (TRCK), if filled, will be used to output
an <itunes:episode> tag. See the .ini for usage info.
Expand Down
24 changes: 18 additions & 6 deletions dir2cast.ini
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,8 @@
; See https://github.com/simplepie/simplepie-ng/wiki/Spec:-iTunes-Podcast-RSS
; Valid values are "yes", "explicit", "true" or "no", "clean", "false"
;
; If you don't set this, it will not appear in the feed at all!
; If you don't set this, it will not appear in the feed at all, and Apple
; Podcasts may reject your feed!
;ITUNES_EXPLICIT = "no"


Expand Down Expand Up @@ -159,21 +160,32 @@

; Whether to output the <itunes:episode> and <itunes:season> tags
;
; If set to true, the feed will be set to itunes:type serial, and it will
; Set the <itunes:type> tag. If you set this to "serial", it will
; use the content of the ID3 "TRCK" and "TPOS" fields (also known as
; "track number", and "part of a set" (or sometimes "disc number"),
; respectively, as content of the <itunes:episode> and <itunes:season> tags.
;
; The TRCK and TPOS values should be non-zero positive integers (1, 2, 3, etc)
;
; NOTE: these are NOT used for ordering within the RSS feed. This is
; still done by file date so upload them in the right order if you have
; any issues.
; still done by file date so it's up to you to make the episode order
; and the file date order match by uploading them in season/episode order.
;
; The default value is "episodic", and no <itunes:episode> or <itunes:season>
; tags will be output in the feed.
;
; If you don't want <itunes:type> to appear in the feed at all, set this to ""
;
;ITUNES_TYPE_SERIAL = false
; Any value that is not "" or "serial" will be treated as "episodic"
;ITUNES_TYPE = episodic

; *** CHECK THESE ARE OK. ***

; Language of the feed
; This defaults to en-us (US English). This must be something recognised by
; the RSS standard.
; the RSS standard. Apple Podcasts only supports values from the ISO 639 list
; (two-letter language codes, with some possible modifiers, such as "en-us").
; See https://www.loc.gov/standards/iso639-2/php/code_list.php
;LANGUAGE = en-us

; Where to cache RSS feeds (this must be writable by the web server)
Expand Down
14 changes: 7 additions & 7 deletions dir2cast.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ public function id()
}

static $ITUNES_SUBTITLE_SUFFIX = '';
static $ITUNES_TYPE_SERIAL = false;
static $ITUNES_TYPE = "episodic";

protected $owner_name, $owner_email, $image_href, $explicit;
protected $categories = array();
Expand Down Expand Up @@ -397,10 +397,10 @@ public function appendToChannel(DOMElement $channel, DOMDocument $doc)
->setAttribute('href', $this->image_href);
}

if(iTunes_Podcast_Helper::$ITUNES_TYPE_SERIAL)
if(strlen(iTunes_Podcast_Helper::$ITUNES_TYPE))
{
$channel->appendChild( $doc->createElement('itunes:type') )
->appendChild( new DOMText( 'serial' ) );
->appendChild( new DOMText( iTunes_Podcast_Helper::$ITUNES_TYPE == "serial" ? "serial" : "episodic" ) );
}
}

Expand Down Expand Up @@ -438,7 +438,7 @@ public function appendToItem(DOMElement $item_element, DOMDocument $doc, RSS_Ite
$elements['subtitle'] = $itunes_subtitle . iTunes_Podcast_Helper::$ITUNES_SUBTITLE_SUFFIX;
}

if(iTunes_Podcast_Helper::$ITUNES_TYPE_SERIAL)
if(iTunes_Podcast_Helper::$ITUNES_TYPE == "serial")
{

$episode = $item->getEpisode();
Expand Down Expand Up @@ -2005,8 +2005,8 @@ public static function defaults(array $SERVER)
if(!defined('ITUNES_SUBTITLE_SUFFIX'))
define('ITUNES_SUBTITLE_SUFFIX', '');

if(!defined('ITUNES_TYPE_SERIAL'))
define('ITUNES_TYPE_SERIAL', false);
if(!defined('ITUNES_TYPE'))
define('ITUNES_TYPE', "episodic");

if(!defined('DESCRIPTION_SOURCE'))
define('DESCRIPTION_SOURCE', 'comment');
Expand Down Expand Up @@ -2038,7 +2038,7 @@ public static function defaults(array $SERVER)
Cached_Dir_Podcast::$MIN_CACHE_TIME = MIN_CACHE_TIME;
getID3_Podcast_Helper::$AUTO_SAVE_COVER_ART = AUTO_SAVE_COVER_ART;
iTunes_Podcast_Helper::$ITUNES_SUBTITLE_SUFFIX = ITUNES_SUBTITLE_SUFFIX;
iTunes_Podcast_Helper::$ITUNES_TYPE_SERIAL = ITUNES_TYPE_SERIAL;
iTunes_Podcast_Helper::$ITUNES_TYPE = ITUNES_TYPE;

// Set up up factory settings for RSS Items
RSS_File_Item::$FILES_URL = MP3_URL; // TODO: rename this to MEDIA_URL
Expand Down
2 changes: 1 addition & 1 deletion test/ITunesPodcastSeasonTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public static function setUpBeforeClass(): void
touch('6.mp3', $now+250);
MixedMediaExampleTest::$filemtime = $now;

file_put_contents('./dir2cast.ini', "ITUNES_TYPE_SERIAL = true\n");
file_put_contents('./dir2cast.ini', "ITUNES_TYPE = serial\n");

MixedMediaExampleTest::$output = '';
exec('php dir2cast.php --media-url=https://www.example.com/podcast/ --output=out.xml --min-file-age=0', MixedMediaExampleTest::$output, MixedMediaExampleTest::$returncode);
Expand Down
2 changes: 1 addition & 1 deletion test/MixedMediaExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function test_itunes_type()
$itdtd = "http://www.itunes.com/dtds/podcast-1.0.dtd";

// assert itunes:type = serial
$this->assertEmpty($data->channel->children($itdtd)->type);
$this->assertEquals('episodic', $data->channel->children($itdtd)->type);
}

public function test_podcast_has_expected_items_with_default_behaviour(): void
Expand Down
8 changes: 4 additions & 4 deletions test/SettingsHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SettingsHandlerTest extends TestCase
'ITUNES_EXPLICIT',
'LONG_TITLES',
'ITUNES_SUBTITLE_SUFFIX',
'ITUNES_TYPE_SERIAL',
'ITUNES_TYPE',
'DESCRIPTION_SOURCE',
'RECURSIVE_DIRECTORY_ITERATOR',
'AUTO_SAVE_COVER_ART',
Expand Down Expand Up @@ -116,7 +116,7 @@ public function test_default_defines_set()
$this->assertEmpty(RSS_File_Item::$FILES_URL);
$this->assertEmpty(RSS_File_Item::$FILES_DIR);
$this->assertEmpty(iTunes_Podcast_Helper::$ITUNES_SUBTITLE_SUFFIX);
$this->assertFalse(iTunes_Podcast_Helper::$ITUNES_TYPE_SERIAL);
$this->assertEquals('episodic', iTunes_Podcast_Helper::$ITUNES_TYPE);
$this->assertFalse(Media_RSS_Item::$LONG_TITLES);
$this->assertEquals('comment', Media_RSS_Item::$DESCRIPTION_SOURCE);

Expand Down Expand Up @@ -512,7 +512,7 @@ public function test_sensible_defaults($argv0)
$this->assertEquals(ITUNES_EXPLICIT, '');
$this->assertEquals(LONG_TITLES, false);
$this->assertEquals(ITUNES_SUBTITLE_SUFFIX, '');
$this->assertEquals(ITUNES_TYPE_SERIAL, false);
$this->assertEquals(ITUNES_TYPE, 'episodic');
$this->assertEquals(DESCRIPTION_SOURCE, 'comment');
$this->assertEquals(RECURSIVE_DIRECTORY_ITERATOR, false);
$this->assertEquals(AUTO_SAVE_COVER_ART, true);
Expand All @@ -526,7 +526,7 @@ public function test_sensible_defaults($argv0)
$this->assertSame(Cached_Dir_Podcast::$MIN_CACHE_TIME, MIN_CACHE_TIME);
$this->assertSame(getID3_Podcast_Helper::$AUTO_SAVE_COVER_ART, AUTO_SAVE_COVER_ART);
$this->assertSame(iTunes_Podcast_Helper::$ITUNES_SUBTITLE_SUFFIX, ITUNES_SUBTITLE_SUFFIX);
$this->assertSame(iTunes_Podcast_Helper::$ITUNES_TYPE_SERIAL, ITUNES_TYPE_SERIAL);
$this->assertSame(iTunes_Podcast_Helper::$ITUNES_TYPE, ITUNES_TYPE);
$this->assertSame(RSS_File_Item::$FILES_URL, MP3_URL);
$this->assertSame(RSS_File_Item::$FILES_DIR, MP3_DIR());
$this->assertSame(Media_RSS_Item::$LONG_TITLES, LONG_TITLES);
Expand Down

0 comments on commit 589870c

Please sign in to comment.