Levels¶
Main atoms of Geometry Dash are levels; gd.py allows searching, interacting with, modifying and uploading them.
Here is an example of commenting a level:
client = gd.Client()
await client.login('username', 'password')
level = await client.get_level(30029017)
await level.comment('gd.py test comment')
Level¶
-
class
gd.
Level
(*, client: gd.client.Client = None, **options)[source]¶ Class that represents a Geometry Dash Level. This class is derived from
AbstractEntity
.-
classmethod
official
(id: Optional[int] = None, name: Optional[str] = None, index: Optional[int] = None, client: Optional[gd.client.Client] = None, get_data: bool = True, server_style: bool = False) → gd.level.Level[source]¶ Get official level to work with.
Lookup is done in the following form:
id -> name -> index
.- Parameters
id (Optional[
int
]) – ID of the official level.name (Optional[
str
]) – Name of the official level.index (Optional[
int
]) – Index (position) of the official level.client (Optional[
Client
]) – Client to attach to the level.get_data (
bool
) – Whether to attach data to the level. Default isTrue
.server_style (
bool
) – Indicates if server-style of official song ID should be used. Set this toTrue
in case of uploading level to the server. Defaults toFalse
.
- Raises
ValueError – No queries were given.
LookupError – Level was not found.
- Returns
Official level that was found.
- Return type
-
creator
¶ Creator of the level.
- Type
-
difficulty
¶ Difficulty of the level.
- Type
Union[
LevelDifficulty
,DemonDifficulty
]
-
password
¶ The password to copy the level. See
Level.is_copyable()
.- Type
Optional[
int
]
-
uploaded_timestamp
¶ A human-readable string representing how much time ago level was uploaded.
- Type
-
last_updated_timestamp
¶ A human-readable string showing how much time ago the last update was.
- Type
-
length
¶ A type that represents length of the level.
- Type
-
type
¶ A type that shows whether a level is Daily/Weekly.
- Type
-
timely_index
¶ A number that represents current index of the timely. Increments on new dailies/weeklies. If not timely, equals
-1
.- Type
-
is_timely
(daily_or_weekly: Optional[str] = None) → bool[source]¶ bool
: Indicates whether a level is timely/daily/weekly. For instance, let’s suppose a level is daily. Then, the behavior of this method is:level.is_timely() -> True
andlevel.is_timely('daily') -> True
butlevel.is_timely('weekly') -> False
.
-
download
() → Union[bytes, str][source]¶ Union[
str
,bytes
]: Returns level data, represented as string.
-
await
report
() → None[source]¶ This function is a coroutine.
Reports a level.
- Raises
MissingAccess – Failed to report a level.
-
await
upload
(**kwargs) → None[source]¶ This function is a coroutine.
Upload
self
.- Parameters
**kwargs – Arguments that
Client.upload_level()
accepts. Defaults are properties of the level.
-
await
delete
() → None[source]¶ This function is a coroutine.
Deletes a level.
- Raises
MissingAccess – Failed to delete a level.
-
await
update_description
(content: Optional[str] = None) → None[source]¶ This function is a coroutine.
Updates level description.
- Parameters
content (
str
) – Content of the new description. IfNone
or omitted, nothing is run.- Raises
MissingAccess – Failed to update level’s description.
-
await
rate
(stars: int = 1) → None[source]¶ This function is a coroutine.
Sends level rating.
- Parameters
stars (
int
) – Amount of stars to rate with.- Raises
MissingAccess – Failed to rate a level.
-
await
rate_demon
(demon_difficulty: Union[int, str, gd.utils.enums.DemonDifficulty] = 1, as_mod: bool = False) → None[source]¶ This function is a coroutine.
Sends level demon rating.
- Parameters
demon_difficulty (Union[
int
,str
,DemonDifficulty
]) – Demon difficulty to rate a level with.as_mod (
bool
) – Whether to send a demon rating as moderator.
- Raises
MissingAccess – If attempted to rate a level as moderator without required permissions.
-
await
send
(stars: int = 1, featured: bool = True) → None[source]¶ This function is a coroutine.
Sends a level to Geometry Dash Developer and Administrator, RobTop.
- Parameters
- Raises
MissingAccess – Missing required moderator permissions.
-
await
is_alive
() → bool[source]¶ This function is a coroutine.
Checks if a level is still on Geometry Dash servers.
- Returns
True
if a level is still alive, andFalse
otherwise. AlsoFalse
if a client is not attached to the level.s- Return type
-
await
refresh
() → Optional[gd.level.Level][source]¶ This function is a coroutine.
Refreshes a level. Returns
None
on fail.Note
This function actually refreshes a level and its stats. No need to do funky stuff with its return.
- Returns
A newly fetched version.
None
if failed to fetch.- Return type
-
await
comment
(content: str, percentage: int = 0) → Optional[gd.comment.Comment][source]¶ This function is a coroutine.
Posts a comment on a level.
- Parameters
- Raises
MissingAccess – Failed to post a level comment.
- Returns
Sent comment.
- Return type
Optional[
Comment
]
-
await
like
() → None[source]¶ This function is a coroutine.
Likes a level.
- Raises
MissingAccess – Failed to like a level.
-
await
dislike
() → None[source]¶ This function is a coroutine.
Dislikes a level.
- Raises
MissingAccess – Failed to dislike a level.
-
await
get_leaderboard
(strategy: Union[int, str, gd.utils.enums.LevelLeaderboardStrategy] = 0) → List[gd.abstractuser.LevelRecord][source]¶ This function is a coroutine.
Retrieves the leaderboard of a level.
- Parameters
strategy (Union[
int
,str
,LevelLeaderboardStrategy
]) – A strategy to apply.- Returns
A list of user-like objects.
- Return type
List[
LevelRecord
]
-
await
get_comments
(strategy: Union[int, str, gd.utils.enums.CommentStrategy] = 0, amount: int = 20, exclude: Tuple[Type[BaseException]] = (<class 'gd.errors.NothingFound'>, )) → List[gd.comment.Comment][source]¶ This function is a coroutine.
Retrieves level comments.
- Parameters
strategy (Union[
int
,str
,CommentStrategy
]) – A strategy to apply when searching.amount (
int
) – Amount of comments to retrieve. Default is20
. Foramount < 0
,2 ** 31
is added, allowing to fetch a theoretical limit of comments.exclude (Tuple[Type[
BaseException
]]) – Exceptions to ignore. By default includes onlyNothingFound
.
- Returns
List of comments retrieved.
- Return type
List[
Comment
]- Raises
MissingAccess – Failed to fetch comments.
NothingFound – No comments were found.
-
classmethod
gd.py also provides a convenient way of searching for different levels:
client = gd.Client()
for level in await client.search_levels('Bloodlust'):
print(level.name)
# also by filters!
for level in await client.search_levels(filters=gd.Filters.setup_with_song(1)):
print(level.rating)
Filters¶
-
class
gd.
Filters
(strategy: Union[int, str, gd.utils.enums.SearchStrategy] = 0, difficulty: Optional[Sequence[Union[int, str, gd.utils.enums.LevelDifficulty]]] = None, demon_difficulty: Optional[Union[int, str, gd.utils.enums.DemonDifficulty]] = None, length: Optional[Union[int, str, gd.utils.enums.LevelLength]] = None, uncompleted: bool = False, only_completed: bool = False, completed_levels: Optional[Sequence[Union[int, gd.level.Level]]] = None, require_coins: bool = False, featured: bool = False, epic: bool = False, rated: Optional[bool] = None, require_two_player: bool = False, song_id: Optional[int] = None, use_custom_song: bool = False, require_original: bool = False, followed: Optional[Sequence[Union[int, gd.abstractuser.AbstractUser]]] = None)[source]¶ Class that adds ability to create custom filters to apply when searching for levels.
-
strategy
¶ A strategy to apply.
- Type
Optional[Union[
int
,str
,SearchStrategy
]]
-
difficulty
¶ Level difficulties to apply. Either sequence of many or just one difficulty.
- Type
Optional[Sequence[Union[
int
,str
,LevelDifficulty
]]]
-
demon_difficulty
¶ One Demon difficulty to apply as a filter.
- Type
Optional[Union[
int
,str
,DemonDifficulty
]]
-
length
¶ Same as
difficulty
, but for lengths.- Type
Sequence[Union[
int
,str
,LevelLength
]]
-
uncompleted
¶ Whether to search for uncompleted levels only. If true,
completed_levels
is required.- Type
Optional[
bool
]
-
rated
¶ This defaults to
None
. If true, will search for only rated levels, if false, will search for only not rated levels. IfNone
, makes no changes.- Type
Optional[
bool
]
-
use_custom_song
¶ Whether a custom song should be used. Requires
song_id
to be defined.- Type
Optional[
int
]
-
followed
¶ Followed users, basically this will work as
BY_USER
strategy
, but for many users.- Type
Optional[Sequence[Union[
int
,AbstractUser
,User
]]]
-
Geometry Dash has different level packs to play; as of 2.1.1, there are two of those: Map Packs and Gauntlets.
Here is an example of fetching levels of a Fire gauntlet:
client = gd.Client()
gauntlets = await client.get_gauntlets()
fire_gauntlet = gd.utils.get(gauntlets, name='Fire Gauntlet')
for level in await fire_gauntlet.get_levels():
print(level.id, level.rating, level.name)
Level Packs¶
-
class
gd.
MapPack
(**options)[source]¶ Class that represents Map Pack in Geometry Dash. This class is derived from
Gauntlet
.-
difficulty
¶ Average difficulty of a map pack.
- Type
-
-
class
gd.
Gauntlet
(**options)[source]¶ Class that represents The Lost Gauntlet in Geometry Dash. This class is derived from
AbstractEntity
.-
levels
¶ Tuple containing levels of the Gauntlet.
Can be retrieved with
Gauntlet.get_levels()
.- Type
Tuple[
Level
]
-