mirror of
https://github.com/openvk/openvk
synced 2024-11-11 01:19:53 +03:00
Video: Add section for full url to video, also little refactor and fix compatibility for VK4ME
This commit is contained in:
parent
0da679fae6
commit
54092eb6c0
3 changed files with 52 additions and 77 deletions
|
@ -25,49 +25,7 @@ final class Video extends VKAPIRequestHandler
|
|||
|
||||
$video = (new VideosRepo)->getByOwnerAndVID(intval($id[0]), intval($id[1]));
|
||||
if($video) {
|
||||
$items[] = [
|
||||
"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
|
||||
]
|
||||
]
|
||||
];
|
||||
$items[] = $video->getApiStructure();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,40 +49,7 @@ final class Wall extends VKAPIRequestHandler
|
|||
} else if($attachment instanceof \openvk\Web\Models\Entities\Poll) {
|
||||
$attachments[] = $this->getApiPoll($attachment, $this->getUser());
|
||||
} else if ($attachment instanceof \openvk\Web\Models\Entities\Video) {
|
||||
$video = [
|
||||
"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;
|
||||
$attachments[] = $attachment->getApiStructure();
|
||||
} else if ($attachment instanceof \openvk\Web\Models\Entities\Post) {
|
||||
$repostAttachments = [];
|
||||
|
||||
|
|
|
@ -114,6 +114,56 @@ class Video extends Media
|
|||
{
|
||||
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
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue