| @@ 358-378 (lines=21) @@ | ||
| 355 | * |
|
| 356 | * @return string |
|
| 357 | */ |
|
| 358 | public function downloadSubtitle( |
|
| 359 | int $id, |
|
| 360 | string $format, |
|
| 361 | string $path, |
|
| 362 | string $filename = null, |
|
| 363 | string $key = 'default' |
|
| 364 | ) { |
|
| 365 | if (! $filename) { |
|
| 366 | $response = $this->get($id); |
|
| 367 | $filename = pathinfo(json_decode($response, true)['file']['name'], PATHINFO_FILENAME).".{$format}"; |
|
| 368 | } |
|
| 369 | ||
| 370 | return $this->client->get( |
|
| 371 | sprintf('files/%d/subtitles/%s', $id, $key), |
|
| 372 | ['format' => $format], |
|
| 373 | [ |
|
| 374 | 'sink' => "{$path}/{$filename}", |
|
| 375 | 'allow_redirects' => false, |
|
| 376 | ] |
|
| 377 | ); |
|
| 378 | } |
|
| 379 | ||
| 380 | /** |
|
| 381 | * Serves a HLS playlist for a video file. |
|
| @@ 394-409 (lines=16) @@ | ||
| 391 | * |
|
| 392 | * @return string |
|
| 393 | */ |
|
| 394 | public function hlsPlaylist(int $id, string $path, string $filename = null, string $subtitle_key = 'all') |
|
| 395 | { |
|
| 396 | if (! $filename) { |
|
| 397 | $response = $this->get($id); |
|
| 398 | $filename = pathinfo(json_decode($response, true)['file']['name'], PATHINFO_FILENAME); |
|
| 399 | } |
|
| 400 | ||
| 401 | return $this->client->get( |
|
| 402 | sprintf('files/%d/hls/media.m3u8', $id), |
|
| 403 | ['subtitle_key' => $subtitle_key], |
|
| 404 | [ |
|
| 405 | 'sink' => "{$path}/{$filename}.m3u8", |
|
| 406 | 'allow_redirects' => false, |
|
| 407 | ] |
|
| 408 | ); |
|
| 409 | } |
|
| 410 | ||
| 411 | /** |
|
| 412 | * List of dashboard events. Includes download and share events. |
|