Video: Add section for full url to video, also little refactor and fix compatibility for VK4ME

This commit is contained in:
veselcraft 2023-02-21 00:35:10 +03:00
parent 0da679fae6
commit 54092eb6c0
No known key found for this signature in database
GPG key ID: AED66BC1AC628A4E
3 changed files with 52 additions and 77 deletions

View file

@ -25,49 +25,7 @@ final class Video extends VKAPIRequestHandler
$video = (new VideosRepo)->getByOwnerAndVID(intval($id[0]), intval($id[1])); $video = (new VideosRepo)->getByOwnerAndVID(intval($id[0]), intval($id[1]));
if($video) { if($video) {
$items[] = [ $items[] = $video->getApiStructure();
"type" => "video",
"video" => [
"can_comment" => 1,
"can_like" => 0, // we don't h-have wikes in videos
"can_repost" => 0,
"can_subscribe" => 1,
"can_add_to_faves" => 0,
"can_add" => 0,
"comments" => $video->getCommentsCount(),
"date" => $video->getPublicationTime()->timestamp(),
"description" => $video->getDescription(),
"duration" => 0, // я хуй знает как получить длину видео
"image" => [
[
"url" => $video->getThumbnailURL(),
"width" => 320,
"height" => 240,
"with_padding" => 1
]
],
"width" => 640,
"height" => 480,
"id" => $video->getVirtualId(),
"owner_id" => $video->getOwner()->getId(),
"user_id" => $video->getOwner()->getId(),
"title" => $video->getName(),
"is_favorite" => false,
"player" => $video->getURL(),
"added" => 0,
"repeat" => 0,
"type" => "video",
"views" => 0,
"likes" => [
"count" => 0,
"user_likes" => 0
],
"reposts" => [
"count" => 0,
"user_reposted" => 0
]
]
];
} }
} }

View file

@ -49,40 +49,7 @@ final class Wall extends VKAPIRequestHandler
} else if($attachment instanceof \openvk\Web\Models\Entities\Poll) { } else if($attachment instanceof \openvk\Web\Models\Entities\Poll) {
$attachments[] = $this->getApiPoll($attachment, $this->getUser()); $attachments[] = $this->getApiPoll($attachment, $this->getUser());
} else if ($attachment instanceof \openvk\Web\Models\Entities\Video) { } else if ($attachment instanceof \openvk\Web\Models\Entities\Video) {
$video = [ $attachments[] = $attachment->getApiStructure();
"type" => "video",
"video" => [
"can_comment" => 1,
"can_like" => 0, // we don't h-have wikes in videos
"can_repost" => 0,
"can_subscribe" => 1,
"can_add_to_faves" => 0,
"can_add" => 0,
"comments" => $attachment->getCommentsCount(),
"date" => $attachment->getPublicationTime()->timestamp(),
"description" => $attachment->getDescription(),
"duration" => 0, // я хуй знает как получить длину видео
"image" => [
[
"url" => $attachment->getThumbnailURL(),
"width" => 320,
"height" => 240,
"with_padding" => 1
]
],
"width" => 640,
"height" => 480,
"id" => $attachment->getVirtualId(),
"owner_id" => $attachment->getOwner()->getId(),
"user_id" => $attachment->getOwner()->getId(),
"title" => $attachment->getName(),
"is_favorite" => false,
"repeat" => 0,
"type" => "video",
"views" => 0, // у нас просмотров нет)
]
];
$attachments[] = $video;
} else if ($attachment instanceof \openvk\Web\Models\Entities\Post) { } else if ($attachment instanceof \openvk\Web\Models\Entities\Post) {
$repostAttachments = []; $repostAttachments = [];

View file

@ -114,6 +114,56 @@ class Video extends Media
{ {
return $this->getRecord()->owner; return $this->getRecord()->owner;
} }
function getApiStructure(): object
{
return (object)[
"type" => "video",
"video" => [
"can_comment" => 1,
"can_like" => 0, // we don't h-have wikes in videos
"can_repost" => 0,
"can_subscribe" => 1,
"can_add_to_faves" => 0,
"can_add" => 0,
"comments" => $this->getCommentsCount(),
"date" => $this->getPublicationTime()->timestamp(),
"description" => $this->getDescription(),
"duration" => 0, // я хуй знает как получить длину видео
"image" => [
[
"url" => $this->getThumbnailURL(),
"width" => 320,
"height" => 240,
"with_padding" => 1
]
],
"width" => 640,
"height" => 480,
"id" => $this->getVirtualId(),
"owner_id" => $this->getOwner()->getId(),
"user_id" => $this->getOwner()->getId(),
"title" => $this->getName(),
"is_favorite" => false,
"player" => $this->getURL(),
"files" => [
"mp4_480" => $this->getURL()
],
"added" => 0,
"repeat" => 0,
"type" => "video",
"views" => 0,
"likes" => [
"count" => 0,
"user_likes" => 0
],
"reposts" => [
"count" => 0,
"user_reposted" => 0
]
]
];
}
function setLink(string $link): string function setLink(string $link): string
{ {