Không có chuyện đó đâu.... do có cơ duyên làm việc liên quan đến việc này và phải lăn lộn với nó nên biết thôi.
Dịch vụ streaming này dùng 2 source. Đầu tiên nó dùng source từ google nếu bị lỗi (do request quá nhiều bị google block) thì player sẽ load từ nguồn dự phòng (server streaming tự build) mà server này đã config bóp băng thông hoặc server cùi hoặc bị quá tải.
xin phép đc đào top, mình đang cần download link từ ok.ru, mình đã get đc link nhưng tốc độ download rất chậm 100 - 200kb/s, trong khi một số site get link speed rất cao 2MB/s. Mình get link từ những site đó đc luôn chứng tỏ họ ko download về server. Xin hỏi có cách nào để speed nhanh hơn ko ạ. Cảm ơn các bác. --- Double Post Merged, Jan 16, 2021, Original Post Date: Jan 15, 2021 --- up
Đây nha bác, link get đc từ ok.ru https://vd295.mycdn.me/?expires=161...urls=45.136.22.5&clientType=0&id=941740198559 Link download từ site get link : aiovideodl ml --- Double Post Merged, Jan 16, 2021, Original Post Date: Jan 16, 2021 --- https://aiovideodl.ml/#url=https://ok.ru/video/1859306523295 --- Double Post Merged, Jan 16, 2021 --- à bác phải set header origin và referer là ok.ru mới download đc nha --- Double Post Merged, Jan 16, 2021 --- PHP: function force_download($remoteURL, $vidName, $ftype){ $fsize = get_file_size($remoteURL, false, false); header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . htmlspecialchars_decode(sanitize_filename($vidName, $ftype)) . '"'); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); if ($fsize > 0) { header('Content-Length: ' . $fsize); } header('Connection: Close'); ob_clean(); flush(); // Activate flush if (function_exists('apache_setenv')) { apache_setenv('no-gzip', 1); } @ini_set('zlib.output_compression', false); ini_set('implicit_flush', true); // CURL Process $ch = curl_init(); $chunkEnd = $chunkSize = 1000000; // 1 MB in bytes $tries = $count = $chunkStart = 0; $cookie_file_name = $_SESSION["token"] . ".txt"; $cookie_file = join(DIRECTORY_SEPARATOR, [sys_get_temp_dir(), $cookie_file_name]); while ($fsize > $chunkStart) { curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $remoteURL); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, _REQUEST_USER_AGENT); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_RANGE, $chunkStart . '-' . $chunkEnd); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BUFFERSIZE, $chunkSize); if (!empty($_SESSION["proxy"])) { $proxy = $_SESSION["proxy"]; curl_setopt($ch, CURLOPT_PROXY, $proxy['ip'] . ":" . $proxy['port']); curl_setopt($ch, CURLOPT_PROXYTYPE, get_proxy_type($proxy['type'])); if (!empty($proxy['username']) && !empty($proxy['password'])) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy['username'] . ":" . $proxy['password']); } $chunkSize = 1000000; curl_setopt($ch, CURLOPT_TIMEOUT, (int)ceil(3 * (round($chunkSize / 1048576, 2) / (1 / 8)))); } if (file_exists($cookie_file)) { curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); } //curl_setopt($ch, CURLOPT_MAX_RECV_SPEED_LARGE, "100"); $output = curl_exec($ch); $curlInfo = curl_getinfo($ch); if ($curlInfo['http_code'] != "206" && $tries < 10) { $tries++; continue; } else { $tries = 0; echo $output; flush(); ob_implicit_flush(true); if (ob_get_length() > 0) ob_end_flush(); } $chunkStart += $chunkSize; $chunkStart += ($count == 0) ? 1 : 0; $chunkEnd += $chunkSize; $count++; //sleep(10); } curl_close($ch); exit;} --- Double Post Merged, Jan 16, 2021 --- đây là function script đấy dùng để download, speed toàn 2mb/s, em get link download chỉ đc 100kb, 200kb --- Double Post Merged, Jan 16, 2021 --- Up --- Double Post Merged, Jan 24, 2021 --- xin phép đc đào top ạ, em vẫn chưa tìm đc lời giải. Em check đc là nó dùng http transfer php, em up thử lên host ở hawhost mà downlaod vẫn chậm quá --- Double Post Merged, Jan 24, 2021 --- ko hiểu sao của nó nhanh thật sự
Các site stream thường sẽ giới hạn tốc độ download sau 1 số MB nhất định. Cái này do server nó cấu hình để hạn chế. Cái code download kia nó chia ra download từng MB sau đó ghép lại nên mới maxspeed được.
vâng bác, nhưng em lấy nguyên code của nó vứt lên server em mà cũng chậm ( hay do tại server của em đểu --- Double Post Merged, Jan 24, 2021, Original Post Date: Jan 24, 2021 --- PHP: <?phpsession_start();const _REQUEST_USER_AGENT = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36";force_download("https://vd296.mycdn.me/?expires=1611560222076&srcIp=117.5.147.83&srcAg=CHROME&ms=185.226.53.5&type=3&sig=f6d5gGCw7Kc&ct=0&urls=185.226.52.4&clientType=0&id=941889948319", "video_name", "mp4");function force_download($remoteURL, $vidName, $ftype){ $fsize = get_file_size($remoteURL, false, false); header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); //header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename="' . htmlspecialchars_decode(sanitize_filename($vidName, $ftype)) . '"'); header("Content-Transfer-Encoding: binary"); header("Accept-Ranges: bytes"); if ($fsize > 0) { header('Content-Length: ' . $fsize); } header('Connection: Close'); @ini_set('max_execution_time', 0); @set_time_limit(); ob_clean(); flush(); // Activate flush if (function_exists('apache_setenv')) { apache_setenv('no-gzip', 1); } @ini_set('zlib.output_compression', false); ini_set('implicit_flush', true); // CURL Process $ch = curl_init(); $chunkEnd = $chunkSize = 1000000; // 1 MB in bytes $tries = $count = $chunkStart = 0; //$cookie_file_name = $_SESSION["token"] . ".txt"; //$cookie_file = join(DIRECTORY_SEPARATOR, [sys_get_temp_dir(), $cookie_file_name]); while ($fsize > $chunkStart) { curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_URL, $remoteURL); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1); curl_setopt($ch, CURLOPT_USERAGENT, _REQUEST_USER_AGENT); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_RANGE, $chunkStart . '-' . $chunkEnd); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_BUFFERSIZE, $chunkSize); if (!empty($_SESSION["proxy"])) { $proxy = $_SESSION["proxy"]; curl_setopt($ch, CURLOPT_PROXY, $proxy['ip'] . ":" . $proxy['port']); curl_setopt($ch, CURLOPT_PROXYTYPE, get_proxy_type($proxy['type'])); if (!empty($proxy['username']) && !empty($proxy['password'])) { curl_setopt($ch, CURLOPT_PROXYUSERPWD, $proxy['username'] . ":" . $proxy['password']); } $chunkSize = 1000000; curl_setopt($ch, CURLOPT_TIMEOUT, (int)ceil(3 * (round($chunkSize / 1048576, 2) / (1 / 8)))); } //if (file_exists($cookie_file)) { // curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file); //} //curl_setopt($ch, CURLOPT_MAX_RECV_SPEED_LARGE, "100"); $output = curl_exec($ch); $curlInfo = curl_getinfo($ch); if ($curlInfo['http_code'] != "206" && $tries < 10) { $tries++; continue; } else { $tries = 0; echo $output; flush(); ob_implicit_flush(true); if (ob_get_length() > 0) ob_end_flush(); } $chunkStart += $chunkSize; $chunkStart += ($count == 0) ? 1 : 0; $chunkEnd += $chunkSize; $count++; //sleep(10); } curl_close($ch); exit;}function get_file_size($url, $enable_proxies = false, $format = true){ $cookie_file_name = $_SESSION["token"] . ".txt"; $cookie_file = join(DIRECTORY_SEPARATOR, [sys_get_temp_dir(), $cookie_file_name]); $result = -1; // Assume failure. // Issue a HEAD request and follow any redirects. $curl = curl_init($url); curl_setopt($curl, CURLOPT_NOBODY, true); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_REFERER, ''); //curl_setopt($curl, CURLOPT_INTERFACE, ''); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($curl, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4); curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_USERAGENT, _REQUEST_USER_AGENT); if ($enable_proxies) { if (!empty($_SESSION["proxy"] ?? null)) { $proxy = $_SESSION["proxy"]; } else { $proxy = get_proxy(); $_SESSION["proxy"] = $proxy; } curl_setopt($curl, CURLOPT_PROXY, $proxy['ip'] . ":" . $proxy['port']); curl_setopt($curl, CURLOPT_PROXYTYPE, get_proxy_type($proxy['type'])); if (!empty($proxy['username']) && !empty($proxy['password'])) { curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxy['username'] . ":" . $proxy['password']); } $chunkSize = 1000000; curl_setopt($curl, CURLOPT_TIMEOUT, (int)ceil(3 * (round($chunkSize / 1048576, 2) / (1 / 8)))); } if (file_exists($cookie_file)) { curl_setopt($curl, CURLOPT_COOKIEFILE, $cookie_file); } $headers = curl_exec($curl); if (curl_errno($curl) == 0) { $result = (int)curl_getinfo($curl, CURLINFO_CONTENT_LENGTH_DOWNLOAD); } curl_close($curl); if ($result > 100) { switch ($format) { case true: return format_size($result); break; case false: return $result; break; default: return format_size($result); break; } } else { return ""; }}function sanitize_filename($string, $ftype){ return (filter_filename($string) ?? "video") . "." . $ftype;}function filter_filename($filename, $beautify = true){ // sanitize filename $filename = preg_replace( '~ [<>:"/\\|?*]| # file system reserved https://en.wikipedia.org/wiki/Filename#Reserved_characters_and_words [\x00-\x1F]| # control characters http://msdn.microsoft.com/en-us/library/windows/desktop/aa365247%28v=vs.85%29.aspx [\x7F\xA0\xAD]| # non-printing characters DEL, NO-BREAK SPACE, SOFT HYPHEN [#\[\]@!$&\'()+,;=]| # URI reserved https://tools.ietf.org/html/rfc3986#section-2.2 [{}^\~`] # URL unsafe characters https://www.ietf.org/rfc/rfc1738.txt ~x', '-', $filename); // avoids ".", ".." or ".hiddenFiles" $filename = ltrim($filename, '.-'); // optional beautification if ($beautify) $filename = beautify_filename($filename); // maximize filename length to 255 bytes http://serverfault.com/a/9548/44086 $ext = pathinfo($filename, PATHINFO_EXTENSION); $filename = mb_strcut(pathinfo($filename, PATHINFO_FILENAME), 0, 255 - ($ext ? strlen($ext) + 1 : 0), mb_detect_encoding($filename)) . ($ext ? '.' . $ext : ''); return $filename;}function beautify_filename($filename){ // reduce consecutive characters $filename = preg_replace(array( // "file name.zip" becomes "file-name.zip" '/ +/', // "file___name.zip" becomes "file-name.zip" '/_+/', // "file---name.zip" becomes "file-name.zip" '/-+/' ), '-', $filename); $filename = preg_replace(array( // "file--.--.-.--name.zip" becomes "file.name.zip" '/-*\.-*/', // "file...name..zip" becomes "file.name.zip" '/\.{2,}/' ), '.', $filename); // lowercase for windows/unix interoperability http://support.microsoft.com/kb/100625 $filename = mb_strtolower($filename, mb_detect_encoding($filename)); // ".file-name.-" becomes "file-name" $filename = trim($filename, '.-'); return $filename;}?> --- Double Post Merged, Jan 24, 2021 --- code bên trên các bác thử test xem --- Double Post Merged, Jan 24, 2021 --- --- Double Post Merged, Jan 24, 2021 --- sao ko có bác nào giúp em với
dùng streamlink để download nhé Bác [search google ] download về , giải nén ra trong folder có file Streamlink.bat paste link vào là nó tự download còn muốn down các res khác nhau thì thêm resolution vào ví dụ : streamlink "link ok.ru " 720p -o "file.mp4"