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.

CommentList

class moddb.boxes.CommentList(**kwargs)[source]

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.

current_page

The page of results this objects represents

Type:

int

total_pages

The total amount of result pages available

Type:

int

total_results

The total amount of results available

Type:

int

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

flatten()[source]

Returns a ‘flattened’ list of comments where children of comments are added right after the parent comment so:

[ Comment1 ]

├── Comment2

├── Comment3
└── Comment4

└── Comment5

would become:

[Comment1, Comment2, Comment3, Comment4, Comment5]

Returns:

The flattened list of comments

Return type:

List[Comment]

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

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

current_page

The page of results this objects represents

Type:

int

total_pages

The total amount of result pages available

Type:

int

total_results

The total amount of results available

Type:

int

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.

Parameters:

new_sort (Tuple[str, str]) – The new sorting tuple to check by

Returns:

The new set of results with the updated sort order

Return type:

ResultList

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

current_page

The page of results this objects represents

Type:

int

total_pages

The total amount of result pages available

Type:

int

total_results

The total amount of results available

Type:

int

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

class moddb.boxes.Statistics(html)[source]

The stats box, on pages that have one. This represents total stats and daily stats in one neat package.

files

The number of files this page has uploaded

Type:

int

articles

The number of articles this page has uploaded

Type:

int

reviews

The number of reviews this page has been given

Type:

int

watchers

The number of people following this page

Type:

int

mods

The number of mods this page is related too (only applies to games, members and teams)

Type:

int

addons

The number of addons this page has uploaded

Type:

int

members

The number of members a group has (only applies to groups and teams)

Type:

int

visits

The total number of times this page has been viewed

Type:

int

today

The number of times this page has been viewed today

Type:

int

rank

The current rank of the page against all other pages of the same type

Type:

int

total

The maximum rank number

Type:

int

updated

The last time this page was updated

Type:

datetime.datetime

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]

contact

The url to contact the page owner

Type:

str

follow

The url to click to follow the mod

Type:

str

share

A dictionnary of share links with the place they will be shared as the key and the url for sharing as the value.

Type:

dict

private

Exclusive to Group and Team, True if the group is private, else False

Type:

bool

membership

Exclusive to Group and Team, represents the join procedure (invitation only, private, public)

Type:

Membership

icon

Exclusive to Game, Mod and Addon pages. URL of the icon image

Type:

str

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:

dict

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:

datetime.datetime

homepage

Present on all pages but Group pages. URL to the page’s homepage. Can be None

Type:

str

engine

Exclusive to Game and Addon pages. Engine like thumbnails representing the engine the addon/game was built for.

Type:

Thumbnail

game

Exclusive to Mod pages. Game like thumbnail representing the game the mod was built for.

Type:

Thumbnail

licence

Exclusive to Engine and Addon pages. Object representing the licence the engine operates under.

Type:

Licence

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:

Status

download_count

Total count of all downloads on the page, this adds up downloads of all files and addons. Exclusive to mods and games.

Type:

int

Style

class moddb.boxes.Style(html)[source]

Represents semantic information on the page’s theme.

Parameters:

html (bs4.BeautifulSoup) – The html to parse. Allows for finer control.

theme

fantasy, sci-fi, ect…

Type:

Theme

genre

fps, rpg, moba, ect…

Type:

Genre

players

Singplayer, multiplayer, ect…

Type:

PlayerStyle

scope

Triple A games or indie

Type:

Scope

boxart

URL of the boxart for the page.

Type:

str

Thumbnail

class moddb.boxes.Thumbnail(**attrs)[source]

Thumbnail objects are minature version of ModDB models. They can be parsed to return the full version of the model.

url

The url to the full model, mandatory attribute.

Type:

str

name

The name of the model

Type:

str

image

The optional thumbnail image of the model

Type:

str

summary

Optional bit of fluff

Type:

str

date

A date related to this timestamp if it exists. Can be None

Type:

datetime.datetime

type

The type of the resource, mandatory attribute

Type:

ThumbnailType

parse()[source]

Uses the Thumbnail’s mandatory attributes to get the full html of the model and parse them with the appropriate object.

Returns:

The model that was parsed, can be any model from the list of the ThumbnailType enum.

Return type:

Any

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.

id

The ID of the comment

Type:

int

author

A member like thumbnail of the member who posted the comment

Type:

Thumbnail

date

Date and time of the comment creation

Type:

datetime.datetime

position

Ranging from 0-2 represents the nested level of the comment.

Type:

int

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:

int

content

Text of the comment can be none if the comment only contains embeds

Type:

str

embeds

List of urls that have been embeded

Type:

list

karma

The current karma count

Type:

int

upvote

Link to upvote the comment

Type:

str

downvote

Link to downvote the comment

Type:

str

approved

Whether or not the comment is still waiting for admin approval and is visible to the guest members

Type:

bool

developer

Whether or not the comment was posted one of the page creators

Type:

bool

staff

Wether or not the comment was posted by one of moddb’s staff members

Type:

bool

subscriber

Whether or not the comment was posted by a moddb subscriber

Type:

bool

guest

Whether or not the comment was posted by a guest user

Type:

bool

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:

Thumbnail

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:

bool

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.

name

Name of the member

Type:

str

level

Current level

Type:

int

progress

Percentage progress to next level

Type:

float

title

Member title

Type:

str

avatar

Url of the member avatar

Type:

str

online

Whether or not the member is currently online

Type:

bool

last_online

None if the member is currently online, datetime the user was last seen online

Type:

datetime.datetime

gender

Gender of the member, can be None

Type:

str

homepage

URL of the member’s homepage

Type:

str

country

The member’s chosen country

Type:

str

follow

Link to follow a member

Type:

str

MemberStatistics

class moddb.boxes.MemberStatistics(html)[source]

Similarly, a member statistics shared no common ground with other stats and therefore there was a need for a separate object.

Parameters:

html (bs4.BeautifulSoup) – The html to parse. Allows for finer control.

watchers

How many members are following this member

Type:

int

acivity_points

Activity points

Type:

int

comments

How many comments the member has made

Type:

int

tags

How many tags the member has created

Type:

int

visits

How many people have viewed this page

Type:

int

site_visits

How many time this user has visited the site

Type:

int

today

How many people have viewed this page today

Type:

int

time

How many seconds the member has spent online

Type:

int

rank

The member’s current rank (compared to other members)

Type:

int

total

the maximum rank

Type:

int

PlatformStatistics

class moddb.boxes.PlatformStatistics(html)[source]

Stats for platform pages.

Parameters:

html (bs4.BeautifulSoup) – The html to parse. Allows for finer control.

hardware

Number of harware created for this platform

Type:

int

software

Number of software created for this platform

Type:

int

engines

Number of engines created for this platform

Type:

int

games

Number of games created for this platform

Type:

int

mods

Number of mods created for this platform

Type:

int

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.

name

Name of the articles

Type:

str

url

Link to the article

Type:

str

date

Date the article was published

Type:

datetime.datetime

type

Type of the article

Type:

ArticleCategory

content

html of the article content

Type:

str

plaintext

plaintext of the article content (without html)

Type:

str

get_article()[source]

Returns the full article object of this article.

Returns:

The complete article object

Return type:

Article

Option

class moddb.boxes.Option(**kwargs)[source]

Represents one of the choice from the poll they are attached to, should not be created manually, prefer relying on the Poll.

id

The id of the option, can be None and will be None in most cases.

Type:

int

text

The option’s text

Type:

str

votes

The number of votes that have been cast on this option

Type:

int

percent

The percent of all votes that have been cast on this option

Type:

int

Mirror

class moddb.boxes.Mirror(**kwargs)[source]

Represents a download mirror from which the user can download a file

name

The name of the mirror

Type:

str

index

The index of the mirror, as multiple mirrors have the same name. Index starts at 1

Type:

int

city

Alpha 2 code, or full name, of the city the server is located in. Sometimes represents a country.

Type:

str

country

Alpha 2 code for the country the server is located in. Sometimes represents a continent.

Type:

str

served

How many downloads of this file this mirror has served

Type:

int

capacity

The current capacity of this server as a percentage. E.g. 35.5 -> 35.5%. Lower is better for speed.

Type:

float

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