diff --git a/src/Exception/UrlNotSupportedException.php b/src/Exception/UrlNotSupportedException.php new file mode 100644 index 0000000..7e1cd39 --- /dev/null +++ b/src/Exception/UrlNotSupportedException.php @@ -0,0 +1,7 @@ +isUrlSupported($url)) { + throw new UrlNotSupportedException(sprintf('Provided url "%s" is not supported.', $url)); + } + $processBuilder = $this->createProcessBuilder([ $url, '--no-playlist', @@ -328,4 +333,13 @@ private function configureOptions(OptionsResolver $resolver) return $value; }); } + + private function isUrlSupported(string $url): bool + { + if (preg_match('#soundcloud.com/.+/sets.+#', $url)) { + return false; + } + + return true; + } } diff --git a/tests/YoutubeDl/YoutubeDlTest.php b/tests/YoutubeDl/YoutubeDlTest.php index 34afbe2..6ba870a 100644 --- a/tests/YoutubeDl/YoutubeDlTest.php +++ b/tests/YoutubeDl/YoutubeDlTest.php @@ -95,6 +95,17 @@ public function testYoutubeAccountTerminatedVideoDownload() $yt->download('https://www.youtube.com/watch?v=oIdgb-vwAQI'); } + /** + * @expectedException \YoutubeDl\Exception\UrlNotSupportedException + * @expectedExceptionMessageRegExp /Provided url ".+" is not supported\./ + */ + public function testUrlNotSupported() + { + $yt = new YoutubeDl(); + $yt->setDownloadPath('/'); + $yt->download('https://soundcloud.com/csimpi/sets/go4it-demo'); + } + /** * @expectedException \Symfony\Component\Process\Exception\ProcessFailedException */