API Reference

music_scraper.main.main()[source]

The entry point for the app. Called when music-scraper is typed in terminal. Starts the GUI and starts the scraping process after the input is given

music_scraper.main.start_gui(process)[source]

A function that takes care of starting the GUI and stops the Scrapy crawler process when exited from program.

Parameters:process (CrawlerProcess) – The scrapy crawler process that is used to scrape the web. The instance is used for stopping the process.
class music_scraper.gui.GUI[source]

A static class containing attributes to control the GUI process of the app

Attributes:
screen:The maximum speed that such a bird can attain.
status:The locale where these birds congregate to reproduce.
strings:The list of song names, scraped from the web
size_dict:Dictionary mapping file names to size of file.
url_dict:Dictionary mapping file names to url of file.
pages:Total number of pages required to display the song list.
page:current page number
position:current highlighted song name.
max_row:Maximum number of rows that can be displayed in the terminal window.
row_num:Total number of rows required.
box:Box object which is drawn on the screen with curses
high_light_text:
 curses color of highlighted text.
normal_text:Normal text color.
key:current pressed key value.
run_download:Used to indicate an ongoing download
gui_stopped:Used to indicate whether GUI is on or off
message:The message or query passed to scrapy and got as input from user
static add_bottom_menus()[source]

Adds the bottom menu Exit and Download

static display_list()[source]

Displays the list of song names scraped from web.

static download_item()[source]

It downloads the song from the url and saves it in the file.

static get_input()[source]

Loops till user types a non empty query :return: The user inputted query.

static init_display()[source]

Inits the display GUI

static my_raw_input(r, c, prompt_string)[source]

Gets input on the screen :param r: y coordinate :param c: x coordinate :param prompt_string: The prompt string :return: The input string

static on_key_down()[source]

Called when down arrow is pressed

static on_key_enter()[source]

Called when enter key is pressed. It starts the download process in a new thread

static on_key_left()[source]

Called when left arrow key is pressed.

static on_key_right()[source]

Called when right arrow key is pressed.

static on_key_up()[source]

Called when up arrow key is pressed.

static refresh_values()[source]

Refresh the parameters when the size of list changes in display

static update_on_key()[source]

Loops to get a key input and updates the screen accordingly

static update_screen()[source]

Updates the screen each time a key is pressed.

class music_scraper.threads.DownloadThread(func)[source]

A thread used for downloading Audio files

Parameters:func – The function that is run in the thread.
class music_scraper.threads.GUIThread(process, func)[source]

A thread used to run GUI in parallel

Parameters:
  • process (CrawlerProcess) – Process of Scrapy that scrapes the Web for songs
  • func – The function to run when the thread is started.
class music_scraper.spiders.music_spider.MusicSpider(name=None, **kwargs)[source]
name = 'music'
parse(response)[source]

Override function of the class scrapy.Spider. Called when response is obtained :param response: Response object used to get the details of the webpage

parse_header(response)[source]

Callback function called when header of each link in each result is obtained :param response: Response object used to get the details of the webpage

parse_result_contents(response)[source]

Callback function called when the webpage of each result is opened. :param response: Response object used to get the details of the webpage

music_scraper.spiders.music_spider.is_standard_website(href)[source]

Function to remove urls belonging to some famous sites

Parameters:href (str) – the url
Return bool:True or False