Advertisement
Th3-822

[rapidleech][d] ok_ru

Nov 18th, 2015
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.58 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once('index.html');
  5.     exit;
  6. }
  7.  
  8. class ok_ru extends DownloadClass {
  9.     private $xid, $streams, $formats = array('full' => 1080, 'hd' => 720, 'sd' => 480, 'low' => 360, 'lowest' => 240, 'mobile' => 144);
  10.     public function Download($link) {
  11.         if (!preg_match('@/video(?:embed)?/(\d+)@i', $link, $xid)) html_error('Video ID not found.');
  12.         $this->xid = $xid[1];
  13.         $this->link = 'https://ok.ru/video/' . $this->xid;
  14.  
  15.         $page = $this->GetPage($this->link);
  16.         is_present($page, "Video has not been found", 'Video not found or it was deleted.');
  17.  
  18.         $json = cut_str($page, 'data-options="', '"');
  19.         if (empty($json)) html_error('Video Data not Found.');
  20.         $json = $this->json2array(html_entity_decode(str_replace('\\\\u0026', '&amp;', $json), ENT_QUOTES, 'UTF-8'), 'Error Parsing Video Data.');
  21.         if (!empty($json['flashvars']['metadata']) && !is_array($json['flashvars']['metadata'])) $json['flashvars']['metadata'] = $this->json2array($json['flashvars']['metadata'], 'Error Parsing Video Metadata.');
  22.         else if (empty($json['flashvars']['metadata'])) html_error('Video Metadata Not Found');
  23.         $json = $json['flashvars']['metadata'];
  24.  
  25.         if (empty($json['movie']['title'])) html_error('Video Title Not Found');
  26.  
  27.         $this->streams = array();
  28.         foreach ($json['videos'] as $video) {
  29.             if (array_key_exists($video['name'], $this->formats) && !empty($video['url'])) $this->streams[$video['name']] = $video['url'];
  30.         }
  31.         if (empty($this->streams)) html_error('Non Aceptable Video Streams Found.');
  32.  
  33.         // I did see a couple of videos that links to youtube, i will add code to send them to the youtube plugin.
  34.         if (count($json['videos']) == 1 && empty($json['movie']['collageInfo']))
  35.         {
  36.             // Looks Like A Video for a External Site.
  37.             $extLink = $this->streams[key($this->streams)];
  38.             if (preg_match('@youtube\.com/(?:v|embed)/([\w\-\.]{11})@i', $extLink, $YT)) {
  39.                 // It's a  YT link, send it to the youtube plugin.
  40.                 insert_location($this->DefaultParamArr('https://www.youtube.com/watch?v=' . $YT[1]));
  41.                 exit();
  42.             }
  43.             html_error('This video doesn\'t seems to be hosted on ok.ru, link: ' . htmlspecialchars($extLink));
  44.         }
  45.  
  46.         if (empty($_POST['dlstream']) && !isset($_GET['audl'])) return $this->QSelector();
  47.         elseif (empty($_POST['dlstream']) || !empty($this->streams[$_POST['dlstream']])) {
  48.             $key = (empty($_POST['dlstream']) ? key($this->streams) : $_POST['dlstream']);
  49.             $DL = $this->streams[$key];
  50.         } else html_error('Selected video stream was not found.');
  51.  
  52.         $filename = preg_replace('@[^ A-Za-z_\-\d\.,\(\)\[\]\{\}&\!\'\@\%\#]@u', '_', html_entity_decode(trim($json['movie']['title']), ENT_QUOTES, 'UTF-8'));
  53.         $filename .= " [OK-{$this->formats[$key]}p][{$this->xid}].mp4";
  54.  
  55.         $this->RedirectDownload($DL, $filename, 0, 0, 0, $filename);
  56.     }
  57.  
  58.     private function QSelector() {
  59.         echo "\n<br /><br /><h3 style='text-align: center;'>Video Quality Selector</h4>";
  60.         echo "\n<center><form name='T8_QS' action='{$_SERVER['SCRIPT_NAME']}' method='POST'>\n";
  61.         echo "<select name='dlstream' id='QS_fmt'>\n";
  62.         foreach ($this->formats as $fmt => $res) if (array_key_exists($fmt, $this->streams)) echo "<option value='$fmt'>" . ucfirst($fmt) . " ({$res}p)</option>\n";
  63.         echo "</select>\n";
  64.         $data = $this->DefaultParamArr($this->link);
  65.         foreach ($data as $n => $v) echo("<input type='hidden' name='$n' id='QS_$n' value='$v' />\n");
  66.         echo "<input type='submit' name='Th3-822' value='" . lang(209) . "' />\n";
  67.         echo "</form></center>\n</body>\n</html>";
  68.         exit;
  69.     }
  70. }
  71.  
  72. //[18-11-2015] Written by Th3-822.
  73. //[25-02-2017] Switched to HTTPS. - Th3-822
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement