From 74efd9ab448e7e43ae07231408cc87ea3f2eb316 Mon Sep 17 00:00:00 2001 From: Ben XO <75862+ben-xo@users.noreply.github.com> Date: Fri, 23 Dec 2022 23:22:24 +0000 Subject: [PATCH] Fix the name and implement the PartOfASet -> Season mapping --- dir2cast.php | 15 ++++++- test/Media_RSS_ItemTest.php | 11 +++++ ..._Item_id3v2_artist_title_partofsetTest.php | 41 ++++++++++++++++++ ....mp3 => id3v2_artist_title_partofaset.mp3} | Bin 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 test/Media_RSS_Item_id3v2_artist_title_partofsetTest.php rename test/fixtures/{id3v2_artist_title_partofset.mp3 => id3v2_artist_title_partofaset.mp3} (100%) diff --git a/dir2cast.php b/dir2cast.php index c14413a..5d2e262 100644 --- a/dir2cast.php +++ b/dir2cast.php @@ -173,7 +173,7 @@ public function appendToItem(DOMElement $d, DOMDocument $doc, RSS_Item $item) } unset($this->getid3); - + if(!empty($info['comments'])) { if(!empty($info['comments']['title'][0])) @@ -184,6 +184,8 @@ public function appendToItem(DOMElement $d, DOMDocument $doc, RSS_Item $item) $item->setID3Album( $info['comments']['album'][0] ); if(!empty($info['comments']['comment'][0])) $item->setID3Comment( $info['comments']['comment'][0] ); + if(!empty($info['part_of_a_set'][0])) + $item->setID3PartOfASet( $info['part_of_a_set'][0] ); if(self::$AUTO_SAVE_COVER_ART) { @@ -929,6 +931,17 @@ public function getSubtitle() return $subtitle; } + public function getSeason() + { + $season = parent::getSeason(); + if(!$season) + { + // use part_of_a_set tag as season if there's no override + $season = $this->getID3PartOfASet(); + } + return $season; + } + /** * Version number used in the saved cache files. If the used fields change, increment this number. * @var integer diff --git a/test/Media_RSS_ItemTest.php b/test/Media_RSS_ItemTest.php index cc8f8c5..2200998 100644 --- a/test/Media_RSS_ItemTest.php +++ b/test/Media_RSS_ItemTest.php @@ -50,6 +50,11 @@ public function getID3Comment() return ''; } + public function getID3PartOfASet() + { + return ''; + } + protected $media_rss_item_class = 'Media_RSS_Item'; public function newRSSItem() @@ -67,6 +72,7 @@ public function newRSSItem() $item->setID3Title($this->getID3Title()); $item->setID3Artist($this->getID3Artist()); $item->setID3Comment($this->getID3Comment()); + $item->setID3PartOfASet($this->getID3PartOfASet()); return $item; } @@ -136,6 +142,11 @@ public function test_summary_from_description_when_summary_not_set_and_descripti $this->assertEquals('', $item->getSummary()); } + public function test_season_from_part_of_set_tag_by_default() { + $item = $this->newRSSItem(); + $this->assertEquals($this->getID3PartOfASet(), $item->getSeason()); + } + public function tearDown(): void { file_exists($this->filename) && unlink($this->filename); diff --git a/test/Media_RSS_Item_id3v2_artist_title_partofsetTest.php b/test/Media_RSS_Item_id3v2_artist_title_partofsetTest.php new file mode 100644 index 0000000..2d985d5 --- /dev/null +++ b/test/Media_RSS_Item_id3v2_artist_title_partofsetTest.php @@ -0,0 +1,41 @@ +