ModDB Boxes¶
A ‘Box’ is a div tag which resides on the page but does not encompass the page. It is often on the sidebar with for goal to provide meta data on the page it is attached too. Few of these will be returned as individual objects, they are mostly used as attributes of Pages.
ResultList¶
- class moddb.boxes.ResultList(**kwargs)[source]¶
Represents a list of result gotten from one of the many get methods the library uses. This is returned over a regular list because it has additional methods that allow for easily go through all the results. In the same way that the moddb site works, you don’t have to re-run the query manually to get the next page, you simply click a button, same here, you don’t have to recall the base get method, simply use on of the methods here to traverse the results. This emulates a list and will behave like one, so you can use any of the regular list operators in addition to the methods defined below
- append(value)¶
S.append(value) – append value to the end of the sequence
- clear() None -- remove all items from S ¶
- count(value) integer -- return number of occurrences of value ¶
- extend(values)¶
S.extend(iterable) – extend sequence by appending elements from the iterable
- get_all_results()¶
An expensive methods that iterates over every page of the result query and returns all the results. This may return more results than you expected if new page have fit the criteria while iterating.
- Returns:
The list of things you were searching for
- Return type:
Union[CommentList[Any], ResultList[Any]]
- index(value[, start[, stop]]) integer -- return first index of value. ¶
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- insert(index, value)¶
S.insert(index, value) – insert value before index
- next_page()¶
Returns the next page of results as either a CommentList if you are retriving comments or as a ResultList if it’s literally anything else.
- Returns:
The new search objects containing a new set of results.
- Return type:
Union[ResultList, CommentList]
- Raises:
ValueError – There is no next page
- pop([index]) item -- remove and return item at index (default last). ¶
Raise IndexError if list is empty or index is out of range.
- previous_page()¶
Returns the previous page of results as either a CommentList if you are retriving comments or as a ResultList if it’s literally anything else.
- Returns:
The new list-like object of results.
- Return type:
Union[ResultList, CommentList]
- Raises:
ValueError – There is no previous page
- remove(value)¶
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- resort(new_sort)[source]¶
Allows you to sort the whole search by a new sorting parameters. Returns a new search object.
- reverse()¶
S.reverse() – reverse IN PLACE
- to_page(page)¶
Returns the desired page of results as either a CommentList if you are retriving comments or as a ResultList if it’s literally anything else.
- Parameters:
page (int) – A page number within the range 1 - max_page inclusive
- Returns:
The new list-like object of results.
- Return type:
Union[ResultList, CommentList]
- Raises:
ValueError – This page does not exist
ReviewList¶
- class moddb.pages.ReviewList(**kwargs)[source]¶
Represents a list of reviews
- append(value)¶
S.append(value) – append value to the end of the sequence
- clear() None -- remove all items from S ¶
- count(value) integer -- return number of occurrences of value ¶
- extend(values)¶
S.extend(iterable) – extend sequence by appending elements from the iterable
- get_all_results()¶
An expensive methods that iterates over every page of the result query and returns all the results. This may return more results than you expected if new page have fit the criteria while iterating.
- Returns:
The list of things you were searching for
- Return type:
Union[CommentList[Any], ResultList[Any]]
- index(value[, start[, stop]]) integer -- return first index of value. ¶
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
- insert(index, value)¶
S.insert(index, value) – insert value before index
- next_page()¶
Returns the next page of results as either a CommentList if you are retriving comments or as a ResultList if it’s literally anything else.
- Returns:
The new search objects containing a new set of results.
- Return type:
Union[ResultList, CommentList]
- Raises:
ValueError – There is no next page
- pop([index]) item -- remove and return item at index (default last). ¶
Raise IndexError if list is empty or index is out of range.
- previous_page()¶
Returns the previous page of results as either a CommentList if you are retriving comments or as a ResultList if it’s literally anything else.
- Returns:
The new list-like object of results.
- Return type:
Union[ResultList, CommentList]
- Raises:
ValueError – There is no previous page
- remove(value)¶
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
- reverse()¶
S.reverse() – reverse IN PLACE
- to_page(page)¶
Returns the desired page of results as either a CommentList if you are retriving comments or as a ResultList if it’s literally anything else.
- Parameters:
page (int) – A page number within the range 1 - max_page inclusive
- Returns:
The new list-like object of results.
- Return type:
Union[ResultList, CommentList]
- Raises:
ValueError – This page does not exist
Statistics¶
Profile¶
- class moddb.boxes.Profile(html)[source]¶
The profile object is used for several models and as such attribute vary based on which model the profile is attached too. Profiles are only present on Mod, Game, Member, Addon, Engine, Company, Hardware, Software and Group pages.
- Parameters:
html (bs4.BeautifulSoup) – The html to parse. Allows for finer control.
- category¶
The category the page falls under within the context of what the page is. E.g the page is an Addon category will be an AddonCategory enum. If the category of the page doesn’t fall under any of the above mentionned the attribute will be of type SearchCategory.
- Type:
Union[AddonCategory, HardwareCategory, SoftwareCategory, TeamCategory, GroupCategory, SearchCategory]
A dictionnary of share links with the place they will be shared as the key and the url for sharing as the value.
- Type:
- membership¶
Exclusive to Group and Team, represents the join procedure (invitation only, private, public)
- Type:
- developers¶
Exclusive to Game, Mods, Engine and Addon pages. Dictionnary of member/team like thumbnails as values and the role of the member/team as the key (creator, publisher, developer, ect…)
- Type:
- release¶
Exclusive to Game, Mods, Engine and Addon pages. Datetime object of when the page was released, can be None if the page hasn’t seen a release yet.
- Type:
- engine¶
Exclusive to Game and Addon pages. Engine like thumbnails representing the engine the addon/game was built for.
- Type:
- game¶
Exclusive to Mod pages. Game like thumbnail representing the game the mod was built for.
- Type:
- licence¶
Exclusive to Engine and Addon pages. Object representing the licence the engine operates under.
- Type:
- platforms¶
Exclusive to Game, Engine and Addon pages. List of platform like thumbnails representing the plaftorms the software was built for.
- Type:
List[Thumbnail]
- status¶
Exclusive to Games, Mods, Addons, Engines, Hardware .Whether the thing is released, unreleased, ect…
- Type:
Style¶
Thumbnail¶
Comment¶
- class moddb.boxes.Comment(html)[source]¶
A moddb comment object.
- Parameters:
html (bs4.Tag) – The html to parse into the object. Must be the exact div of the comment.
- date¶
Date and time of the comment creation
- Type:
- children¶
Comment object replying directly to this one. If the comment is parsed on its own it will be null. It is only populated if originating from a CommentList
- Type:
- approved¶
Whether or not the comment is still waiting for admin approval and is visible to the guest members
- Type:
- location¶
Thumbnail of the place the comment is, only available when getting comments from get_member_comments. This thumbnail does not guarantee that you will find the comment if you parse it, since the url does not contain the page number.
- Type:
- is_stale()[source]¶
Comments are very volatile. If they are pushed onto another page by other comments it becomes impossible to use objects with the previous page number. In addition, calculating the new page number is not possible. Pages do not have a defined size but rather grow and shrink based on sizes of individual comments. Finally, comments also have token that can be used to modify them. These tokens have a hard life of 30 minutes from the time of the request. This function puts in place several mechanism to verify wether or not the object can still be trusted.
- Returns:
True, the comment is stale and you should fetch a new version, False you should be good to continue using it.
- Return type:
MissingComment¶
- class moddb.boxes.MissingComment(position)[source]¶
An object to represent a missing comment. This is used in the cases where a parent comment with children is deleted so that the children may still be accessible, missing comment will have the same attributes as a
Comment
but they will all be equal to None or False apart from children and the comment position, which will have the children of the comment that was deleted attached to it.
MemberProfile¶
- class moddb.boxes.MemberProfile(html)[source]¶
Member profiles are separate entities because they share nothing with the other profile boxes. Where as all other profile boxes share at least 4 attributes, a member shares none.
- Parameters:
html (bs4.BeautifulSoup) – The html to parse. Allows for finer control.
- last_online¶
None if the member is currently online, datetime the user was last seen online
- Type:
MemberStatistics¶
PlatformStatistics¶
PartialArticle¶
- class moddb.boxes.PartialArticle(html)[source]¶
A partial article is an article object missing attributes due to being parsed from the front page intead of from the article page itself. In general, it’ is simple enough for previewing the article but if you need a full article with comments, profile, ect… Then parse it with the method
- Parameters:
html (bs4.BeautifulSoup) – The html to parse. Allows for finer control.
- date¶
Date the article was published
- Type:
- type¶
Type of the article
- Type:
Option¶
Mirror¶
- class moddb.boxes.Mirror(**kwargs)[source]¶
Represents a download mirror from which the user can download a file
- city¶
Alpha 2 code, or full name, of the city the server is located in. Sometimes represents a country.
- Type:
- country¶
Alpha 2 code for the country the server is located in. Sometimes represents a continent.
- Type:
Tag¶
- class moddb.boxes.Tag(**kwargs)[source]¶
Represents a tag, useful to vote on stuff
- Parameters:
id (Optional[int]) – ID of the tag. None if obtained from parsing a page
name_id (str) – Name id of the tag
name (str) – Name of the tag
date (Optional[datetime.datetime]) – Creation date of the tag. None if obtained from parsing a page
official (Optional[bool]) – Whether the tag is official or user created. None if obtained from parsing a page
sitearea (int) – Site area
siteareaid (int) – Site area id
positive (int) – Number of positive votes
negative (int) – Number of negative votes
rank (Optiona[int]) – Rank of the tag in trending. None if obtained from parsing a page
url (str) – Url to the tag
CommentList¶
Represents a list of comments. This emulates a list and will behave like one, so you can use any of the regular list operators in addition to the methods defined below.
The page of results this objects represents
int
The total amount of result pages available
int
The total amount of results available
int
S.append(value) – append value to the end of the sequence
S.extend(iterable) – extend sequence by appending elements from the iterable
Returns a ‘flattened’ list of comments where children of comments are added right after the parent comment so:
├── Comment2
└── Comment5
would become:
[Comment1, Comment2, Comment3, Comment4, Comment5]
The flattened list of comments
List[Comment]
An expensive methods that iterates over every page of the result query and returns all the results. This may return more results than you expected if new page have fit the criteria while iterating.
The list of things you were searching for
Union[CommentList[Any], ResultList[Any]]
Raises ValueError if the value is not present.
Supporting start and stop arguments is optional, but recommended.
S.insert(index, value) – insert value before index
Returns the next page of results as either a CommentList if you are retriving comments or as a ResultList if it’s literally anything else.
The new search objects containing a new set of results.
Union[ResultList, CommentList]
ValueError – There is no next page
Raise IndexError if list is empty or index is out of range.
Returns the previous page of results as either a CommentList if you are retriving comments or as a ResultList if it’s literally anything else.
The new list-like object of results.
Union[ResultList, CommentList]
ValueError – There is no previous page
S.remove(value) – remove first occurrence of value. Raise ValueError if the value is not present.
S.reverse() – reverse IN PLACE
Returns the desired page of results as either a CommentList if you are retriving comments or as a ResultList if it’s literally anything else.
page (int) – A page number within the range 1 - max_page inclusive
The new list-like object of results.
Union[ResultList, CommentList]
ValueError – This page does not exist