Advertisement
Th3-822

[rapidleech][d] dailymotion_com.php

Mar 7th, 2014
483
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 4.10 KB | None | 0 0
  1. <?php
  2.  
  3. if (!defined('RAPIDLEECH')) {
  4.     require_once('index.html');
  5.     exit();
  6. }
  7.  
  8. class dailymotion_com extends DownloadClass {
  9.     private $cookie, $xid, $title, $streams,
  10.     $formats = array('1080' => 'stream_h264_hd1080_url', '720' => 'stream_h264_hd_url',
  11.         '480' => 'stream_h264_hq_url', '384' => 'stream_h264_url', '240' => 'stream_h264_ld_url');
  12.  
  13.     public function Download($link) {
  14.         $this->cookie = !empty($_POST['step']) && !empty($_POST['cookie']) ? StrToCookies(decrypt(urldecode($_POST['cookie']))) : array('ff' => 'off');
  15.         if (!preg_match('@/video/(x[0-9a-zA-Z]+)@i', $link, $xid)) html_error('Video ID not found.');
  16.         $this->xid = $xid[1];
  17.         $this->link = 'http://www.dailymotion.com/video/'.$this->xid;
  18.  
  19.         if (empty($_POST['step'])) {
  20.             $page = $this->GetPage($this->link, $this->cookie);
  21.             $this->cookie = GetCookiesArr($page, $this->cookie);
  22.  
  23.             $status = (int)substr($page, 9, 3);
  24.             switch ($status) {
  25.                 case 200: break;
  26.                 case 403: html_error('This video is forbidden to download!');break;
  27.                 case 404: html_error('404 Not Found');break;
  28.                 case 410: html_error('This video has been removed by the user.');break;
  29.                 default: html_error("Unexpected response: $status");break;
  30.             }
  31.         }
  32.  
  33.         $this->getVideoInfo();
  34.  
  35.         if (empty($_POST['dlstream']) && !isset($_GET['audl'])) return $this->QSelector();
  36.         elseif (empty($_POST['dlstream']) || !empty($this->streams[$_POST['dlstream']])) {
  37.             $key = (empty($_POST['dlstream']) ? key($this->streams) : $_POST['dlstream']);
  38.             $DL = $this->streams[$key];
  39.         } else html_error('Selected video stream was not found.');
  40.  
  41.         $filename = preg_replace('@[^ A-Za-z_\-\d\.,\(\)\[\]\{\}&\!\'\@\%\#]@u', '_', html_entity_decode(trim($this->title), ENT_QUOTES, 'UTF-8'));
  42.         $filename .= " [DM-{$key}p][{$this->xid}].mp4";
  43.  
  44.         $page = $this->GetPage($DL, $this->cookie);
  45.         if (!preg_match('@https?://[^/\s]+/video/[^\s<>\'\"]+@i', $page, $DL)) html_error('Download Link not Found.');
  46.  
  47.         $this->RedirectDownload($DL[0], $filename, $this->cookie, 0, 0, $filename);
  48.     }
  49.  
  50.     private function Get_Reply($content) {
  51.         if (!function_exists('json_decode')) html_error('Error: Please enable JSON in php.');
  52.         if (($pos = strpos($content, "\r\n\r\n")) > 0) $content = substr($content, $pos + 4);
  53.         $cb_pos = strpos($content, '{');
  54.         $sb_pos = strpos($content, '[');
  55.         if ($cb_pos === false && $sb_pos === false) html_error('Json start braces not found.');
  56.         $sb = ($cb_pos === false || $sb_pos < $cb_pos) ? true : false;
  57.         $content = substr($content, strpos($content, ($sb ? '[' : '{')));$content = substr($content, 0, strrpos($content, ($sb ? ']' : '}')) + 1);
  58.         if (empty($content)) html_error('No json content.');
  59.         $rply = json_decode($content, true);
  60.         if (!$rply || count($rply) == 0) html_error('Error reading json.');
  61.         return $rply;
  62.     }
  63.  
  64.     private function getVideoInfo() {
  65.         $page = $this->GetPage("http://www.dailymotion.com/json/video/{$this->xid}?fields=title%2C".implode('%2C', $this->formats), $this->cookie);
  66.         $json = $this->Get_Reply($page);
  67.  
  68.         if (empty($json['title'])) html_error('Video Title not Found.');
  69.         $this->title = $json['title'];
  70.  
  71.         $this->streams = array();
  72.         foreach ($this->formats as $key => $fmt) if (!empty($json[$fmt])) $this->streams[$key] = $json[$fmt];
  73.         if (empty($this->streams)) html_error('Video Streams not Found.');
  74.     }
  75.  
  76.     private function QSelector() {
  77.         echo "\n<br /><br /><h3 style='text-align: center;'>Video Quality Selector</h4>";
  78.         echo "\n<center><form name='T8_QS' action='{$_SERVER['SCRIPT_NAME']}' method='POST'>\n";
  79.         echo "<select name='dlstream' id='QS_fmt'>\n";
  80.         foreach ($this->streams as $fmt => $url) echo "<option value='$fmt'>{$fmt}p</option>\n";
  81.         echo "</select>\n";
  82.         if (count($this->cookie) > 0) $this->cookie = encrypt(CookiesToStr($this->cookie));
  83.         $data = $this->DefaultParamArr($this->link, $this->cookie);
  84.         $data['step'] = 1;
  85.         foreach ($data as $n => $v) echo("<input type='hidden' name='$n' id='QS_$n' value='$v' />\n");
  86.         echo "<input type='submit' name='Th3-822' value='".lang(209)."' />\n";
  87.         echo "</form></center>\n</body>\n</html>";
  88.         exit;
  89.     }
  90. }
  91.  
  92. //[07-3-2014] Written by Th3-822.
  93.  
  94. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement