VANA/VANA-php/app/Srgssr/Video.php

49 lines
935 B
PHP

<?php
namespace App\Srgssr;
use Illuminate\Support\Facades\Http;
use App\Srgssr\Api;
use App\Models\Episode as EpisodeModel;
class Video extends Api
{
public function __construct()
{
$this->endpoint = 'https://api.srgssr.ch/videometadata/v2/';
parent::__construct();
}
public function mediaComposition(string $videoId)
{
$response = Http::withHeaders($this->headers)->withQueryParameters([
'bu' => 'srf',
])->get($this->endpoint.$videoId.'/mediaComposition');
if($response->successful()){
return $response->json();
}
return false;
}
public function savemediaComposition(string $videoId)
{
$mediaComposition = $this->mediaComposition($videoId);
if($mediaComposition){
$episode = new EpisodeModel;
$episode->urn = $mediaComposition['episode']['id'];
}
}
}