Skip to content

Instantly share code, notes, and snippets.

@metaxy
Last active December 15, 2017 13:34
Show Gist options
  • Save metaxy/a488f7895b07b0b1f4f677da30dc8057 to your computer and use it in GitHub Desktop.
Save metaxy/a488f7895b07b0b1f4f677da30dc8057 to your computer and use it in GitHub Desktop.
<?php
$vimeoConfig = \Yii::$app->params['secrets']['vimeo'];
$lib = new \Vimeo\Vimeo("", "", "");
$next = "/me/videos?fields=name,uri,download&page=$page";
$videos = $lib->request($next);
if (isset($videos['body']['error'])) {
die(print_r($videos));
}
echo $videos['headers']['X-RateLimit-Remaining'];
if (intval($videos['headers']['X-RateLimit-Remaining']) < 5) {
echo "\n\n\n\nRateLImit too low!!!!!!!!!\n\n\n";
die();
}
foreach ($videos['body']['data'] as $videoData) {
$finalLink = "";
echo $videoData['name'] . "\n";
$found = false;
foreach ($titles as $title) {
if (startsWith($title, $videoData['name'])) {
$found = true;
}
}
if (!$found) {
echo "Not found - continue";
continue;
}
$finalLink = "";
foreach ($videoData['download'] as $link) {
$finalLink = $link['link'];
if ($link['quality'] == 'hd') {
break;
}
}
if (!$finalLink) {
echo "Kein Link";
print_r($videoData);
}
//set link as a card
$data = [
"during" => [
[
"card" => [
"description" => "Hier klicken, um das Video zur privaten Nutzung herunterzuladen.",
"link" => $finalLink,
"name" => "Video runterladen",
],
"time_code" => "1",
"type" => "card",
]
],
"before" => null,
"after" => null,
];
echo "$finalLink\n\n";
$req = $lib->request("{$videoData['uri']}/timelineevents", $data, 'PATCH');
echo json_encode($req);
echo "\n\n\n";
if (intval($req['headers']['X-RateLimit-Remaining']) < 10) {
echo "\n\n\n\nRateLImit too low!!!!!!!!!\n\n\n";
die();
}
sleep(2);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment