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¶
Author¶
-
class
gd.
Author
(*, client: gd.client.Client = None, **options)[source]¶ Class that represents an author on Newgrounds. This class is derived from
AbstractEntity
.-
link
¶ URL to author’s page.
- Type
yarl.URL
-
Song¶
-
class
gd.
Song
(**options)[source]¶ Class that represents Geometry Dash/Newgrounds songs. This class is derived from
AbstractEntity
.An author of the song.
- Type
-
dl_link
¶ A link to download the song, used in
Song.download()
.- Type
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
-
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. Requirestqdm
to be installed.
- Returns
A song as bytes, if
file
was not specified.- Return type
Optional[
bytes
]