Guest User

Untitled

a guest
Dec 18th, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <?php
  2. $vimeoConfig = \Yii::$app->params['secrets']['vimeo'];
  3. $lib = new \Vimeo\Vimeo("", "", "");
  4. $next = "/me/videos?fields=name,uri,download&page=$page";
  5. $videos = $lib->request($next);
  6.  
  7. if (isset($videos['body']['error'])) {
  8. die(print_r($videos));
  9. }
  10. echo $videos['headers']['X-RateLimit-Remaining'];
  11. if (intval($videos['headers']['X-RateLimit-Remaining']) < 5) {
  12. echo "\n\n\n\nRateLImit too low!!!!!!!!!\n\n\n";
  13. die();
  14. }
  15. foreach ($videos['body']['data'] as $videoData) {
  16.  
  17. $finalLink = "";
  18. echo $videoData['name'] . "\n";
  19. $found = false;
  20. foreach ($titles as $title) {
  21. if (startsWith($title, $videoData['name'])) {
  22. $found = true;
  23. }
  24. }
  25.  
  26. if (!$found) {
  27. echo "Not found - continue";
  28. continue;
  29. }
  30.  
  31. $finalLink = "";
  32. foreach ($videoData['download'] as $link) {
  33. $finalLink = $link['link'];
  34. if ($link['quality'] == 'hd') {
  35. break;
  36. }
  37. }
  38.  
  39. if (!$finalLink) {
  40. echo "Kein Link";
  41. print_r($videoData);
  42. }
  43.  
  44.  
  45. //set link as a card
  46. $data = [
  47. "during" => [
  48. [
  49. "card" => [
  50. "description" => "Hier klicken, um das Video zur privaten Nutzung herunterzuladen.",
  51. "link" => $finalLink,
  52. "name" => "Video runterladen",
  53. ],
  54. "time_code" => "1",
  55. "type" => "card",
  56. ]
  57. ],
  58. "before" => null,
  59. "after" => null,
  60. ];
  61. echo "$finalLink\n\n";
  62.  
  63. $req = $lib->request("{$videoData['uri']}/timelineevents", $data, 'PATCH');
  64. echo json_encode($req);
  65.  
  66.  
  67. echo "\n\n\n";
  68.  
  69. if (intval($req['headers']['X-RateLimit-Remaining']) < 10) {
  70. echo "\n\n\n\nRateLImit too low!!!!!!!!!\n\n\n";
  71. die();
  72. }
  73. sleep(2);
  74. }
Add Comment
Please, Sign In to add comment