From 1dc052b04c01c6a706d316abad86331155769507 Mon Sep 17 00:00:00 2001 From: Ben XO <75862+ben-xo@users.noreply.github.com> Date: Thu, 21 Jul 2022 10:49:52 +0100 Subject: [PATCH 1/4] Update dates and version numbers for branch --- CHANGELOG.txt | 4 +++- README.md | 2 +- dir2cast.php | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index e852c23..96f8f3e 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,7 +1,9 @@ Changelog ========= -1.33 unreleased * README fixed by @denilsonsa - thanks! +1.34 unreleased * Add support for M4B audiobook files as requested by @crosbyh + +1.33 2022-05-25 * README fixed by @denilsonsa - thanks! * Caching algorithm changed to so that it is no longer dependent on added media files having a newer file date (GitHub #51), and will look for any changes in filesize or date, as well diff --git a/README.md b/README.md index fcf9d1a..718f1c2 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![Testing dir2cast](https://github.com/ben-xo/dir2cast/actions/workflows/testing.yml/badge.svg)](https://github.com/ben-xo/dir2cast/actions/workflows/testing.yml) -dir2cast by Ben XO v1.33 (2022-05-25) +dir2cast by Ben XO v1.34 (SNAPSHOT) ================================================================================ https://github.com/ben-xo/dir2cast/ diff --git a/dir2cast.php b/dir2cast.php index 751bd47..4dfb29c 100644 --- a/dir2cast.php +++ b/dir2cast.php @@ -1,7 +1,7 @@ Date: Thu, 21 Jul 2022 10:50:42 +0100 Subject: [PATCH 2/4] Add provisional support for M4B --- README.md | 6 +++--- dir2cast.php | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 718f1c2..562bdd9 100644 --- a/README.md +++ b/README.md @@ -22,10 +22,10 @@ Features: pick up most of the podcast text straight from the tags in the file (such as the artist, title and comment tags.) -* supports MP3, MP4, and M4A files +* supports MP3, MP4, M4A and M4B files * dir2cast will automatically use the ID3 fields from your files for the Author, - Title, etc. ID3v2 is supported, as are the regular tags found in MP4 and M4A + Title, etc. ID3v2 is supported, as are the usual tags found in MP4 / M4A / M4B files. (Uses getID3, which is bundled with dir2cast.) * dir2cast will automatically use the cover art embedded in your file as well. @@ -81,7 +81,7 @@ Please note: the config file will make more sense if you read all of this `READM before trying the installation instructions. dir2cast is quite flexible but the general idea is that you add cover art and -tags to your media files - mp3, mp4 or m4a currently supported - and then the +tags to your media files (mp3, mp4, m4a and m4b currently supported) and then the podcast that it generates uses the tags from your files. 1. Edit `dir2cast.ini` to your taste. diff --git a/dir2cast.php b/dir2cast.php index 4dfb29c..45cc1ef 100644 --- a/dir2cast.php +++ b/dir2cast.php @@ -1200,6 +1200,7 @@ public function addItem($filename) break; case 'm4a': + case 'm4b': $this->addRssFileItem(new M4A_RSS_Item($filename)); break; From c4f23c1e63b4660af86856cca5e106ecfce2ce4f Mon Sep 17 00:00:00 2001 From: Ben XO <75862+ben-xo@users.noreply.github.com> Date: Thu, 28 Jul 2022 22:01:22 +0100 Subject: [PATCH 3/4] Add unit tests for m4b --- test/Dir_PodcastTest.php | 21 +++++++++++++++------ test/Dir_Podcast_RecursiveTest.php | 10 ++++++++++ 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/test/Dir_PodcastTest.php b/test/Dir_PodcastTest.php index 533fa2a..39eec7b 100644 --- a/test/Dir_PodcastTest.php +++ b/test/Dir_PodcastTest.php @@ -31,12 +31,14 @@ public function createTestItems() file_put_contents('test2.mp4', 'content'); file_put_contents('test3.m4a', 'content'); file_put_contents('test4.other', 'content'); + file_put_contents('test5.m4b', 'content'); $filemtime = time(); touch('test1.mp3', $filemtime+50); touch('test2.mp4', $filemtime); touch('test3.m4a', $filemtime-50); touch('test4.other', $filemtime-100); + touch('test5.m4b', $filemtime-75); return $filemtime; } @@ -47,12 +49,14 @@ public function createEmptyTestItems() file_put_contents('test2.mp4', ''); file_put_contents('test3.m4a', ''); file_put_contents('test4.other', ''); + file_put_contents('test5.m4b', ''); $filemtime = time(); touch('test1.mp3', $filemtime+50); touch('test2.mp4', $filemtime); touch('test3.m4a', $filemtime-50); touch('test4.other', $filemtime-100); + touch('test5.m4b', $filemtime-75); return $filemtime; } @@ -65,7 +69,7 @@ public function test_empty_dir_leads_to_empty_podcast() $this->assertEquals(0, $mp->getMaxMtime()); } - public function test_three_supported_files_of_zero_length_not_added_to_podcast() + public function test_four_supported_files_of_zero_length_not_added_to_podcast() { $filemtime = $this->createEmptyTestItems(); @@ -75,17 +79,18 @@ public function test_three_supported_files_of_zero_length_not_added_to_podcast() $this->assertEquals(0, $mp->getMaxMtime()); } - public function test_three_supported_files_added_to_podcast() + public function test_four_supported_files_added_to_podcast() { $filemtime = $this->createTestItems(); $mp = $this->newPodcast(); $content = $mp->generate(); - $this->assertCount(3, $mp->getItems()); + $this->assertCount(4, $mp->getItems()); $items = $mp->getItems(); $this->assertInstanceOf(MP3_RSS_Item::class, $items[0]); $this->assertInstanceOf(MP4_RSS_Item::class, $items[1]); $this->assertInstanceOf(M4A_RSS_Item::class, $items[2]); + $this->assertInstanceOf(M4A_RSS_Item::class, $items[3]); $this->assertEquals($filemtime+50, $mp->getMaxMtime()); } @@ -100,12 +105,13 @@ public function test_generating_twice_doesnt_rescan() $content = $mp->generate(); // generate again - $this->assertCount(3, $mp->getItems()); + $this->assertCount(4, $mp->getItems()); $items = $mp->getItems(); $this->assertInstanceOf(MP3_RSS_Item::class, $items[0]); $this->assertInstanceOf(MP4_RSS_Item::class, $items[1]); $this->assertInstanceOf(M4A_RSS_Item::class, $items[2]); + $this->assertInstanceOf(M4A_RSS_Item::class, $items[3]); $this->assertEquals($filemtime+50, $mp->getMaxMtime()); } @@ -122,6 +128,7 @@ public function test_regenerates_if_metadata_files_added() $this->assertInstanceOf(MP3_RSS_Item::class, $items[0]); $this->assertInstanceOf(MP4_RSS_Item::class, $items[1]); $this->assertInstanceOf(M4A_RSS_Item::class, $items[2]); + $this->assertInstanceOf(M4A_RSS_Item::class, $items[3]); $this->assertEquals($filemtime+50 - 200, $mp->getMaxMtime()); unset($mp); // releases locks @@ -144,6 +151,7 @@ public function test_regenerates_if_metadata_files_added() $this->assertInstanceOf(MP3_RSS_Item::class, $items[0]); $this->assertInstanceOf(MP4_RSS_Item::class, $items[1]); $this->assertInstanceOf(M4A_RSS_Item::class, $items[2]); + $this->assertInstanceOf(M4A_RSS_Item::class, $items[3]); $this->assertEquals($now-500, $mp->getMaxMtime()); $this->assertEquals('party123', $items[1]->getSummary()); @@ -157,10 +165,10 @@ public function test_helpers_added_to_found_items() $mp = $this->newPodcast(); $helper = $this->createMock(Podcast_Helper::class); - $helper->expects($this->exactly(3))->method('appendToItem'); + $helper->expects($this->exactly(4))->method('appendToItem'); $helper2 = $this->createMock(Podcast_Helper::class); - $helper2->expects($this->exactly(3))->method('appendToItem'); + $helper2->expects($this->exactly(4))->method('appendToItem'); $mp->addHelper($helper); $mp->addHelper($helper2); @@ -200,6 +208,7 @@ protected function delete_test_files() file_exists('test3.m4a') && unlink('test3.m4a'); file_exists('test4.other') && unlink('test4.other'); file_exists('test2.txt') && unlink('test2.txt'); + file_exists('test5.m4b') && unlink('test5.m4b'); } public function tearDown(): void diff --git a/test/Dir_Podcast_RecursiveTest.php b/test/Dir_Podcast_RecursiveTest.php index 6f39dbb..b84d41d 100644 --- a/test/Dir_Podcast_RecursiveTest.php +++ b/test/Dir_Podcast_RecursiveTest.php @@ -22,16 +22,19 @@ public function createTestItems() mkdir('test2'); mkdir('test3'); mkdir('test4'); + mkdir('test5'); file_put_contents('test1/test1.mp3', 'content'); file_put_contents('test2/test2.mp4', 'content'); file_put_contents('test3/test3.m4a', 'content'); file_put_contents('test4/test4.other', 'content'); + file_put_contents('test5/test5.m4b', 'content'); $filemtime = time(); touch('test1/test1.mp3', $filemtime+50); touch('test2/test2.mp4', $filemtime); touch('test3/test3.m4a', $filemtime-50); touch('test4/test4.other', $filemtime-100); + touch('test5/test5.m4b', $filemtime-75); return $filemtime; } @@ -42,16 +45,19 @@ public function createEmptyTestItems() mkdir('test2'); mkdir('test3'); mkdir('test4'); + mkdir('test5'); file_put_contents('test1/test1.mp3', ''); file_put_contents('test2/test2.mp4', ''); file_put_contents('test3/test3.m4a', ''); file_put_contents('test4/test4.other', ''); + file_put_contents('test5/test5.m4b', ''); $filemtime = time(); touch('test1/test1.mp3', $filemtime+50); touch('test2/test2.mp4', $filemtime); touch('test3/test3.m4a', $filemtime-50); touch('test4/test4.other', $filemtime-100); + touch('test5/test5.m4b', $filemtime-75); return $filemtime; } @@ -69,10 +75,12 @@ protected function delete_test_files() file_exists('test2/test2.mp4') && unlink('test2/test2.mp4'); file_exists('test3/test3.m4a') && unlink('test3/test3.m4a'); file_exists('test4/test4.other') && unlink('test4/test4.other'); + file_exists('test5/test5.m4b') && unlink('test5/test5.m4b'); is_dir('test1') && rmdir('test1'); is_dir('test2') && rmdir('test2'); is_dir('test3') && rmdir('test3'); is_dir('test4') && rmdir('test4'); + is_dir('test5') && rmdir('test5'); parent::delete_test_files(); } @@ -89,6 +97,7 @@ public function test_regenerates_if_metadata_files_added() $this->assertInstanceOf(MP3_RSS_Item::class, $items[0]); $this->assertInstanceOf(MP4_RSS_Item::class, $items[1]); $this->assertInstanceOf(M4A_RSS_Item::class, $items[2]); + $this->assertInstanceOf(M4A_RSS_Item::class, $items[3]); $this->assertEquals($filemtime+50 - 200, $mp->getMaxMtime()); unset($mp); // releases locks @@ -111,6 +120,7 @@ public function test_regenerates_if_metadata_files_added() $this->assertInstanceOf(MP3_RSS_Item::class, $items[0]); $this->assertInstanceOf(MP4_RSS_Item::class, $items[1]); $this->assertInstanceOf(M4A_RSS_Item::class, $items[2]); + $this->assertInstanceOf(M4A_RSS_Item::class, $items[3]); $this->assertEquals($now-500, $mp->getMaxMtime()); $this->assertEquals('party123', $items[1]->getSummary()); From c909d7ac7967d300fc55ebe5ef86a2a04ffb8615 Mon Sep 17 00:00:00 2001 From: Ben XO <75862+ben-xo@users.noreply.github.com> Date: Thu, 28 Jul 2022 22:02:21 +0100 Subject: [PATCH 4/4] Update for release v1.34 --- CHANGELOG.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 96f8f3e..9d280de 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,7 +1,8 @@ Changelog ========= -1.34 unreleased * Add support for M4B audiobook files as requested by @crosbyh +1.34 2022-07-28 * Add support for M4B audiobook files as requested by @crosbyh + Many thanks for your support! 1.33 2022-05-25 * README fixed by @denilsonsa - thanks! * Caching algorithm changed to so that it is no longer dependent