mirror of
https://github.com/ad-aures/castopod.git
synced 2026-04-14 12:07:46 +02:00
feat: add transcript display to episode page
+ fix transcript parser closes #411
This commit is contained in:
parent
88851b0226
commit
4d141fceae
9 changed files with 274 additions and 23 deletions
|
|
@ -13,7 +13,6 @@ namespace App\Controllers;
|
|||
use App\Entities\Episode;
|
||||
use App\Models\EpisodeModel;
|
||||
use CodeIgniter\Exceptions\PageNotFoundException;
|
||||
use CodeIgniter\HTTP\RedirectResponse;
|
||||
use Modules\Media\FileManagers\FileManagerInterface;
|
||||
|
||||
class EpisodePreviewController extends BaseController
|
||||
|
|
@ -45,7 +44,7 @@ class EpisodePreviewController extends BaseController
|
|||
return $this->{$method}(...$params);
|
||||
}
|
||||
|
||||
public function index(): RedirectResponse | string
|
||||
public function index(): string
|
||||
{
|
||||
helper('form');
|
||||
|
||||
|
|
@ -55,7 +54,7 @@ class EpisodePreviewController extends BaseController
|
|||
]);
|
||||
}
|
||||
|
||||
public function activity(): RedirectResponse | string
|
||||
public function activity(): string
|
||||
{
|
||||
helper('form');
|
||||
|
||||
|
|
@ -65,7 +64,7 @@ class EpisodePreviewController extends BaseController
|
|||
]);
|
||||
}
|
||||
|
||||
public function chapters(): RedirectResponse | string
|
||||
public function chapters(): string
|
||||
{
|
||||
$data = [
|
||||
'podcast' => $this->episode->podcast,
|
||||
|
|
@ -84,4 +83,30 @@ class EpisodePreviewController extends BaseController
|
|||
helper('form');
|
||||
return view('episode/preview-chapters', $data);
|
||||
}
|
||||
|
||||
public function transcript(): string
|
||||
{
|
||||
// get transcript from json file
|
||||
$data = [
|
||||
'podcast' => $this->episode->podcast,
|
||||
'episode' => $this->episode,
|
||||
];
|
||||
|
||||
if ($this->episode->transcript !== null) {
|
||||
$data['transcript'] = $this->episode->transcript;
|
||||
|
||||
if ($this->episode->transcript->json_key !== null) {
|
||||
/** @var FileManagerInterface $fileManager */
|
||||
$fileManager = service('file_manager');
|
||||
$transcriptJsonString = (string) $fileManager->getFileContents(
|
||||
$this->episode->transcript->json_key
|
||||
);
|
||||
|
||||
$data['captions'] = json_decode($transcriptJsonString, true);
|
||||
}
|
||||
}
|
||||
|
||||
helper('form');
|
||||
return view('episode/preview-transcript', $data);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue