5656/* DEFAULTS *********************************************/
5757
5858// error handler needs these, so let's set them now.
59- define ('VERSION ' , '1.37 ' );
59+ define ('VERSION ' , '1.38 ' );
6060define ('DIR2CAST_HOMEPAGE ' , 'https://github.com/ben-xo/dir2cast/ ' );
6161define ('GENERATOR ' , 'dir2cast ' . VERSION . ' by Ben XO ( ' . DIR2CAST_HOMEPAGE . ') ' );
6262
@@ -173,7 +173,7 @@ public function appendToItem(DOMElement $d, DOMDocument $doc, RSS_Item $item)
173173 }
174174
175175 unset($ this ->getid3 );
176-
176+
177177 if (!empty ($ info ['comments ' ]))
178178 {
179179 if (!empty ($ info ['comments ' ]['title ' ][0 ]))
@@ -184,6 +184,10 @@ public function appendToItem(DOMElement $d, DOMDocument $doc, RSS_Item $item)
184184 $ item ->setID3Album ( $ info ['comments ' ]['album ' ][0 ] );
185185 if (!empty ($ info ['comments ' ]['comment ' ][0 ]))
186186 $ item ->setID3Comment ( $ info ['comments ' ]['comment ' ][0 ] );
187+ if (!empty ($ info ['comments ' ]['track_number ' ][0 ]))
188+ $ item ->setID3Track ( $ info ['comments ' ]['track_number ' ][0 ] );
189+ if (!empty ($ info ['comments ' ]['part_of_a_set ' ][0 ]))
190+ $ item ->setID3PartOfASet ( $ info ['comments ' ]['part_of_a_set ' ][0 ] );
187191
188192 if (self ::$ AUTO_SAVE_COVER_ART )
189193 {
@@ -332,6 +336,7 @@ public function id()
332336 }
333337
334338 static $ ITUNES_SUBTITLE_SUFFIX = '' ;
339+ static $ ITUNES_TYPE = "episodic " ;
335340
336341 protected $ owner_name , $ owner_email , $ image_href , $ explicit ;
337342 protected $ categories = array ();
@@ -391,6 +396,12 @@ public function appendToChannel(DOMElement $channel, DOMDocument $doc)
391396 $ channel ->appendChild ( $ doc ->createElement ('itunes:image ' ) )
392397 ->setAttribute ('href ' , $ this ->image_href );
393398 }
399+
400+ if (strlen (iTunes_Podcast_Helper::$ ITUNES_TYPE ))
401+ {
402+ $ channel ->appendChild ( $ doc ->createElement ('itunes:type ' ) )
403+ ->appendChild ( new DOMText ( iTunes_Podcast_Helper::$ ITUNES_TYPE == "serial " ? "serial " : "episodic " ) );
404+ }
394405 }
395406
396407 public function appendToItem (DOMElement $ item_element , DOMDocument $ doc , RSS_Item $ item )
@@ -426,6 +437,22 @@ public function appendToItem(DOMElement $item_element, DOMDocument $doc, RSS_Ite
426437 {
427438 $ elements ['subtitle ' ] = $ itunes_subtitle . iTunes_Podcast_Helper::$ ITUNES_SUBTITLE_SUFFIX ;
428439 }
440+
441+ if (iTunes_Podcast_Helper::$ ITUNES_TYPE == "serial " )
442+ {
443+
444+ $ episode = $ item ->getEpisode ();
445+ if ($ episode !== '' )
446+ {
447+ $ elements ['episode ' ] = $ episode ;
448+ }
449+
450+ $ season = $ item ->getSeason ();
451+ if ($ season !== '' )
452+ {
453+ $ elements ['season ' ] = $ season ;
454+ }
455+ }
429456
430457 foreach ($ elements as $ key => $ val )
431458 if (!empty ($ val ))
@@ -919,6 +946,28 @@ public function getSubtitle()
919946 return $ subtitle ;
920947 }
921948
949+ public function getEpisode ()
950+ {
951+ $ episode = parent ::getEpisode ();
952+ if (!$ episode )
953+ {
954+ // use track tag as season if there's no override
955+ $ episode = $ this ->getID3Track ();
956+ }
957+ return $ episode ;
958+ }
959+
960+ public function getSeason ()
961+ {
962+ $ season = parent ::getSeason ();
963+ if (!$ season )
964+ {
965+ // use part_of_a_set tag as season if there's no override
966+ $ season = $ this ->getID3PartOfASet ();
967+ }
968+ return $ season ;
969+ }
970+
922971 /**
923972 * Version number used in the saved cache files. If the used fields change, increment this number.
924973 * @var integer
@@ -1956,6 +2005,9 @@ public static function defaults(array $SERVER)
19562005 if (!defined ('ITUNES_SUBTITLE_SUFFIX ' ))
19572006 define ('ITUNES_SUBTITLE_SUFFIX ' , '' );
19582007
2008+ if (!defined ('ITUNES_TYPE ' ))
2009+ define ('ITUNES_TYPE ' , "episodic " );
2010+
19592011 if (!defined ('DESCRIPTION_SOURCE ' ))
19602012 define ('DESCRIPTION_SOURCE ' , 'comment ' );
19612013
@@ -1986,6 +2038,7 @@ public static function defaults(array $SERVER)
19862038 Cached_Dir_Podcast::$ MIN_CACHE_TIME = MIN_CACHE_TIME ;
19872039 getID3_Podcast_Helper::$ AUTO_SAVE_COVER_ART = AUTO_SAVE_COVER_ART ;
19882040 iTunes_Podcast_Helper::$ ITUNES_SUBTITLE_SUFFIX = ITUNES_SUBTITLE_SUFFIX ;
2041+ iTunes_Podcast_Helper::$ ITUNES_TYPE = ITUNES_TYPE ;
19892042
19902043 // Set up up factory settings for RSS Items
19912044 RSS_File_Item::$ FILES_URL = MP3_URL ; // TODO: rename this to MEDIA_URL
0 commit comments