<commit_before>---
title: Downloading some Songs !! 
updated:  2017-04-10 15:32:03
---
- [Music India Online Download script](#org16b46f7)
  - [Download Movie Songs](#orgf8c7f95)
  - [Some Code snippet](#org659ef73)
    - [New Release From Hindi Malayalam and Tamil catagory](#org0bb7cee)
    - [List of All Movies in That catagory](#org6ff3104)
    - [Downloading all songs of catagory](#orgb9bea1e)


<a id="org16b46f7"></a>

# Music India Online Download script

Who likes to downlaod music one by one we are too lazy , we script . This is a script i wrote to download music from [MusicIndiaOnline](http://mio.to/) . This site contain a large repositories of Indian Music and the service is free . It plays the music in a custom player . Opening the firefox web developer option and inspecting we could see the mp3 request links . intestingly there is pattern in the link

> "http://media-audio.mio.to/various_artists/A/Aashiqui 2 (2013)/1_1 - Tum Hi Ho-vbr-V5.mp3"

> " http://media-audio.mio.to/by_artist/A/AR. Rahman/I (2014)/1_1 - Mersalaayitten-vbr-V5.mp3 "

by looking into the source html we could extract all the informations to create the link

> "http://media-audio.mio.to/< by_artist or various_artists >/< first letter of album_id >/< album_id >/< disk_number >_< track_number > - < track_name >-vbr-V5.mp3 "

so we scrap the webpage using [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/) and extract all the details . the source contains the artwork link from which we can get wether it is by_artist or various_artists by search with Regular expression

final we create the link and download the file to its respective folder . the mp3 file downloaded does not contain any tag so we add them using a [eyed3](http://eyed3.nicfit.net/) which is a tag editor


<a id="orgf8c7f95"></a>

## Download Movie Songs

Dowload Movie songs into the directory

*mio.py*
```python
# Made by :  Nemesis
# Discription :This downloads The songs from site named mio.to
# syantax : python3 mio.py <link>
# Requirements : python modules bs4,taglib
# System Package : eyed3 [User for insterting artwork]

import bs4,requests,sys,re,taglib,subprocess,os

#Downloads the webpage and create a Beautifull Soup Object
url=sys.argv[1]
# url = "http://mio.to/album/Aashiqui+2+%282013%29"
mio = requests.get(url)
mio_soup = bs4.BeautifulSoup(mio.text,'html.parser')

#Extracts some informations :

movie_name = re.search(r".*?\([0-9]+\)",mio_soup.select('div.heading')[0].text).group(0)
art_work = mio_soup.select('div.group.info > img["src"]')[0]["src"]
year = re.search(r'\(([0-9][0-9]+)\)',movie_name).group(1)
link = re.search(r'http://media-images.mio.to/(.*?)/(.*)/Art-350.jpg',art_work).group(1)
artwork_path = movie_name+"/artwork.jpg"

print("\nMovie Name : "+movie_name )
# print("Music Director : "+music_director)

subprocess.call(["mkdir" ,"-p",movie_name])

log = open("log","w")
#Downloading the artwork
if not os.path.exists(artwork_path):
    subprocess.call(["wget","-c","-q",art_work,"-O",artwork_path])

#Finds all the songs links and downloads the and inserts the tags

for i in mio_soup.find_all("tr" ,{"class" : "song-link"}):
    artist = ",".join(re.findall('"(.*?)"',i['track_artist']))
    album_name = movie_name
    track_number = i["track_number"]
    disk_number = i["disc_number"]
    track_name = i["track_name"]
    path = album_name+"/"+track_name+".mp3"
    #Create the download links of the mp3
    mp3_link = "http://media-audio.mio.to/"+link+"/"+i["album_id"][0]+"/"+i["album_id"]+"/"+disk_number+"_"+track_number+" - "+track_name+"-vbr-V5.mp3"
    print("Downloading ",track_name,"  ...")
    if not os.path.exists(path):
        subprocess.call(["wget","-q","-c",mp3_link,"-O",path])
        # Inserting the tag details
        command = ["eyeD3","--add-image",artwork_path+":FRONT_COVER",path,"-a",artist,"-A",album_name,"-t",track_name,"-n",track_number,"-Y",year]
        subprocess.call(command,stdout=log)
```

```sh
python3  mio.py  < link >
```


<a id="org659ef73"></a>

## Some Code snippet


<a id="org0bb7cee"></a>

### New Release From Hindi Malayalam and Tamil catagory

*new.py*
```python
import bs4,requests


url = ["http://mio.to/Malayalam/Movie+Songs", "http://mio.to/Hindi/Movie+Songs","http://mio.to/Tamil/Movie+Songs"]

print("| Movie Name | Links |")
print("|--------------------|")
for i in url:
    mio = requests.get(i)
    mio_soup = bs4.BeautifulSoup(mio.text,"html.parser")
    for i in mio_soup.find_all('div', {'id' : '#trending-now'}):
        for j in i.select("a"):
             print("| "+j.find("h2").text+"| http://mio.to" + j["href"]+"|")
```


<a id="org6ff3104"></a>

### List of All Movies in That catagory

*list.py*
```python
import requests,bs4,sys
url =  "http://www.mio.to/Hindi/Movie+Songs/albums/decade/2010"
while True:
      mio = requests.get(url)
      mio_soup = bs4.BeautifulSoup(mio.text,'html.parser')
      for i in mio_soup.find_all("a" , {"class" : "img-cover-175"}):
            print("| http://mio.to"+i["href"])
            try:
                url = "http://mio.to" + mio_soup.find_all("a" , {"class" : "next-page"})[0]["href"]
            except IndexError:
                exit()
```


<a id="orgb9bea1e"></a>

### Downloading all songs of catagory

```sh
python3 list.py < link > | xargs -n1 python3 mio.py
```

Downloading full Hindi Songs

shell script
```sh
for i in {19{3..9}0,20{0,1}0};do
    python3 list.py "http://mio.to/Hindi/Movie+Songs/albums/decade/$i" | xargs -n1 python3 mio.py;
done
```<commit_msg>Some Editing<commit_after>---
title: Downloading some Songs !! 
updated:  2017-04-10 15:32:03
---
- [Music India Online Download script](#org16b46f7)
  - [Download Movie Songs](#orgf8c7f95)
  - [Some Code snippet](#org659ef73)
    - [New Release From Hindi Malayalam and Tamil catagory](#org0bb7cee)
    - [List of All Movies in That catagory](#org6ff3104)
    - [Downloading all songs of catagory](#orgb9bea1e)


<a id="org16b46f7"></a>

# Music India Online Download script

Who likes to downlaod music one by one we are too lazy , we script . This is a script i wrote to download music from [MusicIndiaOnline](http://mio.to/) . This site contain a large repositories of Indian Music and the service is free . It plays the music in a custom player . Opening the firefox web developer option and inspecting we could see the mp3 request links . intestingly there is pattern in the link

> "http://media-audio.mio.to/various_artists/A/Aashiqui 2 (2013)/1_1 - Tum Hi Ho-vbr-V5.mp3"

> " http://media-audio.mio.to/by_artist/A/AR. Rahman/I (2014)/1_1 - Mersalaayitten-vbr-V5.mp3 "

by looking into the source html we could extract all the informations to create the link

> "http://media-audio.mio.to/< by_artist or various_artists >/< first letter of album_id >/< album_id >/< disk_number >_< track_number > - < track_name >-vbr-V5.mp3 "

so we scrap the webpage using [BeautifulSoup](https://www.crummy.com/software/BeautifulSoup/bs4/doc/) and extract all the details . the source contains the artwork link from which we can get wether it is by_artist or various_artists by search with Regular expression

final we create the link and download the file to its respective folder . the mp3 file downloaded does not contain any tag so we add them using a [eyed3](http://eyed3.nicfit.net/) which is a tag editor


<a id="orgf8c7f95"></a>

## Download Movie Songs

Dowload Movie songs into the directory

*mio.py*
```python
# Made by :  Nemesis
# Discription :This downloads The songs from site named mio.to
# syantax : python3 mio.py <link>
# Requirements : python modules bs4,taglib
# System Package : eyed3 [User for insterting artwork]

import bs4,requests,sys,re,taglib,subprocess,os

#Downloads the webpage and create a Beautifull Soup Object
url=sys.argv[1]
# url = "http://mio.to/album/Aashiqui+2+%282013%29"
mio = requests.get(url)
mio_soup = bs4.BeautifulSoup(mio.text,'html.parser')

#Extracts some informations :

movie_name = re.search(r".*?\([0-9]+\)",mio_soup.select('div.heading')[0].text).group(0)
art_work = mio_soup.select('div.group.info > img["src"]')[0]["src"]
year = re.search(r'\(([0-9][0-9]+)\)',movie_name).group(1)
link = re.search(r'http://media-images.mio.to/(.*?)/(.*)/Art-350.jpg',art_work).group(1)
artwork_path = movie_name+"/artwork.jpg"

print("\nMovie Name : "+movie_name )
# print("Music Director : "+music_director)

subprocess.call(["mkdir" ,"-p",movie_name])

log = open("log","w")
#Downloading the artwork
if not os.path.exists(artwork_path):
    subprocess.call(["wget","-c","-q",art_work,"-O",artwork_path])

#Finds all the songs links and downloads the and inserts the tags

for i in mio_soup.find_all("tr" ,{"class" : "song-link"}):
    artist = ",".join(re.findall('"(.*?)"',i['track_artist']))
    album_name = movie_name
    track_number = i["track_number"]
    disk_number = i["disc_number"]
    track_name = i["track_name"]
    path = album_name+"/"+track_name+".mp3"
    #Create the download links of the mp3
    mp3_link = "http://media-audio.mio.to/"+link+"/"+i["album_id"][0]+"/"+i["album_id"]+"/"+disk_number+"_"+track_number+" - "+track_name+"-vbr-V5.mp3"
    print("Downloading ",track_name,"  ...")
    if not os.path.exists(path):
        subprocess.call(["wget","-q","-c",mp3_link,"-O",path])
        # Inserting the tag details
        command = ["eyeD3","--add-image",artwork_path+":FRONT_COVER",path,"-a",artist,"-A",album_name,"-t",track_name,"-n",track_number,"-Y",year]
        subprocess.call(command,stdout=log)
```

```sh
python3  mio.py  < link >
```


<a id="org659ef73"></a>

## Some Code snippet


<a id="org0bb7cee"></a>

### New Release From Hindi Malayalam and Tamil catagory

*new.py*
```python
import bs4,requests


url = ["http://mio.to/Malayalam/Movie+Songs", "http://mio.to/Hindi/Movie+Songs","http://mio.to/Tamil/Movie+Songs"]


for i in url:
    mio = requests.get(i)
    mio_soup = bs4.BeautifulSoup(mio.text,"html.parser")
    for i in mio_soup.find_all('div', {'id' : '#trending-now'}):
        for j in i.select("a"):
             print(+j.find("h2").text+"\t http://mio.to" + j["href"])
```


<a id="org6ff3104"></a>

### List of All Movies in That catagory

*list.py*
```python
import requests,bs4,sys
url =  "http://www.mio.to/Hindi/Movie+Songs/albums/decade/2010"
while True:
      mio = requests.get(url)
      mio_soup = bs4.BeautifulSoup(mio.text,'html.parser')
      for i in mio_soup.find_all("a" , {"class" : "img-cover-175"}):
            print("| http://mio.to"+i["href"])
            try:
                url = "http://mio.to" + mio_soup.find_all("a" , {"class" : "next-page"})[0]["href"]
            except IndexError:
                exit()
```


<a id="orgb9bea1e"></a>

### Downloading all songs of catagory

```sh
python3 list.py < link > | xargs -n1 python3 mio.py
```

{'fraction_non_alphanumeric': 0.17088080022228397, 'fraction_numerical': 0.026766694452162638, 'mean_word_length': 3.9283432222729346, 'pattern_counts': {'":': 2, '<': 45, '<?xml version=': 0, '>': 53, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 53, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6019157', 'n_tokens_mistral': 4208, 'n_tokens_neox': 3947, 'n_words': 954}