Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- error_reporting(0);
- class Joox
- {
- function ngecurl($url , $post=null , $header=null){
- mkdir("Download");
- $ch = curl_init($url);
- if($post != null) {
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
- }
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (iPhone; U; CPU iPhone OS 8_3_3 like Mac OS X; en-SG) AppleWebKit/537.25 (KHTML, like Gecko) Version/7.0 Mobile/8C3 Safari/6533.18.1");
- curl_setopt($ch, CURLOPT_COOKIEJAR, getcwd().'temp/'."cookies.txt");
- curl_setopt($ch, CURLOPT_COOKIEFILE, getcwd().'temp/'."cookies.txt");
- curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);
- if($header != null) {
- curl_setopt($ch, CURLOPT_HTTPHEADER,$header);
- }
- curl_setopt($ch, CURLOPT_COOKIESESSION, true);
- curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
- curl_setopt($ch, CURLOPT_TIMEOUT, 20);
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- return curl_exec($ch);
- curl_close($ch);
- }
- function bersih($data){return preg_replace('/\s+/', '', $data);}
- function decode($data){
- foreach ($data as $is) {
- $data[] = base64_decode($is);
- }
- return $data;
- }
- function parsing($data){
- $regex = array(
- 'judul' => '/"info1":"(.*?)"/',
- 'penyanyi' => '/"name":"(.*?)"/',
- 'album' => '/"info3":"(.*?)"/',
- 'songid' => '/"songid":"(.*?)"/',
- );
- foreach ($regex as $label => $regexnya) {
- preg_match_all($regexnya, $data, $matches);
- if($label != "songid"){
- foreach ($matches[1] as $key => $datanya) {
- $result_[] = base64_decode($datanya);
- }
- $result[] = array($label => $result_);
- unset($result_);
- }else{
- $result[] = array($label => $matches[1]);
- unset($result_);
- }
- }
- return $result;
- }
- function readline($pesan){
- echo "[Download Mp4a/mp3] ".$pesan;
- $answer = rtrim( fgets( STDIN ));
- return $answer;
- }
- function secondsToTime($seconds) {
- $hours = floor($seconds / (60 * 60));
- $divisor_for_minutes = $seconds % (60 * 60);
- $minutes = floor($divisor_for_minutes / 60);
- $divisor_for_seconds = $divisor_for_minutes % 60;
- $seconds = ceil($divisor_for_seconds);
- $obj = array(
- "h" => (int) $hours,
- "m" => (int) $minutes,
- "s" => (int) $seconds,
- );
- return $obj;
- }
- function times(){
- $time = microtime();
- $time = explode(' ', $time);
- return $time[1] + $time[0];
- }
- function download($judul,$url){
- $start = $this->times();
- echo "[Download Mp4a/mp3] Download Size : ";
- $fp = fopen ("Download/".$judul, 'w+');
- $ch = curl_init();
- curl_setopt( $ch, CURLOPT_URL, $url );
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, false );
- curl_setopt( $ch, CURLOPT_BINARYTRANSFER, true );
- curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, false );
- curl_setopt( $ch, CURLOPT_CONNECTTIMEOUT, 10 );
- curl_setopt( $ch, CURLOPT_FILE, $fp );
- curl_exec( $ch );
- curl_close( $ch );
- fclose( $fp );
- $end = $this->times();
- $time = $this->secondsToTime(round(($end - $start), 1));
- if(filesize("Download/".$judul) > 0){
- echo $this->formatSizeUnits( filesize("Download/".$judul) )." | Selesai pada ".$time[m]." menit ".$time[s]." detik\r\n";
- }else{
- echo $this->formatSizeUnits( filesize("Download/".$judul) )." (Gagal)\r\n";
- }
- }
- function getHeaders($url){
- $ch = curl_init($url);
- curl_setopt( $ch, CURLOPT_NOBODY, true );
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, false );
- curl_setopt( $ch, CURLOPT_HEADER, false );
- curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true );
- curl_setopt( $ch, CURLOPT_MAXREDIRS, 3 );
- curl_exec( $ch );
- $headers = curl_getinfo( $ch );
- curl_close( $ch );
- return $headers;
- }
- function formatSizeUnits($bytes)
- {
- if ($bytes >= 1073741824)
- {
- $bytes = number_format($bytes / 1073741824, 2) . ' GB';
- }
- elseif ($bytes >= 1048576)
- {
- $bytes = number_format($bytes / 1048576, 2) . ' MB';
- }
- elseif ($bytes >= 1024)
- {
- $bytes = number_format($bytes / 1024, 2) . ' kB';
- }
- elseif ($bytes > 1)
- {
- $bytes = $bytes . ' bytes';
- }
- elseif ($bytes == 1)
- {
- $bytes = $bytes . ' byte';
- }
- else
- {
- $bytes = '0 bytes';
- }
- return $bytes;
- }
- function pencarian($katakunci)
- {
- $data = $this->bersih($this->ngecurl("http://api.joox.com/web-fcgi-bin//web_search?callback=jQuery110003061714756163918_1477336272879&lang=id&country=id&type=0&search_input=".urlencode($katakunci)));
- $data = $this->parsing($data);
- $judul = $data[0][judul];
- $penyanyi = $data[1][penyanyi];
- $album = $data[2][album];
- $songid = $data[3][songid];
- echo ".-[ID]-|------[ PENYANYI ]--------.--------------[ JUDUL LAGU ]--------------.\r\n";
- foreach ($data[0][judul] as $keyID => $string) {
- if(strlen($keyID) == 1){
- echo "| ".$keyID." | ".$penyanyi[$keyID];
- for ($i=strlen($penyanyi[$keyID]); $i <25; $i++) {
- echo " ";
- }
- echo "| ".substr($string, 0, 40);
- for ($i=strlen($string); $i <40; $i++) {
- echo " ";
- }
- echo " | \r\n";
- }else{
- echo "| ".$keyID." | ".$penyanyi[$keyID];
- for ($i=strlen($penyanyi[$keyID]); $i <25; $i++) {
- echo " ";
- }
- echo "| ".substr($string, 0, 40);
- for ($i=strlen($string); $i <40; $i++) {
- echo " ";
- }
- echo " |\r\n";
- }
- }
- echo "\----------------------------------------------------------------------------/\r\n";
- $IDnya = $this->readline("Pilih ID Lagu (0 - ".(count($data[3][songid])-1).") : ");
- $IDnya = explode(",", $IDnya);
- foreach ($IDnya as $key => $idLagu) {
- if($idLagu != null && isset($songid[$idLagu])){
- echo "\r\n[Download Mp4a/mp3] Judul Lagu : ".$penyanyi[$idLagu]." - ".$judul[$idLagu]." (".$key."/".count($IDnya).")\r\n";
- $data = $this->bersih($this->ngecurl("http://api.joox.com/web-fcgi-bin/web_get_songinfo?songid=".$songid[$idLagu]."&lang=id&country=id&from_type=-1&channel_id=-1"));
- $mp4a = '/"m4aUrl":"(.*?)"/';
- $mp3 = '/"mp3Url":"(.*?)"/';
- preg_match_all($mp4a, $data, $matchesmp4a);
- preg_match_all($mp3, $data, $matchesmp3);
- if($matchesmp4a[1][0] != null){
- $this->download( $penyanyi[$idLagu]." - ".$judul[$idLagu].".mp4a" ,$matchesmp4a[1][0]);
- }else if($matchesmp3[1][0] != null){
- $this->download( $penyanyi[$idLagu]." - ".$judul[$idLagu].".mp3" ,$matchesmp3[1][0]);
- }else{
- echo "\r\n[Download Mp4a/mp3] Link ".$penyanyi[$idLagu]." - ".$judul[$idLagu]." Tidak ada\r\n";
- }
- }else{
- $this->start();
- }
- }
- $this->start();
- }
- function start(){
- $this->pencarian($this->readline("Masukan kata pencarian : "));
- }
- }
- $Joox = new Joox;
- $Joox->start();
- ?>
Add Comment
Please, Sign In to add comment