Hey wazzaaaaaAAA!

Well fuckers, we have something pretty cool today for all the music lovers, even we the bots love it, without it everything will be meaningless with lack of color in life.

To the point, what we are going to do:

  1. Automatically search for google results using a dork(explained below) for mp3.
  2. Grab the first 5 results from google.
  3. Download all mp3 files located on those urls.

google dork is a search command that will display pages with folders full of specific filetypes or more, so if you don’t know how to search you should do it this way:

“index of” + “mp3” + “radiohead” -html -htm -php

so this will look for folders (index of) that contains mp3 with the keyword radiohead and only display html, html and php pages.

The code is commented and well explained, if questions leave a comment.

The code is the same as we preview before in other posts, we have to define the search url using the dork, so we loop the first 5 results:

<?php
require_once('simple_html_dom.php'); // we need this library to parse
$keyword = urlencode('"index of" + "mp3" + "radiohead" -html -htm -php'); //the google dork escaped
$counter = 0; //set the counter to just do it the first 5 links.
$limit = 10; // e limit to 5
$google  = 'http://www.google.com/search?q=' . $keyword .'&num=50';
// we start searching in google ;)
echo '#####################################';
echo '###        SEARCHING IN GOOGLE    ####';
echo '#####################################';
$html = file_get_html($google);
$linkObjs = $html->find('h3.r a');
foreach ($linkObjs as $linkObj) {
    $title = trim($linkObj->plaintext);
    $link  = trim($linkObj->href);
    // if it is not a direct link but url reference found inside it, then extract
    if (!preg_match('/^https?/', $link) && preg_match('/q=(.+)&amp;sa=/U', $link, $matches) && preg_match('/^https?/', $matches[1])) {
        $link = $matches[1];
    } else if (!preg_match('/^https?/', $link)) { // skip if it is not a valid link
        continue;    
    }
    
    print 'Title: ' . $title . '\n';
    print 'Link: ' . $link . '\n';   
    if($counter <= $limit ) { //logic for only the limit you decide on the config
      //this is very interesting, you can do it with also the below commented alternative
      $cmd = "wget -A mp3 -m -p -E -k -K -np ". $link;
      //$cmd = "wget --accept mp3 --mirror --progress --adjust-extension --convert-links --backup-converted --no-parent ".$link;
      exec($cmd);
      $counter++;
    } 
}
?>

The point of this script is to download all the mp3 files you want from your favorite artist, don’t worry it will separate all the grabbed content into specific folder for each of the domain that was used to download them and respective folders, so you can navigate to each and select the final mp3 that will remain with you and erase the others.

What do you think? Ready to party?

robotdj

 

installwizardSometimes you just want to make your life easier on deploying a server in seconds with all the dependencies you need to run many languages or maybe a LAMP config easily.

I made this whole compilation guys, but right now I dont feel like finishing it. So I decided to add a github repo so you can just clone and run it very quick. But I will be updating this post frequently. Just make sure to comment in order to report a bug or something that needs to be modified, also there https://github.com/wizardofbots/wizardinstall

So I decided to call it wizardinstall 😉 we will be adding the repos you need in order to have everything ready to start on a $5 cents digitalocean server to have a linux shell on your smartphone doing a realtime connection and executing your scripts!

So check out the code, you will learn how to use it, and understand the logics, will add comments on each line if necessary so you guys understand:

#!/bin/bash
# ******************************************
# Program: Dev mode install
# Developer: Wizard of Bots
# Site: http://wizardofbots.com/network
# Github: https://github.com/wizardofbots/wizardinstall
# Date: 16-07-2016
# ******************************************
# this line below is checking if the lsb_release -is comment response is 
# equal to Ubuntu and also Debian, because we can use apt-get instead of yum.
if [ "`lsb_release -is`" == "Ubuntu" ] || [ "`lsb_release -is`" == "Debian" ] 
then
    # save time and install essential and then all libraries
    sudo apt-get install -y build-essential;
    # install git
    sudo apt-get install git; # git is really useful, in fact clone this from: https://github.com/wizardofbots/wizardinstall
    # install python
    sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev;
    sudo apt-get python2.7;
    sudo apt-get install python-software-properties;
    # install php
    sudo apt-get install apache2;
    sudo apt-get install curl;
    sudo apt-get install mysql-server;
    sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql;
    sudo systemctl restart apache2;
    sudo systemctl status apache2;
    sudo apt-get install php-cli;
    # install package manager for PHP: Composer
    sudo apt-get update;
    # install perl
    sudo apt-get install perl;
    # install ruby
    sudo apt-add-repository ppa:brightbox/ruby-ng
    sudo apt-get update
    sudo apt-get install ruby1.9.3
    # installing nodejs
    sudo apt-get update;
    curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -;
    sudo apt-get install -y nodejs;
    sudo chmod 777 -R /var/www/;
    sudo printf "<?php\nphpinfo();\n?>" > /var/www/html/info.php;
    sudo service apache2 restart;
# then this logic identifies if the release is CentOS or RedHat so we can use yum
elif [ "`lsb_release -is`" == "CentOS" ] || [ "`lsb_release -is`" == "RedHat" ]
then
    # this lines are not working properly right now. So wait for the update
    sudo yum -y install httpd mysql-server mysql-devel php php-mysql php-fpm;
    sudo yum -y install epel-release phpmyadmin rpm-build redhat-rpm-config;
    sudo yum -y install mysql-community-release-el7-5.noarch.rpm proj;
    sudo yum -y install tinyxml libzip mysql-workbench-community;
    sudo chmod 777 -R /var/www/;
    sudo printf "<?php\nphpinfo();\n?>" > /var/www/html/info.php;
    sudo service mysqld restart;
    sudo service httpd restart;
    sudo chkconfig httpd on;
    sudo chkconfig mysqld on;

# we will add pacman for Arch Linux soon
else
    echo "Unsupported Operating System";
fi