|
@@ -83,12 +83,13 @@ class VideoController implements IRouteController
|
|
|
$data = [];
|
|
|
foreach($videos as $vid) {
|
|
|
$data[] = [
|
|
|
+ "id" => $vid["id"],
|
|
|
"title" => $vid["title"],
|
|
|
"description" => $vid["description"],
|
|
|
"likes" => $vid["likes"],
|
|
|
"dislikes" => $vid["dislikes"],
|
|
|
- "comments" => $vid["comments"],
|
|
|
- "shares" => $vid["shares"],
|
|
|
+ "comments" => Hajeebtok::$Database->Single("SELECT COUNT(*) FROM comments WHERE video_id = :id", ["id" => $vid["id"]]),
|
|
|
+ "shares" => Hajeebtok::$Database->Single("SELECT COUNT(*) FROM messages INNER JOIN videos ON messages.video_id = videos.id WHERE videos.id = :id", ["id" => $vid["id"]]),
|
|
|
"author" => [
|
|
|
"id" => $vid["author_id"],
|
|
|
"pictureHash" => $accounts[$vid["author_id"] - 1]["picture_hash"], // kinda scuffed fix
|
|
@@ -97,6 +98,7 @@ class VideoController implements IRouteController
|
|
|
];
|
|
|
}
|
|
|
|
|
|
+ CORSHelper();
|
|
|
return api_json($data);
|
|
|
}
|
|
|
|
|
@@ -120,6 +122,8 @@ class VideoController implements IRouteController
|
|
|
$mime_types = new MimeTypes();
|
|
|
if(!file_exists($video_path)) throw new VideoNotFoundException($id, 404);
|
|
|
if(!file_exists($frame_path)) {
|
|
|
+ Logger::Debug("Generating thumbnail for video $id");
|
|
|
+
|
|
|
$ffmpeg = FFMpeg\FFMpeg::create();
|
|
|
$video = $ffmpeg->open($video_path);
|
|
|
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds($seconds));
|
|
@@ -148,6 +152,8 @@ class VideoController implements IRouteController
|
|
|
SimpleRouter::options("/{id}", "CORSHelper");
|
|
|
SimpleRouter::options("/{id}/info", "CORSHelper");
|
|
|
SimpleRouter::options("/{id}/thumbnail", "CORSHelper");
|
|
|
+ SimpleRouter::options("/upload", "CORSHelper");
|
|
|
+ SimpleRouter::options("/search", "CORSHelper");
|
|
|
});
|
|
|
}
|
|
|
}
|