Downloading Interactively

Making My Music Download interactive

The Python script i last made to download the music from was designed in such a way that it download songs when the album link was given . Because then it was to Download all the music from the site and an interactive interface was not required . The created a list of all the movies in a particular category and shell scripting was used to automatically download all the music from this list . Now I think that it should be made interactive , so I changed the script to and added the ability to search from their site and crab the link of the search result . python have an -i option which executes all the code in the file and gives a interactive shell.

there are three function new() , search_album() , download()

new() โ€“ load the new music from Hindi Malayalam and Tamil Category search_album() โ€“ takes a string as argument and searches the string in and loads the top five result download() โ€“ shows all the loaded link and prompt for the index number of the movie to be downloaded

a global variable is declared to to store the the result of new() and search_album() then calling download to download any of the loaded link

modified code

# Made by :  Nemesis
# Discription :This downloads The songs from site named
# syantax : python3 -i
# Requirements : python modules bs4
# System Package : eyed3 [User for insterting artwork]

import bs4
import requests
import sys
import re
import subprocess
import os

movie_list = []

def download_album(s):

    #Downloads the webpage and create a Beautifull Soup Object
    # url=sys.argv[1]
    # url = ""

    url = str(s)
    mio = requests.get(url)
    mio_soup = bs4.BeautifulSoup(mio.text,'html.parser')

    #Extracts some informations :

    movie_name =".*?\([0-9]+\)",'div.heading')[0].text).group(0)
    art_work =' > img["src"]')[0]["src"]
    year ='\(([0-9][0-9]+)\)',movie_name).group(1)
    link ='*?)/(.*)/Art-350.jpg',art_work).group(1)
    artwork_path = movie_name+"/artwork.jpg"

    print("\nMovie Name : "+movie_name )["mkdir" ,"-p",movie_name])

    #Downloading the artwork
    print("Downloading Artwork")
    if not os.path.exists(artwork_path):["wget","-q","--show-progress" ,"-c",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 = ""+link+"/"+i["album_id"][0]+"/"+i["album_id"]+"/"+disk_number+"_"+track_number+" - "+track_name+"-vbr-V5.mp3"
        print("Downloading ",track_name,"  ...","\n")["wget","-q","--show-progress","-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]
        with open("log",'a') as log_file:

def new():
    url = ["", "",""]
    global movie_list
    movie_list = []
    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'}):
            movie_list = movie_list + [ [j.find("h2").text , ""+j["href"]] for j in"a")]
    for i in movie_list:
        print(" {0:20}: {1} ".format(i[0],i[1]))
    # return movie_list
def search_album(s):
    global movie_list
    movie_list = []
    s = s.replace(' ','+')
    url = "" + s
    mio = requests.get(url)
    mio_soup = bs4.BeautifulSoup(mio.text,"html.parser")
    for i in mio_soup.find_all('div', {'id' : 'albums'}):
        movie_list = [ ['\<span\>(.*)\</span\>',str('span')[0])).group(1) , ""+j['href'] ] for j in'a')[1:] ]
    for i in movie_list:
        print(" {0:20}: {1} ".format(i[0],i[1]))
    # return movie_list[0:5]

def download():
    global movie_list
    index = 1
    for i in movie_list:
        print(str(index)+ " {0:20}: {1} ".format(i[0],i[1]))
        index = index + 1
    print("Enter the number to Download : ")
    index = int(input())