Skip to main content

Modified version of mcuuid - fetches Minecraft player information from the Mojang API

Project description

MCFETCH

Fetches Minecraft player information from the Mojang API

Installation

Run the following:

pip install mcfetch

How to use

Non asynchronous

Fetch a player using their username:

>>> from mcfetch import Player
>>> player = Player(player="gronkh")
>>> player.name
'Gronkh'
>>> player.uuid
'a2080281c2784181b961d99ed2f3347c'

Fetch a player using their uuid:

>>> from mcfetch import Player
>>> player = Player(player="a2080281c2784181b961d99ed2f3347c")
>>> player.name
'Gronkh'

If a player doesn't exist:

>>> from mcfetch import Player
>>> player = Player(player="ThisUsernameIsNotValid")
>>> player.name
None
>>> player.uuid
None

It is also possible to use a custom requests object:

>>> from mcfetch import Player
>>> from requests_cache import CachedSession
>>> my_cache = CachedSession(cache_name='./my_cache', expire_after=60)
>>> player = Player(player="gronkh", requests_obj=my_cache)

You can fetch a player's skin URL and skin texture

>>> from mcfetch import Player
>>> player = Player(player="Notch")
>>> player.skin_url
'http://textures.minecraft.net/texture/292009a4925b58f02c77dadc3ecef07ea4c7472f64e0fdc32ce5522489362680'
>>> player.skin_texture
b'\x89PNG\r\n\x1a\n\x00\x00\x00\...'

Asynchronous

Fetching a player (same functionality as the above examples)

>>> import asyncio
>>> from mcfetch import AsyncPlayer
>>> async def main():
...     player = AsyncPlayer(player="Gronkh")
...     print(await player.name)
...     print(await player.uuid)
>>> asyncio.run(main())
'Gronkh'
'a2080281c2784181b961d99ed2f3347c'

Tools

Check syntax of a username:

>>> from mcfetch import is_valid_username
>>> is_valid_username('gronkh')
True
>>> is_valid_username('gronkh-is cool')
False

Check syntax of a UUID (undashed):

>>> from mcfetch import is_valid_uuid
>>> is_valid_uuid('a2080281c2784181b961d99ed2f3347c')
True
>>> is_valid_uuid('bcc28a5f6')
False

Remove dashes from a UUID:

>>> from mcfetch import undash_uuid
>>> undash_uuid('a2080281-c278-4181-b961-d99ed2f3347c')
'a2080281c2784181b961d99ed2f3347c'

Added dashes to a UUID:

>>> from mcfetch import dash_uuid
>>> dash_uuid('a2080281c2784181b961d99ed2f3347c')
'a2080281-c278-4181-b961-d99ed2f3347c'

License

This software is licensed under the MIT license. Feel free to use it however you like. For more infomation see LICENSE.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcfetch-2.1.4.tar.gz (7.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcfetch-2.1.4-py3-none-any.whl (9.9 kB view details)

Uploaded Python 3

File details

Details for the file mcfetch-2.1.4.tar.gz.

File metadata

  • Download URL: mcfetch-2.1.4.tar.gz
  • Upload date:
  • Size: 7.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for mcfetch-2.1.4.tar.gz
Algorithm Hash digest
SHA256 0acf36a175b7fdd0bf0eca473d84c32f8d0a1cf3ff6acb8061ba3c59e1839608
MD5 88463e2e2ece50748df1c64c593560de
BLAKE2b-256 d52358c65d041f09a3f9b405c0b3ba088a5b7c4031e367fb000a91e53332014f

See more details on using hashes here.

File details

Details for the file mcfetch-2.1.4-py3-none-any.whl.

File metadata

  • Download URL: mcfetch-2.1.4-py3-none-any.whl
  • Upload date:
  • Size: 9.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.25

File hashes

Hashes for mcfetch-2.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b0a074adcd98df34715146d6f248829ccf709e482d2030ed489460e0742f7d45
MD5 dd256d72b961426051375f86a4b62adf
BLAKE2b-256 227792eafcdc49877c6b51381bdcb57ee5c5857dab15534787762eb9671aacf9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page