Skip to content

Commit

Permalink
add getChannelArchive
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmorbo committed Nov 27, 2023
1 parent e58825a commit 427954f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/Controller/InstanceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use AlexMorbo\React\Trassir\Router\Router;
use AlexMorbo\React\Trassir\Traits\DBTrait;
use AlexMorbo\React\Trassir\TrassirHelper;
use Carbon\Carbon;
use Clue\React\SQLite\DatabaseInterface;
use Fig\Http\Message\StatusCodeInterface;
use Psr\Http\Message\ServerRequestInterface;
Expand Down Expand Up @@ -62,6 +63,15 @@ public function addRoutes(Router $router): void
$stream
)
);
$router->get(
"/api/instance/{instanceId}/channel/{channelId}/archive/{start}/{end}",
fn(ServerRequestInterface $request, $instanceId, $channelId, $start, $end) => $this->getChannelArchive(
$instanceId,
$channelId,
$start,
$end,
)
);
}

public function getInstances(): PromiseInterface
Expand Down Expand Up @@ -298,5 +308,26 @@ function ($video) use ($request) {
);
}

public function getChannelArchive(string $instanceId, string $channelId, string $start, string $end): PromiseInterface
{
return $this->trassirHelper->getInstance($instanceId)
->then(
function (Instance $instance) use ($channelId, $start, $end) {
$from = Carbon::parse(urldecode($start));
$to = Carbon::parse(urldecode($end));

return $instance->getTrassir()(
$instance->getName(),
$channelId,
$container,
$stream
);
return resolve(Response::json([
'from' => $from,
'to' => $to
]));
}
);
}

}

0 comments on commit 427954f

Please sign in to comment.