<?php
|
|
|
|
namespace App\Http\Controllers;
|
|
|
|
use App\Services\FileService;
|
|
use Illuminate\Http\Request;
|
|
use Log;
|
|
|
|
class LiveVideoController extends Controller
|
|
{
|
|
const EVENT_TYPE_FILE_CLOSED = "FileClosed";
|
|
|
|
private $fileService;
|
|
public function __construct()
|
|
{
|
|
$this->fileService = new FileService();
|
|
}
|
|
|
|
//
|
|
public function add(Request $request)
|
|
{
|
|
$data = $request->json()->all();
|
|
$eventType = $data["EventType"];
|
|
$eventData = $data["EventData"];
|
|
Log::info("bilibili live record webhook data : ", json_encode($data));
|
|
if ($eventType == self::EVENT_TYPE_FILE_CLOSED) {
|
|
Log::info($eventData["RelativePath"]);
|
|
$this->fileService->renameFileAndAddToQueue("/mnt/e/rec/" . $eventData["RelativePath"], "flv", "mp4");
|
|
}
|
|
// Log::info($data["EventData"]);
|
|
// Log::info($data["EventType"]);
|
|
return response("", 200);
|
|
}
|
|
}
|