Skip to content

Instantly share code, notes, and snippets.

@mysteriouss
Last active July 8, 2020 21:23
Show Gist options
  • Save mysteriouss/d77bb005ac3712bcd01e1428c0de1e17 to your computer and use it in GitHub Desktop.
Save mysteriouss/d77bb005ac3712bcd01e1428c0de1e17 to your computer and use it in GitHub Desktop.

Revisions

  1. mysteriouss revised this gist Jul 8, 2020. 1 changed file with 1 addition and 159 deletions.
    160 changes: 1 addition & 159 deletions netease-qq.php
    Original file line number Diff line number Diff line change
    @@ -1,159 +1 @@
    <?php
    /**
    * Created by PhpStorm.
    * User: user
    * Date: 11/03/2018
    * Time: 2:20 AM
    */
    date_default_timezone_set('Asia/Shanghai');

    if(!isset($argv[1])){
    echo 'Usage: php netease.php $url' . PHP_EOL;
    return;
    }

    echo str_replace('/#','',$argv[1]) . PHP_EOL;

    $curl = curl_init();

    curl_setopt_array($curl, array(
    CURLOPT_URL => str_replace('/#','',$argv[1]),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 3,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
    "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6",
    "Cache-Control: no-cache",
    ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
    echo "cURL Error #:" . $err;
    } else {

    preg_match("/<h2 class=\"f-ff2\">(.*?)<\/h2>/i",$response,$album_name);

    if(!count($album_name)) {
    echo 'Please try with album url : e.g. http://music.163.com/#/album?id=36714070' . PHP_EOL;
    return;
    }
    echo 'album name: ' . PHP_EOL;
    $album_name = end($album_name);
    var_dump($album_name);

    preg_match("/<a class=\"s-fc7\" .*?>(.*?)<\/a>/i",$response,$artist_name);

    if(!count($artist_name)) return;
    echo 'artist name: ' . PHP_EOL;
    $artist_name = end($artist_name);
    var_dump($artist_name);

    preg_match("/<ul class=\"f-hide\">(.*?)<\/ul>/i",$response,$album);

    echo 'album:' . PHP_EOL;
    var_dump($album);

    if(!count($album)){
    //var_dump($response);
    return;
    }
    $album = end($album);

    preg_match_all("/<li><a href=\"\/song\?id=([0-9]+)\">(.*?)<\/a><\/li>/i",$album,$songs);

    echo 'songs:' . PHP_EOL;
    var_dump($songs);

    if(!count($songs)){

    return;
    }

    $songs_name = $songs[2];
    $index = 1;
    foreach ($songs_name as $song_name){
    $curl = curl_init();
    $song_name .= '-' . $artist_name;
    $song_name = urlencode($song_name);
    curl_setopt_array($curl, array(
    CURLOPT_URL => "http://music.able.cat/download/api/?id=$song_name&t=qq",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 5,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
    "User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0"
    ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
    echo "cURL Error #:" . $err;
    } else {
    //echo $response . PHP_EOL;

    $response = json_decode($response,true);
    if(!is_array($response) ||
    !array_key_exists('count',$response) ||
    !array_key_exists('data',$response)){
    continue;
    }
    $count = $response['count'];
    if(intval($count) < 1){
    continue;
    }elseif (intval($count) > 1) {
    //echo json_encode($response) . PHP_EOL;
    }

    $data = $response['data'];
    if(is_array($data) && count($data)){
    $data = reset($data);
    }

    if(is_array($data) &&
    array_key_exists('flac',$data) &&
    array_key_exists('Album',$data) &&
    array_key_exists('title',$data) &&
    array_key_exists('singer',$data) &&
    array_key_exists('url', $data)
    ){
    $album = $data['Album'];
    $title = $data['title'];
    $singer = $data['singer'];

    $album = str_replace('/','|',$album);
    $album = str_replace(':','',$album);
    $path = __DIR__.'/'. $album_name . ' - ' . $artist_name;
    $title = str_replace('/','|',$title);
    $title = str_replace(':','',$title);

    if(strlen( $data['flac'] )){
    $flac = $data['flac'];
    echo '<< '. $album . ' >> '. $index . '. ' . $title . PHP_EOL . $flac . PHP_EOL;
    exec("mkdir -p \"$path\" && curl -L -H \"User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0\" -f \"$flac\" -o \"$path/$index. $title - $singer.flac\"");
    }else{

    $url = $data['url'];
    echo '<< '. $album . ' >> '. $index . '. ' . $title . PHP_EOL . $url . PHP_EOL;
    exec("mkdir -p \"$path\" && curl -L -H \"User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0\" -f \"$url\" -o \"$path/$index. $title - $singer.mp3\"");
    }
    //sleep(1);
    }
    }
    $index ++;
    }
    }
    deprecated
  2. mysteriouss revised this gist Mar 12, 2018. 1 changed file with 68 additions and 42 deletions.
    110 changes: 68 additions & 42 deletions netease-qq.php
    Original file line number Diff line number Diff line change
    @@ -56,47 +56,73 @@
    $artist_name = end($artist_name);
    var_dump($artist_name);

    $curl = curl_init();
    $search = urlencode("$album_name-$artist_name");
    curl_setopt_array($curl, array(
    CURLOPT_URL => "http://music.able.cat/download/api/?id=$search&t=qq",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 5,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
    "User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0"
    ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
    echo "cURL Error #:" . $err;
    } else {
    //echo $response . PHP_EOL;

    $response = json_decode($response,true);
    if(!is_array($response) ||
    !array_key_exists('count',$response) ||
    !array_key_exists('data',$response)){
    return;
    }
    $count = $response['count'];
    if(intval($count) < 1){
    return;
    }elseif (intval($count) > 1) {
    //echo json_encode($response) . PHP_EOL;
    }
    preg_match("/<ul class=\"f-hide\">(.*?)<\/ul>/i",$response,$album);

    echo 'album:' . PHP_EOL;
    var_dump($album);

    if(!count($album)){
    //var_dump($response);
    return;
    }
    $album = end($album);

    preg_match_all("/<li><a href=\"\/song\?id=([0-9]+)\">(.*?)<\/a><\/li>/i",$album,$songs);

    echo 'songs:' . PHP_EOL;
    var_dump($songs);

    $all_data = $response['data'];
    $index = 1;
    foreach ($all_data as $data){
    if(!count($songs)){

    return;
    }

    $songs_name = $songs[2];
    $index = 1;
    foreach ($songs_name as $song_name){
    $curl = curl_init();
    $song_name .= '-' . $artist_name;
    $song_name = urlencode($song_name);
    curl_setopt_array($curl, array(
    CURLOPT_URL => "http://music.able.cat/download/api/?id=$song_name&t=qq",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 5,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
    "User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0"
    ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
    echo "cURL Error #:" . $err;
    } else {
    //echo $response . PHP_EOL;

    $response = json_decode($response,true);
    if(!is_array($response) ||
    !array_key_exists('count',$response) ||
    !array_key_exists('data',$response)){
    continue;
    }
    $count = $response['count'];
    if(intval($count) < 1){
    continue;
    }elseif (intval($count) > 1) {
    //echo json_encode($response) . PHP_EOL;
    }

    $data = $response['data'];
    if(is_array($data) && count($data)){
    $data = reset($data);
    }

    if(is_array($data) &&
    array_key_exists('flac',$data) &&
    @@ -111,7 +137,7 @@

    $album = str_replace('/','|',$album);
    $album = str_replace(':','',$album);
    $path = __DIR__.'/'. $album_name;
    $path = __DIR__.'/'. $album_name . ' - ' . $artist_name;
    $title = str_replace('/','|',$title);
    $title = str_replace(':','',$title);

    @@ -127,7 +153,7 @@
    }
    //sleep(1);
    }
    $index ++;
    }
    $index ++;
    }
    }
  3. mysteriouss revised this gist Mar 12, 2018. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions netease-qq.php
    Original file line number Diff line number Diff line change
    @@ -118,12 +118,12 @@
    if(strlen( $data['flac'] )){
    $flac = $data['flac'];
    echo '<< '. $album . ' >> '. $index . '. ' . $title . PHP_EOL . $flac . PHP_EOL;
    exec("mkdir -p \"$path\" && curl -H \"User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0\" -f \"$flac\" -o \"$path/$index. $title - $singer.flac\"");
    exec("mkdir -p \"$path\" && curl -L -H \"User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0\" -f \"$flac\" -o \"$path/$index. $title - $singer.flac\"");
    }else{

    $url = $data['url'];
    echo '<< '. $album . ' >> '. $index . '. ' . $title . PHP_EOL . $url . PHP_EOL;
    exec("mkdir -p \"$path\" && curl -H \"User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0\" -f \"$url\" -o \"$path/$index. $title - $singer.mp3\"");
    exec("mkdir -p \"$path\" && curl -L -H \"User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0\" -f \"$url\" -o \"$path/$index. $title - $singer.mp3\"");
    }
    //sleep(1);
    }
  4. mysteriouss revised this gist Mar 12, 2018. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions netease-qq.php
    Original file line number Diff line number Diff line change
    @@ -41,7 +41,10 @@

    preg_match("/<h2 class=\"f-ff2\">(.*?)<\/h2>/i",$response,$album_name);

    if(!count($album_name)) return;
    if(!count($album_name)) {
    echo 'Please try with album url : e.g. http://music.163.com/#/album?id=36714070' . PHP_EOL;
    return;
    }
    echo 'album name: ' . PHP_EOL;
    $album_name = end($album_name);
    var_dump($album_name);
    @@ -115,16 +118,16 @@
    if(strlen( $data['flac'] )){
    $flac = $data['flac'];
    echo '<< '. $album . ' >> '. $index . '. ' . $title . PHP_EOL . $flac . PHP_EOL;
    exec("mkdir -p \"$path\" && wget -q \"$flac\" -O \"$path/$index. $title - $singer.flac\"");
    exec("mkdir -p \"$path\" && curl -H \"User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0\" -f \"$flac\" -o \"$path/$index. $title - $singer.flac\"");
    }else{

    $url = $data['url'];
    echo '<< '. $album . ' >> '. $index . '. ' . $title . PHP_EOL . $url . PHP_EOL;
    exec("mkdir -p \"$path\" && wget -q \"$url\" -O \"$path/$index. $title - $singer.mp3\"");
    exec("mkdir -p \"$path\" && curl -H \"User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0\" -f \"$url\" -o \"$path/$index. $title - $singer.mp3\"");
    }
    //sleep(1);
    }
    $index ++;
    }
    }
    }
    }
  5. mysteriouss revised this gist Mar 12, 2018. 1 changed file with 41 additions and 67 deletions.
    108 changes: 41 additions & 67 deletions netease-qq.php
    Original file line number Diff line number Diff line change
    @@ -53,73 +53,47 @@
    $artist_name = end($artist_name);
    var_dump($artist_name);

    preg_match("/<ul class=\"f-hide\">(.*?)<\/ul>/i",$response,$album);

    echo 'album:' . PHP_EOL;
    var_dump($album);

    if(!count($album)){
    //var_dump($response);
    return;
    }
    $album = end($album);

    preg_match_all("/<li><a href=\"\/song\?id=([0-9]+)\">(.*?)<\/a><\/li>/i",$album,$songs);

    echo 'songs:' . PHP_EOL;
    var_dump($songs);

    if(!count($songs)){

    return;
    }

    $songs_name = $songs[2];
    $index = 1;
    foreach ($songs_name as $song_name){
    $curl = curl_init();
    $song_name .= '-' . $artist_name;
    $song_name = urlencode($song_name);
    curl_setopt_array($curl, array(
    CURLOPT_URL => "http://music.able.cat/download/api/?id=$song_name&t=qq",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 5,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
    "User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0"
    ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
    echo "cURL Error #:" . $err;
    } else {
    //echo $response . PHP_EOL;

    $response = json_decode($response,true);
    if(!is_array($response) ||
    !array_key_exists('count',$response) ||
    !array_key_exists('data',$response)){
    continue;
    }
    $count = $response['count'];
    if(intval($count) < 1){
    continue;
    }elseif (intval($count) > 1) {
    //echo json_encode($response) . PHP_EOL;
    }
    $curl = curl_init();
    $search = urlencode("$album_name-$artist_name");
    curl_setopt_array($curl, array(
    CURLOPT_URL => "http://music.able.cat/download/api/?id=$search&t=qq",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 5,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
    "User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0"
    ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
    echo "cURL Error #:" . $err;
    } else {
    //echo $response . PHP_EOL;

    $response = json_decode($response,true);
    if(!is_array($response) ||
    !array_key_exists('count',$response) ||
    !array_key_exists('data',$response)){
    return;
    }
    $count = $response['count'];
    if(intval($count) < 1){
    return;
    }elseif (intval($count) > 1) {
    //echo json_encode($response) . PHP_EOL;
    }

    $data = $response['data'];
    if(is_array($data) && count($data)){
    $data = reset($data);
    }
    $all_data = $response['data'];
    $index = 1;
    foreach ($all_data as $data){

    if(is_array($data) &&
    array_key_exists('flac',$data) &&
    @@ -150,7 +124,7 @@
    }
    //sleep(1);
    }
    $index ++;
    }
    $index ++;
    }
    }
  6. mysteriouss revised this gist Mar 11, 2018. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion netease-qq.php
    Original file line number Diff line number Diff line change
    @@ -75,7 +75,6 @@
    }

    $songs_name = $songs[2];
    $songs_info = array();
    $index = 1;
    foreach ($songs_name as $song_name){
    $curl = curl_init();
  7. mysteriouss revised this gist Mar 11, 2018. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions netease-qq.php
    Original file line number Diff line number Diff line change
    @@ -80,12 +80,13 @@
    foreach ($songs_name as $song_name){
    $curl = curl_init();
    $song_name .= '-' . $artist_name;
    $song_name = urlencode($song_name);
    curl_setopt_array($curl, array(
    CURLOPT_URL => "http://music.able.cat/download/api/?id=$song_name&t=qq",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 3,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_MAXREDIRS => 5,
    CURLOPT_TIMEOUT => 30,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
  8. mysteriouss revised this gist Mar 11, 2018. 1 changed file with 17 additions and 3 deletions.
    20 changes: 17 additions & 3 deletions netease-qq.php
    Original file line number Diff line number Diff line change
    @@ -39,6 +39,20 @@
    echo "cURL Error #:" . $err;
    } else {

    preg_match("/<h2 class=\"f-ff2\">(.*?)<\/h2>/i",$response,$album_name);

    if(!count($album_name)) return;
    echo 'album name: ' . PHP_EOL;
    $album_name = end($album_name);
    var_dump($album_name);

    preg_match("/<a class=\"s-fc7\" .*?>(.*?)<\/a>/i",$response,$artist_name);

    if(!count($artist_name)) return;
    echo 'artist name: ' . PHP_EOL;
    $artist_name = end($artist_name);
    var_dump($artist_name);

    preg_match("/<ul class=\"f-hide\">(.*?)<\/ul>/i",$response,$album);

    echo 'album:' . PHP_EOL;
    @@ -65,7 +79,7 @@
    $index = 1;
    foreach ($songs_name as $song_name){
    $curl = curl_init();

    $song_name .= '-' . $artist_name;
    curl_setopt_array($curl, array(
    CURLOPT_URL => "http://music.able.cat/download/api/?id=$song_name&t=qq",
    CURLOPT_RETURNTRANSFER => true,
    @@ -120,7 +134,7 @@

    $album = str_replace('/','|',$album);
    $album = str_replace(':','',$album);
    $path = __DIR__.'/'. $album;
    $path = __DIR__.'/'. $album_name;
    $title = str_replace('/','|',$title);
    $title = str_replace(':','',$title);

    @@ -139,4 +153,4 @@
    }
    $index ++;
    }
    }
    }
  9. mysteriouss created this gist Mar 11, 2018.
    142 changes: 142 additions & 0 deletions netease-qq.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,142 @@
    <?php
    /**
    * Created by PhpStorm.
    * User: user
    * Date: 11/03/2018
    * Time: 2:20 AM
    */
    date_default_timezone_set('Asia/Shanghai');

    if(!isset($argv[1])){
    echo 'Usage: php netease.php $url' . PHP_EOL;
    return;
    }

    echo str_replace('/#','',$argv[1]) . PHP_EOL;

    $curl = curl_init();

    curl_setopt_array($curl, array(
    CURLOPT_URL => str_replace('/#','',$argv[1]),
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 3,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
    "User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/604.5.6 (KHTML, like Gecko) Version/11.0.3 Safari/604.5.6",
    "Cache-Control: no-cache",
    ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
    echo "cURL Error #:" . $err;
    } else {

    preg_match("/<ul class=\"f-hide\">(.*?)<\/ul>/i",$response,$album);

    echo 'album:' . PHP_EOL;
    var_dump($album);

    if(!count($album)){
    //var_dump($response);
    return;
    }
    $album = end($album);

    preg_match_all("/<li><a href=\"\/song\?id=([0-9]+)\">(.*?)<\/a><\/li>/i",$album,$songs);

    echo 'songs:' . PHP_EOL;
    var_dump($songs);

    if(!count($songs)){

    return;
    }

    $songs_name = $songs[2];
    $songs_info = array();
    $index = 1;
    foreach ($songs_name as $song_name){
    $curl = curl_init();

    curl_setopt_array($curl, array(
    CURLOPT_URL => "http://music.able.cat/download/api/?id=$song_name&t=qq",
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => "",
    CURLOPT_MAXREDIRS => 3,
    CURLOPT_TIMEOUT => 10,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => "GET",
    CURLOPT_HTTPHEADER => array(
    "User-Agent: JSBoxMain/97 CFNetwork/811.5.4 Darwin/16.7.0"
    ),
    ));

    $response = curl_exec($curl);
    $err = curl_error($curl);

    curl_close($curl);

    if ($err) {
    echo "cURL Error #:" . $err;
    } else {
    //echo $response . PHP_EOL;

    $response = json_decode($response,true);
    if(!is_array($response) ||
    !array_key_exists('count',$response) ||
    !array_key_exists('data',$response)){
    continue;
    }
    $count = $response['count'];
    if(intval($count) < 1){
    continue;
    }elseif (intval($count) > 1) {
    //echo json_encode($response) . PHP_EOL;
    }

    $data = $response['data'];
    if(is_array($data) && count($data)){
    $data = reset($data);
    }

    if(is_array($data) &&
    array_key_exists('flac',$data) &&
    array_key_exists('Album',$data) &&
    array_key_exists('title',$data) &&
    array_key_exists('singer',$data) &&
    array_key_exists('url', $data)
    ){
    $album = $data['Album'];
    $title = $data['title'];
    $singer = $data['singer'];

    $album = str_replace('/','|',$album);
    $album = str_replace(':','',$album);
    $path = __DIR__.'/'. $album;
    $title = str_replace('/','|',$title);
    $title = str_replace(':','',$title);

    if(strlen( $data['flac'] )){
    $flac = $data['flac'];
    echo '<< '. $album . ' >> '. $index . '. ' . $title . PHP_EOL . $flac . PHP_EOL;
    exec("mkdir -p \"$path\" && wget -q \"$flac\" -O \"$path/$index. $title - $singer.flac\"");
    }else{

    $url = $data['url'];
    echo '<< '. $album . ' >> '. $index . '. ' . $title . PHP_EOL . $url . PHP_EOL;
    exec("mkdir -p \"$path\" && wget -q \"$url\" -O \"$path/$index. $title - $singer.mp3\"");
    }
    //sleep(1);
    }
    }
    $index ++;
    }
    }