|
@@ -6,6 +6,7 @@ use app\Exceptions\AccountNotFoundException;
|
|
use app\Exceptions\CommentNotFoundException;
|
|
use app\Exceptions\CommentNotFoundException;
|
|
use app\Exceptions\VideoNotFoundException;
|
|
use app\Exceptions\VideoNotFoundException;
|
|
use app\Hajeebtok;
|
|
use app\Hajeebtok;
|
|
|
|
+use app\Types\DatabaseObjects\View;
|
|
use Pecee\SimpleRouter\SimpleRouter;
|
|
use Pecee\SimpleRouter\SimpleRouter;
|
|
use Mimey\MimeTypes;
|
|
use Mimey\MimeTypes;
|
|
use app\Interfaces\IRouteController;
|
|
use app\Interfaces\IRouteController;
|
|
@@ -56,7 +57,9 @@ class VideoController implements IRouteController
|
|
$author_information = new Account($video_information->author_id);
|
|
$author_information = new Account($video_information->author_id);
|
|
$author_information->Load();
|
|
$author_information->Load();
|
|
|
|
|
|
|
|
+ CORSHelper();
|
|
return api_json([
|
|
return api_json([
|
|
|
|
+ "id" => $video_information->id,
|
|
"title" => $video_information->title,
|
|
"title" => $video_information->title,
|
|
"description" => $video_information->description,
|
|
"description" => $video_information->description,
|
|
"likes" => $video_information->likes,
|
|
"likes" => $video_information->likes,
|
|
@@ -83,12 +86,13 @@ class VideoController implements IRouteController
|
|
$data = [];
|
|
$data = [];
|
|
foreach($videos as $vid) {
|
|
foreach($videos as $vid) {
|
|
$data[] = [
|
|
$data[] = [
|
|
|
|
+ "id" => $vid["id"],
|
|
"title" => $vid["title"],
|
|
"title" => $vid["title"],
|
|
"description" => $vid["description"],
|
|
"description" => $vid["description"],
|
|
"likes" => $vid["likes"],
|
|
"likes" => $vid["likes"],
|
|
"dislikes" => $vid["dislikes"],
|
|
"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" => [
|
|
"author" => [
|
|
"id" => $vid["author_id"],
|
|
"id" => $vid["author_id"],
|
|
"pictureHash" => $accounts[$vid["author_id"] - 1]["picture_hash"], // kinda scuffed fix
|
|
"pictureHash" => $accounts[$vid["author_id"] - 1]["picture_hash"], // kinda scuffed fix
|
|
@@ -97,6 +101,7 @@ class VideoController implements IRouteController
|
|
];
|
|
];
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ CORSHelper();
|
|
return api_json($data);
|
|
return api_json($data);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -120,6 +125,8 @@ class VideoController implements IRouteController
|
|
$mime_types = new MimeTypes();
|
|
$mime_types = new MimeTypes();
|
|
if(!file_exists($video_path)) throw new VideoNotFoundException($id, 404);
|
|
if(!file_exists($video_path)) throw new VideoNotFoundException($id, 404);
|
|
if(!file_exists($frame_path)) {
|
|
if(!file_exists($frame_path)) {
|
|
|
|
+ Logger::Debug("Generating thumbnail for video $id");
|
|
|
|
+
|
|
$ffmpeg = FFMpeg\FFMpeg::create();
|
|
$ffmpeg = FFMpeg\FFMpeg::create();
|
|
$video = $ffmpeg->open($video_path);
|
|
$video = $ffmpeg->open($video_path);
|
|
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds($seconds));
|
|
$frame = $video->frame(FFMpeg\Coordinate\TimeCode::fromSeconds($seconds));
|
|
@@ -135,6 +142,20 @@ class VideoController implements IRouteController
|
|
return file_get_contents($frame_path);
|
|
return file_get_contents($frame_path);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public static function getFeed(): string
|
|
|
|
+ {
|
|
|
|
+ $signed_in = signed_in(request());
|
|
|
|
+ if(!$signed_in) throw new AccountNotFoundException(0, 404);
|
|
|
|
+ $id = get_token_id(request());
|
|
|
|
+ $view = new View(account_id: $id);
|
|
|
|
+ $view->LoadMany();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ CORSHelper();
|
|
|
|
+ return api_json([]);
|
|
|
|
+ }
|
|
|
|
+
|
|
public static function RegisterRoutes(): void
|
|
public static function RegisterRoutes(): void
|
|
{
|
|
{
|
|
SimpleRouter::group([
|
|
SimpleRouter::group([
|
|
@@ -148,6 +169,8 @@ class VideoController implements IRouteController
|
|
SimpleRouter::options("/{id}", "CORSHelper");
|
|
SimpleRouter::options("/{id}", "CORSHelper");
|
|
SimpleRouter::options("/{id}/info", "CORSHelper");
|
|
SimpleRouter::options("/{id}/info", "CORSHelper");
|
|
SimpleRouter::options("/{id}/thumbnail", "CORSHelper");
|
|
SimpleRouter::options("/{id}/thumbnail", "CORSHelper");
|
|
|
|
+ SimpleRouter::options("/upload", "CORSHelper");
|
|
|
|
+ SimpleRouter::options("/search", "CORSHelper");
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|