Coder Social home page Coder Social logo

gd.py's Introduction

Image

gd.py

License Version Downloads Discord

Documentation Check Test Coverage

An API wrapper for Geometry Dash written in Python.

Installing

Python 3.8 or above is required.

pip

Installing the library with pip is quite simple:

$ pip install gd.py

Alternatively, the library can be installed from source:

$ git clone https://github.com/nekitdev/gd.py.git
$ cd gd.py
$ python -m pip install .

poetry

You can add gd.py as a dependency with the following command:

$ poetry add gd.py

Or by directly specifying it in the configuration like so:

[tool.poetry.dependencies]
"gd.py" = "^2.0.0-dev.0"

Alternatively, you can add it directly from the source:

[tool.poetry.dependencies."gd.py"]
git = "https://github.com/nekitdev/gd.py.git"

Examples

Interactive

Song

Fetching

# file.py

from entrypoint import entrypoint

import gd

SONG_ID = 1081309

SONG_INFO = "`{song.name}` by `{song.artist.name}` (ID: `{song.id}`, size: `{song.size} MB`)"
song_info = SONG_INFO.format


async def async_main() -> None:
    song = await client.get_song(SONG_ID)

    print(song_info(song=song))


@entrypoint(__name__)
def main() -> None:
    client.run(async_main())
$ python file.py
`PANDA EYES - BROKEN` by `PandaEyesOfficial` (ID: `1081309`, size: `9.71 MB`)

Login

gd.py is now using hashed passwords for safety reasons.

gd.hash_password is provided for convenience.

Moreover, client.login returns an awaitable asynchronous context manager, which can be utilized to factor out the blocks that require logging in.

In the snippet below we define the credentials and hash the password.

import gd

client = gd.Client()

name = "name"
password = "********"

hashed_password = gd.hash_password(password)

Regular login:

await client.login(name, hashed_password)

...  # the client is now logged in

Advanced version:

async with client.login(name, hashed_password):
    ...  # the client is logged in here

...  # but not outside of the `async with` block!

Listening

from entrypoint import entrypoint

import gd

client = gd.Client()

DAILY_INFO = "new daily! `{daily.name}` by `{daily.creator.name}` (ID: `{daily.id}`)"
daily_info = DAILY_INFO.format


@client.event
async def on_daily(daily: gd.Level) -> None:
    print(daily_info(daily=daily))


client.listen_for_daily()


@entrypoint(__name__)
def main() -> None:
    client.create_controller().run()

Documentation

You can find the documentation here.

Support

If you need support with the library, you can send an email or refer to the official Discord server.

Changelog

You can find the changelog here.

Security Policy

You can find the Security Policy of gd.py here.

Contributing

If you are interested in contributing to gd.py, make sure to take a look at the Contributing Guide, as well as the Code of Conduct.

License

gd.py is licensed under the MIT License terms. See License for details.

gd.py's People

Contributors

nekitdev avatar bswck avatar dependabot[bot] avatar spookybear0 avatar camila314 avatar callocgd avatar kifilterfibercontext avatar melowody avatar scottwedge avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.