Casts

For operations to be performed on casts/artists there is the method(casts()) that retrieves the data form the webpage and a class(Cast) for storing it.

casts()

def casts(url: str)


This function is used to retrieve data from the webpage.

Parameters:

  • link(str) - The url for the MDL webpage containing information on Casts/Artists.

Raises:

  • InvalidURLError - The entered URL was not a valid one.

  • NotMDLError - The entered URL did not belong to MDL.

  • RequestTimeoutError - There was some error getting the response from the server.

  • BadHttpResponseError - Did not get a positive response from the server.

Returns:

All the data that was extracted from the webpage in the Cast object.

Return type:

Cast

Cast

class Cast

This is the container class whose object contains all the data extracted form the webpage.

Supported Operations:

str(x) - Will return the name of the Cast/Artist the object contains details about.

Attributes:

  • name - Name of the person.

  • description - A short bio on the person.

  • url - The url that was used for scraping the data.

  • thumbnail - Thumbnail obtained directly from the website.

  • first_name - First name of the person.

  • family_name - Family name of the person.

  • native_name - Native name of the person.

  • nationality - Nationality of the person.

  • gender - Gender of the person.

  • dob - Date of birth of the person.

  • age - Age of the person.

  • works - All the performances or established works of movies/dramas done by the person.

  • aka - Alias or also known as names of the person.

Methods:

def save(self, file, overwrite=False)


Saves the data in the object to a file in JSON format.

Parameters:

  • file(str) - The name of the file to save the data into.

  • overwrite(bool) - A boolean that indicates weather to overwrite data if it already exists.

Returns:

Returns a boolean value that indicates whether the data was saved successfully or not.

Return Type:

bool

Note: In some scenarios, two or more different people will have the same name. In that case, the name will change to <name>(n). Where n is a number that starts from 1 and increments by one each time a conflict is found. Starts from 2nd person with the same name.

def to_json(self)


Returns a json formatted string of the data present in the object.

Returns:

The json formatted string.

Return Type:

str

def dumps(self)


Returns a dict of data with attributes as keys and value as attribute’s value.

Returns:

A dict of data present in the object.

Return Type:

dict