diff --git a/include/Helper/Url.php b/include/Helper/Url.php index 952836d2..fd7cc0d8 100644 --- a/include/Helper/Url.php +++ b/include/Helper/Url.php @@ -64,6 +64,7 @@ class Url 'searchChannels' => [ 'endpoint' => 'search', 'query' => [ + 'q' => '', 'part' => [ 'id', 'snippet', @@ -72,7 +73,6 @@ class Url 'items(id(channelId)', 'snippet(title))' ], - 'q' => '', 'type' => 'channel', 'maxResults' => 1 ], @@ -80,6 +80,7 @@ class Url 'searchPlaylists' => [ 'endpoint' => 'search', 'query' => [ + 'q' => '', 'part' => [ 'id', 'snippet', @@ -88,7 +89,6 @@ class Url 'items(id(playlistId)', 'snippet(title))' ], - 'q' => '', 'type' => 'playlist', 'maxResults' => 1 ], @@ -235,10 +235,10 @@ public static function getApi(string $type, string $parameter, string $apiKey) foreach (self::$apiEndpoints[$type]['query'] as $name => $section) { if (is_array($section) === true) { $query[$name] = implode(',', $section); - } elseif ($name === 'q') { - $query[$name] = urlencode($parameter); - } else { + } elseif ($name === 'q' || $name === 'id') { $query[$name] = $parameter; + } else { + $query[$name] = $section; } } diff --git a/tests/files/helper-url-samples.json b/tests/files/helper-url-samples.json index de7a2d71..e35e6880 100644 --- a/tests/files/helper-url-samples.json +++ b/tests/files/helper-url-samples.json @@ -60,12 +60,12 @@ "value" :"jNQXAC9IVRw" }, { - "url": "https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&fields=items%28id%28channelId%29%2Csnippet%28title%29%29&q=jawed&type=jawed&maxResults=jawed&prettyPrint=true&key=ApiKeyHere", + "url": "https://www.googleapis.com/youtube/v3/search?q=jawed&part=id%2Csnippet&fields=items%28id%28channelId%29%2Csnippet%28title%29%29&type=channel&maxResults=1&prettyPrint=true&key=ApiKeyHere", "type": "searchChannels", "value" :"jawed" }, { - "url": "https://www.googleapis.com/youtube/v3/search?part=id%2Csnippet&fields=items%28id%28playlistId%29%2Csnippet%28title%29%29&q=YouTube%2BRewind%2B2018&type=YouTube+Rewind+2018&maxResults=YouTube+Rewind+2018&prettyPrint=true&key=ApiKeyHere", + "url": "https://www.googleapis.com/youtube/v3/search?q=YouTube+Rewind+2018&part=id%2Csnippet&fields=items%28id%28playlistId%29%2Csnippet%28title%29%29&type=playlist&maxResults=1&prettyPrint=true&key=ApiKeyHere", "type": "searchPlaylists", "value" :"YouTube Rewind 2018" }