Andrew 3 tuần trước cách đây
mục cha
commit
1b0bcb4206
1 tập tin đã thay đổi với 8 bổ sung2 xóa
  1. 8 2
      app/Controllers/VideoController.php

+ 8 - 2
app/Controllers/VideoController.php

@@ -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");
 		});
 	}
 }