mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
VKAPI: Add owner_id support to video.get (not sure if this works cuz it's hot outside and i'm tired)
This commit is contained in:
parent
27fb0f1d90
commit
725e68d0e5
1 changed files with 35 additions and 15 deletions
|
@ -11,27 +11,47 @@ use openvk\Web\Models\Repositories\Comments as CommentsRepo;
|
||||||
|
|
||||||
final class Video extends VKAPIRequestHandler
|
final class Video extends VKAPIRequestHandler
|
||||||
{
|
{
|
||||||
function get(string $videos, int $offset = 0, int $count = 30, int $extended = 0): object
|
function get(int $owner_id, string $videos, int $offset = 0, int $count = 30, int $extended = 0): object
|
||||||
{
|
{
|
||||||
$this->requireUser();
|
$this->requireUser();
|
||||||
|
|
||||||
$vids = explode(',', $videos);
|
if ($videos) {
|
||||||
|
$vids = explode(',', $videos);
|
||||||
|
|
||||||
foreach($vids as $vid)
|
foreach($vids as $vid)
|
||||||
{
|
{
|
||||||
$id = explode("_", $vid);
|
$id = explode("_", $vid);
|
||||||
|
|
||||||
|
$items = [];
|
||||||
|
|
||||||
|
$video = (new VideosRepo)->getByOwnerAndVID(intval($id[0]), intval($id[1]));
|
||||||
|
if($video) {
|
||||||
|
$items[] = $video->getApiStructure();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (object) [
|
||||||
|
"count" => count($items),
|
||||||
|
"items" => $items
|
||||||
|
];
|
||||||
|
} else {
|
||||||
|
if ($owner_id > 0)
|
||||||
|
$user = (new UsersRepo)->get($owner_id);
|
||||||
|
else
|
||||||
|
$this->fail(1, "Not implemented");
|
||||||
|
|
||||||
|
$videos = (new VideosRepo)->getByUser($user, $offset + 1, $count);
|
||||||
|
$videosCount = (new VideosRepo)->getUserVideosCount($user);
|
||||||
|
|
||||||
$items = [];
|
$items = [];
|
||||||
|
foreach ($videos as $video) {
|
||||||
$video = (new VideosRepo)->getByOwnerAndVID(intval($id[0]), intval($id[1]));
|
|
||||||
if($video) {
|
|
||||||
$items[] = $video->getApiStructure();
|
$items[] = $video->getApiStructure();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return (object) [
|
return (object) [
|
||||||
"count" => count($items),
|
"count" => $videosCount,
|
||||||
"items" => $items
|
"items" => $items
|
||||||
];
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue