mysql — PHP, как проверить, существует ли openload видео?

Мне нужно кое-что проверить, существует ли видео с открытой загрузкой, некоторые видео иногда удаляются по отчету DMCA, и мне просто нужно отображать не работающие ссылки.

Просто набросок, что я хочу

$result = mysqli_query($db, "SELECT videos FROM table");
while($row=mysqli_fetch_assoc($result) {

$embedUrl = $row["videos"];

//so i wanna show only not working url's
if($embedUrl == false)
echo $embedUrl;
}

Это пример не работающей ссылки Вот

0

Решение

Попробуй это. Выходы: «Видео недоступно», если видео не существует.

Смотрите комментарии для пошагового объяснения.

<?php

// Your Openload URL
$url = 'https://openload.co/embed/UgmaOAo1wlg/Horrible.Bosses.2.2014.720p.BluRay.x264.YIFY.mp4';

// Initialize cURL library.
if (($curl = curl_init()) === FALSE)
{
$errno = curl_errno();
throw new RuntimeException("curl_init() ($errno): " . curl_strerror($errno));
}

// Tell cURL which URL to operate on. GET is the default method.
curl_setopt($curl, CURLOPT_URL, $url);

// Optionally specify a path to a certificate store in PEM format.
// curl_setopt($curl, CURLOPT_CAINFO, __DIR__ . '/cacert.pem');
// Given Openload URL is requested over https. Allow for some sanity checking.
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, TRUE);
// Set this to the latest SSL standard supported by PHP at the time of this answer.
curl_setopt($curl, CURLOPT_SSLVERSION, 6);

// Return response, so we can inspect its contents.
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
// Openload returns HTTP code 200 if a video wasn't found. Any code >= 400 indicates a different problem.
curl_setopt($curl, CURLOPT_FAILONERROR, TRUE);
// Allow for server-side redirects.
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, TRUE);
// Don't include header in response.
curl_setopt($curl, CURLOPT_HEADER, FALSE);

if (($response = curl_exec($curl)) === FALSE)
throw new RuntimeException("curl_exec() failed for $url: " . curl_error($curl));

// Perform a case-insensitive search for a token that is specific to the 'video not found' page.
if (stripos($response, '<img class="image-blocked" src="/assets/img/blocked.png" alt="blocked">') !== FALSE)
echo 'Video unavailable';
0

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector