@@ -15,7 +15,7 @@ public function getPageFromSlug(string $slug)
1515 {
1616 if ($ slug == '' ) {
1717 $ page = page (site ()->homePageId ());
18- } elseif (!$ page = page ($ slug )) {
18+ } elseif (!( $ page = page ($ slug) )) {
1919 $ page = page (kirby ()->router ()->call ($ slug ));
2020
2121 if ($ page ->isHomeOrErrorPage ()) {
@@ -32,10 +32,13 @@ public function getPageFromSlug(string $slug)
3232
3333 public function getPodcastFromId (string $ id )
3434 {
35- $ pages = site ()->index ()->filterBy ('template ' , 'podcasterfeed ' )->filter (function ($ child ) use ($ id ) {
36- return $ child ->podcastId ()->value () === $ id ;
37- })->first ();
38-
35+ $ pages = site ()
36+ ->index ()
37+ ->filterBy ('template ' , 'podcasterfeed ' )
38+ ->filter (function ($ child ) use ($ id ) {
39+ return $ child ->podcastId ()->value () === $ id ;
40+ })
41+ ->first ();
3942
4043 if (is_null ($ pages )) {
4144 return false ;
@@ -68,7 +71,8 @@ public function getFeedOfEpisode($episode)
6871
6972 public function getEpisodes ($ rssFeed )
7073 {
71- return $ rssFeed ->podcasterSource ()
74+ return $ rssFeed
75+ ->podcasterSource ()
7276 ->toPages ()
7377 ->children ()
7478 ->listed ()
@@ -77,7 +81,8 @@ public function getEpisodes($rssFeed)
7781 })
7882 ->filter (function ($ child ) {
7983 return $ child ->hasAudio ();
80- })->sortBy ('date ' , 'desc ' );
84+ })
85+ ->sortBy ('date ' , 'desc ' );
8186 }
8287
8388 public function getAudioFile ($ episode )
@@ -137,7 +142,7 @@ public function getPodloveRoles($episodeSlug)
137142 [
138143 'id ' => '1 ' ,
139144 'title ' => 'Team ' ,
140- ]
145+ ],
141146 ];
142147 }
143148
@@ -147,7 +152,7 @@ public function getPodloveRoles($episodeSlug)
147152 [
148153 'id ' => '1 ' ,
149154 'title ' => 'Team ' ,
150- ]
155+ ],
151156 ];
152157 }
153158
@@ -156,7 +161,7 @@ public function getPodloveRoles($episodeSlug)
156161 [
157162 'id ' => '1 ' ,
158163 'title ' => 'Team ' ,
159- ]
164+ ],
160165 ];
161166 }
162167
@@ -165,7 +170,7 @@ public function getPodloveRoles($episodeSlug)
165170
166171 foreach ($ podloveRoles as $ role ) {
167172 $ roles [] = [
168- 'id ' => (string )$ role ->roleId ()->value (),
173+ 'id ' => (string ) $ role ->roleId ()->value (),
169174 'title ' => $ role ->roleTitle ()->value (),
170175 ];
171176 }
@@ -181,7 +186,7 @@ public function getPodloveGroups($episodeSlug)
181186 [
182187 'id ' => '1 ' ,
183188 'title ' => 'Team ' ,
184- ]
189+ ],
185190 ];
186191 }
187192
@@ -192,7 +197,7 @@ public function getPodloveGroups($episodeSlug)
192197 [
193198 'id ' => '1 ' ,
194199 'title ' => 'Team ' ,
195- ]
200+ ],
196201 ];
197202 }
198203
@@ -201,7 +206,7 @@ public function getPodloveGroups($episodeSlug)
201206 [
202207 'id ' => '1 ' ,
203208 'title ' => 'Team ' ,
204- ]
209+ ],
205210 ];
206211 }
207212
@@ -210,7 +215,7 @@ public function getPodloveGroups($episodeSlug)
210215
211216 foreach ($ podloveRoles as $ role ) {
212217 $ roles [] = [
213- 'id ' => (string )$ role ->roleId ()->value (),
218+ 'id ' => (string ) $ role ->roleId ()->value (),
214219 'title ' => $ role ->roleTitle ()->value (),
215220 ];
216221 }
@@ -263,6 +268,30 @@ public function getPodloveContributors($contributorsField, $contributorRoles, $c
263268 return $ contributors ;
264269 }
265270
271+ public function getPodloveTranscripts ($ episode )
272+ {
273+ if ($ episode ->podcasterTranscript ()->isEmpty ()) {
274+ return null ;
275+ }
276+
277+ $ transcripts = $ episode ->podcasterTranscript ()->toStructure ();
278+ $ podloveTranscripts = [];
279+ foreach ($ transcripts as $ transcript ) {
280+ $ podloveTranscript = [
281+ 'language ' => $ transcript ->podcasterTranscriptLanguage ()->value (),
282+ 'url ' => $ transcript ->podcasterTranscriptFile ()->toFile ()->url (),
283+ ];
284+
285+ $ podloveTranscripts [] = $ podloveTranscript ;
286+ }
287+
288+ if (is_null ($ podloveTranscripts [0 ])) {
289+ return null ;
290+ }
291+
292+ return $ podloveTranscripts [0 ]['url ' ];
293+ }
294+
266295 public function getPodloveFonts ($ feed )
267296 {
268297 if ($ feed ->podcasterPodloveFonts ()->isEmpty ()) {
@@ -361,16 +390,20 @@ public function getPodloveEpisodeJson($episode)
361390 $ enclosure = $ feedUtils ->getAudioEnclosures ($ episode , $ audio );
362391 $ audioDuration = $ feedUtils ->getAudioDuration ($ audio );
363392 $ chapters = $ feedUtils ->getChapters ($ episode , true , true );
364- $ contributors = $ this ->getPodloveContributors ($ episode ->podcasterContributors (), $ feed ->podcasterPodloveRoles (), $ feed ->podcasterPodloveGroups ());
365-
393+ $ contributors = $ this ->getPodloveContributors (
394+ $ episode ->podcasterContributors (),
395+ $ feed ->podcasterPodloveRoles (),
396+ $ feed ->podcasterPodloveGroups ()
397+ );
398+ $ transcript = $ this ->getPodloveTranscripts ($ episode );
366399 return [
367400 'version ' => 5 ,
368401 'show ' => [
369402 'title ' => $ feed ->podcasterTitle ()->value (),
370403 'subtitle ' => $ feed ->podcasterSubtitle ()->value (),
371404 'summary ' => $ feed ->podcasterDescription ()->value (),
372405 'poster ' => $ feed ->podcasterCover ()->toFile ()->url (),
373- 'link ' => $ feed ->podcasterLink ()->value ()
406+ 'link ' => $ feed ->podcasterLink ()->value (),
374407 ],
375408 'title ' => $ episode ->podcasterTitle ()->value (),
376409 'subtitle ' => $ episode ->podcasterSubtitle ()->value (),
@@ -383,36 +416,22 @@ public function getPodloveEpisodeJson($episode)
383416 [
384417 'url ' => $ enclosure ['url ' ],
385418 'size ' => $ enclosure ['length ' ],
386- 'title ' => " MP3 Audio " ,
387- 'mimeType ' => " audio/mpeg "
388- ]
419+ 'title ' => ' MP3 Audio ' ,
420+ 'mimeType ' => ' audio/mpeg ' ,
421+ ],
389422 ],
390423 'files ' => [
391424 [
392425 'url ' => $ enclosure ['url ' ],
393426 'size ' => $ enclosure ['length ' ],
394- 'title ' => " MP3 Audio " ,
395- 'mimeType ' => " audio/mpeg "
396- ]
427+ 'title ' => ' MP3 Audio ' ,
428+ 'mimeType ' => ' audio/mpeg ' ,
429+ ],
397430 ],
398431 'chapters ' => $ chapters ,
399432 'contributors ' => $ contributors ,
433+ 'transcripts ' => $ transcript ,
400434 ];
401- /*
402- // TODO
403- "transcripts" => [
404- [
405- "start" => "00:00:00.005",
406- "start_ms" => 5,
407- "end" => "00:00:09.458",
408- "end_ms" => 9458,
409- "speaker" => "3",
410- "voice" => "Eric",
411- "text" => "Dann sage ich einfach mal: Hallo und willkommen zu Episode drei des Podlovers Podcasts. Heute das erste Mal mit Gast. Hallo Simon."
412- ],
413- ]
414- ];
415- */
416435 }
417436
418437 public function getPodloveConfigJson ($ episode )
@@ -428,7 +447,7 @@ public function getPodloveConfigJson($episode)
428447 'base ' => 'player/ ' ,
429448 'activeTab ' => $ feed ->podcasterPodloveActiveTab ()->value (),
430449 'subscribe-button ' => [
431- 'feed ' => $ feed ->url ()
450+ 'feed ' => $ feed ->url (),
432451 ],
433452 ];
434453
@@ -461,7 +480,7 @@ public function getAppleMetadata($endpoint)
461480
462481 if (option ('mauricerenck.podcaster.useApi ' , true )) {
463482 $ apiCache = kirby ()->cache ('mauricerenck.podcaster ' );
464- $ jsonString = $ apiCache ->get ($ endpoint );
483+ $ jsonString = $ apiCache ->get ($ endpoint );
465484
466485 if ($ jsonString === null ) {
467486 $ response = new Remote ('https://api.podcaster-plugin.com/ ' . $ endpoint );
0 commit comments