Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add videoCategoryId param to getPopularVideos #192

Merged
merged 2 commits into from
Mar 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Youtube.php
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,14 @@ public function getLocalizedVideoInfo($vId, $language, $part = ['id', 'snippet',
* @param array $part
* @return array
*/
public function getPopularVideos($regionCode, $maxResults = 10, $part = ['id', 'snippet', 'contentDetails', 'player', 'statistics', 'status'])
public function getPopularVideos($regionCode, $maxResults = 10, $part = ['id', 'snippet', 'contentDetails', 'player', 'statistics', 'status'], $videoCategoryId = 0)
{
$API_URL = $this->getApi('videos.list');
$params = [
'chart' => 'mostPopular',
'part' => implode(',', $part),
'regionCode' => $regionCode,
'videoCategoryId' => $videoCategoryId,
'maxResults' => $maxResults,
];

Expand Down
4 changes: 3 additions & 1 deletion tests/YoutubeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ public function testGetPopularVideos()
{
$maxResult = rand(10, 30);
$regionCode = 'us';
$response = $this->youtube->getPopularVideos($regionCode, $maxResult);
$videoCategoryId = 0;
$part = ['id', 'snippet', 'contentDetails', 'player', 'statistics', 'status'];
$response = $this->youtube->getPopularVideos($regionCode, $maxResult, $part, $videoCategoryId);

$this->assertNotNull('response');
$this->assertEquals($maxResult, count($response));
Expand Down
Loading