Einleitung
Im Folgenden finden Sie zwei PHP-Apps zum Generieren von Feeds für iTunes und Ruku, wobei die Playback-API als Quelle für Videoinformationen verwendet wird.
iTunes-Feed-Generator
// 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('');
echo"\n";
print('');
echo"\n";
print('');
echo"\n";
print(' '. $titel. ' ');
echo"\n";
print(' '. $verknüpfung. '');
echo"\n";
print(' '. $lang. ' ');
echo"\n";
print(' '. $ Urheberrecht. ' ');
echo"\n";
print(' '. $untertitel. ' ');
echo"\n";
print(' '. $autor. ' ');
echo"\n";
print(' '. $Veröffentlichungsdatum. ' ');
echo"\n";
print(' ');
echo"\n";
print(' ');
echo"\n";
print(' ');
echo"\n";
print(' '. $Besitzername. ' ');
echo"\n";
print(' '. $owner-E-Mail. ' ');
echo"\n";
print(' ');
echo"\n";
print(' ');
echo"\n";
print(' ');
echo"\n";
print(' '. $explizit. ' ');
echo "\ n“;
echo "\ n“;
Funktion formatSeconds ($sekunden)
{
$sekunden = ($sekunden/1000);
$Stunden = 0;
$Millisekunden = str_replace („0. „, „, $sekunden - floor ($sekunden));
if ($sekunden > 3600)
{
$hours = floor ($sekunden/3600);
}
$sekunden = $sekunden% 3600;
return str_pad ($hours, 2, '0', STR_PAD_LEFT). gmdate (':i:s', $sekunden);
}
$ch = curl_init ();
$timeout = 5;//auf Null setzen für kein Timeout
curl_setopt ($ch), CURLOPT_URL, $baseURL. $accountID. '/playlists/'. $playlist);
curl_setopt ($ch), CURLOPT_HTTPHEADER, array ('Autorisierung: BCOV-Richtlinie'). $policyKey), ('BCoV-Richtlinie: '. $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 ($ch) returndata->videos als $items)
{
print (') - ');
echo"\n";
print('
');
print_r($items->{"name"});
print(' ');
echo"\n";
print(' ');
print_r($items->custom_fields->{"itunesartist"});
print(' ');
echo"\n";
print(' ');
print_r($items->{"description"});
print(' ');
echo"\n";
print(' ');
print_r($items->{"description"});
print(' ');
echo"\n";
print(' ');
print_r($items->{"poster"});
print(' ');
echo"\n";
print(' <enclosure url="');
$newurl = $items->sources[4]->{"src"};
print_r($newurl);
print('" length="');
print_r($items->{"duration"});
print('" type="video/mp4" />');
echo"\n";
print(' ');
print_r($items->{"id"});
print(' ');
echo"\n";
print(' ');
print_r (date (DATE_RFC2822, ($artikel-> {"veröffentlicht_am"})));
print (' ');
echo"\n";
print(' ');
print($duration = formatSeconds($items->{"duration"}));
print(' ');
echo"\n";
print(' ');
print_r($items->custom_fields->{"explicit"});
print(' ');
echo"\n";
print(' ');
echo"\n";
}
echo"\n";
print(' ');
echo"\n";
print(' ');
? >
Roku-Feed-Generator
// 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(' ');
?>