diff --git a/VKAPI/Handlers/Video.php b/VKAPI/Handlers/Video.php index c7c203db..7198f766 100755 --- a/VKAPI/Handlers/Video.php +++ b/VKAPI/Handlers/Video.php @@ -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(); } } diff --git a/VKAPI/Handlers/Wall.php b/VKAPI/Handlers/Wall.php index 795a8c62..758b174e 100644 --- a/VKAPI/Handlers/Wall.php +++ b/VKAPI/Handlers/Wall.php @@ -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 = []; diff --git a/Web/Models/Entities/Video.php b/Web/Models/Entities/Video.php index 6641f509..ee53b378 100644 --- a/Web/Models/Entities/Video.php +++ b/Web/Models/Entities/Video.php @@ -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 {