diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c9e9b23..2284ea8 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,9 +1,10 @@ Changelog ========= -1.38 2023-01-05 * Add ITUNES_TYPE_SERIAL option to dir2cast.ini. When enabled, - the feed will have serial set. - For each episode, the "Part Of A Set" tag (TPOS), if filled, +1.38 2023-01-05 * Add defaulting to "episodic". The ITUNES_TYPE + option in dir2cast.ini will let you set the feed to + serial set, and then, + for each episode, the "Part Of A Set" tag (TPOS), if filled, will be used to output an tag, and the "Track Number" tag (TRCK), if filled, will be used to output an tag. See the .ini for usage info. diff --git a/dir2cast.ini b/dir2cast.ini index 029a44f..663a3a3 100755 --- a/dir2cast.ini +++ b/dir2cast.ini @@ -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" @@ -159,21 +160,32 @@ ; Whether to output the and tags ; -; If set to true, the feed will be set to itunes:type serial, and it will +; Set the 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 and 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 or +; tags will be output in the feed. +; +; If you don't want 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) diff --git a/dir2cast.php b/dir2cast.php index f3619bc..22be491 100644 --- a/dir2cast.php +++ b/dir2cast.php @@ -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(); @@ -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" ) ); } } @@ -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(); @@ -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'); @@ -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 diff --git a/test/ITunesPodcastSeasonTest.php b/test/ITunesPodcastSeasonTest.php index d38a19b..e9a107b 100644 --- a/test/ITunesPodcastSeasonTest.php +++ b/test/ITunesPodcastSeasonTest.php @@ -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); diff --git a/test/MixedMediaExampleTest.php b/test/MixedMediaExampleTest.php index c1682f2..70aacad 100644 --- a/test/MixedMediaExampleTest.php +++ b/test/MixedMediaExampleTest.php @@ -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 diff --git a/test/SettingsHandlerTest.php b/test/SettingsHandlerTest.php index 8e1430c..73fe430 100644 --- a/test/SettingsHandlerTest.php +++ b/test/SettingsHandlerTest.php @@ -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', @@ -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); @@ -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); @@ -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);