Key Functions¶
This page documents the functions and objects you will interact with at a high level. They are the most reliable source for obtaining pages and should preffered over passing the html to the models yourself.
search¶
- moddb.base.search(category, *, query=None, sort=None, page=1, **filters)[source]¶
Search for for a certain type of models and return a list of thumbnails of that model. This function was created to make full use of moddb’s filter and sorting system as long as the appropriate parameters are passed. Because this function is a single one for every model type in moddb the parameters that can be passed vary between model type but the documentation will do its best to document all the possibilities. All the objects listed in this function are enumerations. Finally it is key to note that the result attribute of the returned search object is not a list of the parsed pages but a list of Thumbnail objects containing the image, url, name and type of the object on which. Call the thumbnail’s parse method and it will return the full model.
- Parameters:
category (SearchCategory) – The model type that you want to search
query (str) – String to search for in the model title
sort (Tuple[str, str]) – The tuple to sort by, look at the models your are searching for documentation on sorting.
page (int) – The page of results to get first
filters (dict) – Search filters
- Returns:
The search object containing the current query settings (so at to be able to redo the search easily), pagination metadata and helper methods to navigate the list of results.
- Return type:
parse_page¶
parse_results¶
- moddb.base.parse_results(url, *, params={})[source]¶
Parse a list of results and return them as a list of thumbnails.
- Parameters:
url (str) – The url of the result list to parse
- Returns:
The list of thumbnails, wrapped in a ResultList so as to benefit from the helper methods that help with navigation
- Return type:
login¶
- moddb.base.login(username, password)[source]¶
Login the user to moddb through the library, this allows user to see guest comments and see private groups they are part of.
- Parameters:
- Raises:
ValueError – The password or username was incorrect
- Returns:
The member you are logged in as
- Return type: