diff --git a/src/Youtube.php b/src/Youtube.php index 6c1fe0c..dcc431e 100644 --- a/src/Youtube.php +++ b/src/Youtube.php @@ -376,6 +376,24 @@ public function getPlaylistsByChannelId($channelId, $optionalParams = array()) $apiData = $this->api_get($API_URL, $params); return $this->decodeList($apiData); } + + /** + * @param $url + * @return String + * @throws \Exception + */ + public function parseChannelIdFromUrl($url) { + + $url = parse_url($url); + $id = end(explode('/', $url['path'])); + + if (empty($id)) { + throw new \InvalidArgumentException('channel url is not correct.'); + } + + return $id; + } + /**