Last active
April 2, 2022 08:29
-
-
Save MrCheatEugene/2842497aebc8afda9a2f1015687b7714 to your computer and use it in GitHub Desktop.
Парсер видео с РЭШ на PHP - Resh video parser written in PHP
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 | |
// Парсер видео с resh.edu.ru на PHP. | |
// Нужен DOMDocument а также ссылка на основную часть с плеером player.js. Пример: https://resh.edu.ru/subject/lesson/6111/main/200549/ | |
// $lnk - ссылка на основную часть | |
function get_widget($lnk){ | |
libxml_use_internal_errors(true); | |
if (empty($lnk) == true) { | |
return false; | |
}else{ | |
$html = new DOMDocument(); | |
$html->loadHTML(file_get_contents($lnk)); | |
$iframe = $html->getElementById("iframe_video"); | |
if ($iframe == null) { | |
return false; | |
}elseif ($iframe->hasAttribute('src')) { | |
return $iframe->getAttribute('src'); | |
} | |
} | |
} | |
function get_video($lnk){ | |
$link =get_widget($lnk); | |
$widget = file_get_contents($link); | |
$widget_t = new DOMDocument(); | |
$widget_t->loadHTML($widget); | |
$script= $widget_t->getElementsByTagName("script")[1]->nodeValue; | |
$scriptt = substr($script,strpos($script, "{"),strpos($script,"}")-strlen($script)+1); | |
$folder = str_replace("playlist.m3u8","",("https://video.resh.edu.ru".substr($scriptt, strpos($scriptt, 'file:"')+6,strpos($scriptt, '", poster:"')-strlen($scriptt)))); | |
return array("all"=>"https://video.resh.edu.ru".substr($scriptt, strpos($scriptt, 'file:"')+6,strpos($scriptt, '", poster:"')-strlen($scriptt)),"720"=>$folder.'720/720p.m3u8',"360"=>$folder.'360/360p.m3u8',"480"=>$folder.'480/480p.m3u8',"1080"=>$folder.'1080/1080p.m3u8',"playerjs"=>$scriptt); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment