Introducción
A continuación se muestran dos aplicaciones PHP para generar feeds para iTunes y Ruku, usando la API de reproducción como fuente de información de video.
Generador de fuentes de iTunes
// UPDATED sample Video Cloud iTunes feed
// Please use this at your own risk.
// This is just a sample to get you started. You can customize further as your requirements
// grow.
// The following is a list of requirements and conditions in order for this podcast feed
// to function properly;
//1) You must have a Pro or Enterprise level Video Cloud Account.
//2) You need to create the following custom fields. They are in your Account Settings:
// Video Fields page on the Video Cloud Studio Home page:
// 1) itunesartist(text)
// 2) explicit(text) values = yes|no, true|false, explicit|clean
//
//3) You will have to manually or programmatically set the custom metadata values when you
// upload content.
// Please customize the variables below:
// This is the title of the podcast itself.
$title = "Test Podcast";
// This is a link to where the podcast can be found.
$link = "https://www.someplace.com/php/brightcove_itunes.php";
// This is the language you display for this podcast.
$lang = "en-us";
// This is the copyright information.
$copyright = "℗ & © 2021 Updated iTunes Feed";
// This is the subtitle of the podcast.
$subtitle = "iTunes Test XML FEED via the Video Cloud Playback APIs";
// This is the author's name.
$author = "Some One";
// The publication date of this iTunes Feed
$pubDate = date("m-d-Y"); // OPTIONALLY USE THE "updated_at" VARIABLE FROM THE RETURNED JSON
// This is the summary for the podcast.
$summary = "This is a sample iTunes XML generated from Video Cloud.";
// This is a description of this iTunes Feed.
$description= "Description of the Video Cloud iTunes Test Feed";
// This is the owner's name.
$ownername = "Some One";
// This is the owner's email address.
$owneremail = "someone@somewhere.com";
// This is the podcast thumbnail image url.
$imageurl = "https://www.someplace.com/php/logo.jpg";
// This is the podcast category.
$category = "TV & Film";
// This is a yes or no boolean if the podcast is explicit.
$explicit = "no";
//Brightcove Account ID
$accountId = "123456789";
// This is your Policy Key associated with your account.
$policyKey = "mMm1VoineewK4tkFbfDakfEwYInEMSa_fAJ7HxVMIN1ItBJHXEDYGMnPbJrkK0U";
// The ID of the playlist you wish to publish.
$playlistid = "987654321";
// This is the baseURL of the API endpoint you would like to use
$baseURL = "https://edge.api.brightcove.com/playback/v1/accounts/";
// Please DO NOT alter the code below;
print('');
eco"\\n";
imprimir('');
eco"\\n";
imprimir('');
eco"\\n";
imprimir(' '. $título .' ');
eco"\\n";
imprimir(' '. $enlace .'');
eco"\\n";
imprimir(' '. $lang .' ');
eco"\\n";
imprimir(' '. $derechos de autor .' ');
eco"\\n";
imprimir(' '. $subtítulo .' ');
eco"\\n";
imprimir(' '. $autor .' ');
eco"\\n";
imprimir(' '. $fechapublicación .' ');
eco"\\n";
imprimir(' ');
eco"\\n";
imprimir(' ');
eco"\\n";
imprimir(' ');
eco"\\n";
imprimir(' '. $nombredelpropietario.' ');
eco"\\n";
imprimir(' '. $propietarioemail .' ');
eco"\\n";
imprimir(' ');
eco"\\n";
imprimir(' ');
eco"\\n";
imprimir(' ');
eco"\\n";
imprimir(' '. $explícito.' ');
eco"\\n";
eco"\\n";
función formatSeconds ($ segundos)
{
$segundos = ($segundos / 1000);
$horas = 0;
$milisegundos = str_replace( "0.", '', $segundos - piso( $segundos ) );
si ($segundos > 3600)
{
$horas = piso ($segundos / 3600);
}
$segundos = $segundos % 3600;
devuelve str_pad ($ horas, 2, '0', STR_PAD_LEFT) . gmdate(':i:s', $segundos);
}
$ch = curl_init();
$tiempo de espera = 5; // se pone a cero para que no se agote el tiempo de espera
curl_setopt ($ch, CURLOPT_URL, $baseURL . $accountId . '/playlists/'. $playlistid);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array(('Autorización:BCOV-Policy'. $policyKey),('BCOV-Policy:'. $policyKey),('Accept:application/json;pk='. $policyKey)) );
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $tiempo de espera);
$contenido_archivo = curl_exec($ch);
curl_close($ch);
$returndata = json_decode($archivo_contenido);
foreach($returndata->videos como $elementos)
{
imprimir(' - ');
eco"\\n";
imprimir('
');
print_r($elementos->{"nombre"});
imprimir(' ');
eco"\\n";
imprimir(' ');
print_r($items->custom_fields->{"itunesartist"});
imprimir(' ');
eco"\\n";
imprimir(' ');
print_r($elementos->{"descripción"});
imprimir(' ');
eco"\\n";
imprimir(' ');
print_r($elementos->{"descripción"});
imprimir(' ');
eco"\\n";
imprimir(' ');
print_r($elementos->{"cartel"});
imprimir(' ');
eco"\\n";
imprimir(' <url del recinto="');
$nuevaurl = $elementos->fuentes[4]->{"src"};
print_r($nuevaurl);
imprimir ('" longitud = "');
print_r($elementos->{"duración"});
imprimir('" tipo="video/mp4" />');
eco"\\n";
imprimir(' ');
print_r($elementos->{"id"});
imprimir(' ');
eco"\\n";
imprimir(' ');
print_r(fecha(DATE_RFC2822,($items->{"published_at"})));
imprimir(' ');
eco"\\n";
imprimir(' ');
print($duración = formatSeconds($elementos->{"duración"}));
imprimir(' ');
eco"\\n";
imprimir(' ');
print_r($elementos->campos_personalizados->{"explícito"});
imprimir(' ');
eco"\\n";
imprimir(' ');
eco"\\n";
}
eco"\\n";
imprimir(' ');
eco"\\n";
imprimir(' ');
?>
Generador de alimentación Roku
// Sample Video Cloud Roku Direct Publisher feed
// Please use this at your own risk.
// This is just a sample to get you started. You can customize further as your requirements
// grow.
// The following is a list of requirements and conditions in order for this Roku Direct Publisher feed
// to function properly;
//1) You must have a Pro or Enterprise level Video Cloud Account.
//2) You need to create the following custom fields. They are in your Account Settings:
// Video Fields page on the Video Cloud Studio Home page:
// 1) roku_category
// 2)
//
//3) You will have to manually or programmatically set the custom metadata values when you
// upload content.
// Please customize the variables below:
// This is the title of the Roku Feed itself.
$title = "Brightcove Test Roku Direct Publisher Feed";
// This is a link to where the podcast can be found.
$link = "https://www.blacktreeproductions.com/brightcove_roku_direct_publisher.php5";
// This is a description of this Roku Direct Publisher Feed.
$description= "Description of the Video Cloud Roku Direct Publisher Test Feed";
//Brightcove Account ID
$accountId = "1234567890";
// This is your Policy Key associated with your account.
$policyKey = "m1VoineewK4tkFbfDakfEwYInEMSa_fAJ7HxVMIN1ItBJHXEDYGMnPbJrkK0U";
// The ID of the playlist you wish to publish.
$playlistid = "987654321";
// This is the baseURL of the API endpoint you would like to use
$baseURL = "https://edge.api.brightcove.com/playback/v1/accounts/";
// Please DO NOT alter the code below;
header('Content-Type: text/xml');
print('');
echo"\n";
print('');
echo"\n";
print(' '. $title .' ');
echo"\n";
print(' '. $link .'');
echo"\n";
print(' ');
echo"\n";
$ch = curl_init();
$timeout = 5; // set to zero for no timeout
curl_setopt ($ch, CURLOPT_URL, $baseURL . $accountId . '/playlists/'. $playlistid);
curl_setopt ($ch, CURLOPT_HTTPHEADER, array(('Authorization:BCOV-Policy '. $policyKey),('BCOV-Policy:'. $policyKey),('Accept:application/json;pk='. $policyKey)));
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$file_contents = curl_exec($ch);
curl_close($ch);
$returndata = json_decode($file_contents);
foreach($returndata->videos as $items)
{
print(' - ');
echo"\n";
print('
');
print_r($items->{"id"});
print(' ');
echo"\n";
print(' ');
print_r(date(DATE_RFC2822,($items->{"published_at"})));
print(' ');
echo"\n";
print(' ');
print_r($items->{"name"});
print(' ');
echo"\n";
print(' ');
print_r($items->{"description"});
print(' ');
echo"\n";
print(' ');
print_r($items->custom_fields->{"roku_category"});
print(' ');
echo"\n";
print(' ');
echo"\n";
print(' ');
echo"\n";
print(' ');
echo"\n";
// print_r($items); DUMP THE ENTIRE ARRAY FOR TESTING
print(' ');
echo"\n";
}
echo"\n";
print(' ');
echo"\n";
print(' ');
?>