Songs

All levels in Geometry Dash are based on different songs; either official ones, or custom songs from Newgrounds.

gd.py provides simple API for fetching and working with both of them:

client = gd.Client()

song = gd.Song.official(0, client=client)
# <Song id=0 name='Stereo Madness' author='ForeverBound'>

print(song.is_custom())  # False

song = await client.get_song(1)  # or get_ng_song for Newgrounds fetching
# <Song id=1 name='Chilled 1' author='Recoil'>

data = await song.download()  # returns song data, as bytes

with open('test.mp3', 'wb') as file:
    file.write(data)

Artist Info

class gd.ArtistInfo(*, client: gd.client.Client = None, **options)[source]

Class that represents info about the creator of a particular song.

artist

Author of the song.

Type

str

song

A name of the song.

Type

str

exists

Whether the song exists.

Type

bool

is_scouted()bool[source]

bool: Whether the artist is scouted.

is_whitelisted()bool[source]

bool: Whether the artist is whitelisted.

api_allowed()bool[source]

bool: Whether the external API is allowed.

Author

class gd.Author(*, client: gd.client.Client = None, **options)[source]

Class that represents an author on Newgrounds. This class is derived from AbstractEntity.

id

ID of the Author.

Type

int

URL to author’s page.

Type

yarl.URL

name

Name of the author.

Type

str

await get_page_songs(page: int = 0) → List[gd.song.Song][source]

This function is a coroutine.

Get songs on the page.

Parameters

page (int) – Page of songs to look at.

Returns

Songs found. Can be empty.

Return type

List[Song]

await get_songs(pages: Iterable[int] = range(0, 10)) → List[gd.song.Song][source]

This function is a coroutine.

Get songs on the pages.

Parameters

pages (Iterable[int]) – Pages of songs to look at.

Returns

Songs found. Can be empty.

Return type

List[Song]

Song

class gd.Song(**options)[source]

Class that represents Geometry Dash/Newgrounds songs. This class is derived from AbstractEntity.

name

A name of the song.

Type

str

size

A float representing size of the song, in megabytes.

Type

float

author

An author of the song.

Type

str

A link to the song on Newgrounds, e.g. .../audio/listen/<id>.

Type

str

A link to download the song, used in Song.download().

Type

str

is_custom()bool[source]

bool: Indicates whether the song is custom or not.

get_author() → gd.song.Author[source]

Author: Author of the song.

await update(from_ng: bool = False)None[source]

This function is a coroutine.

Update the song.

Parameters

from_ng (bool) – Whether to fetch song from Newgrounds.

await get_artist_info() → gd.song.ArtistInfo[source]

This function is a coroutine.

Fetch artist info of self.

Acts like the following:

await client.get_artist_info(song.id)
Raises

MissingAccess – Failed to find artist info.

Returns

Fetched info about an artist.

Return type

ArtistInfo

await download(file: Optional[Union[str, pathlib.Path, IO]] = None, with_bar: bool = False) → Optional[bytes][source]

This function is a coroutine.

Download a song from Newgrounds.

Parameters
  • file (Optional[Union[str, pathlib.Path, IO]]) – File-like or Path-like object to write song to, instead of returning bytes.

  • with_bar (bool) – Whether to show a progress bar while downloading. Requires tqdm to be installed.

Returns

A song as bytes, if file was not specified.

Return type

Optional[bytes]