Last active
December 15, 2017 13:34
-
-
Save metaxy/a488f7895b07b0b1f4f677da30dc8057 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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