Python3 only
- added UUID cleanup
This commit is contained in:
parent
6cac703c0e
commit
6c134927d5
39
README.md
39
README.md
@ -49,6 +49,45 @@ if is_valid_mojang_uuid('a2080281c2784181b961d99ed2f3347c'):
|
|||||||
print('Valid')
|
print('Valid')
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Documentation
|
||||||
|
### Module `mcuuid.api`
|
||||||
|
#### Class `GetPlayerData(indentifier, timestamp=None)`
|
||||||
|
##### Parameters
|
||||||
|
- `identifier`: string - a Minecraft username or Mojang UUID
|
||||||
|
- `timestamp`: int - a unix timestamp
|
||||||
|
|
||||||
|
##### Returns
|
||||||
|
`player` object
|
||||||
|
|
||||||
|
#### Object `player`
|
||||||
|
##### Value `player.uuid`
|
||||||
|
Mojang UUID
|
||||||
|
|
||||||
|
##### Value `player.username`
|
||||||
|
Minecraft username
|
||||||
|
|
||||||
|
### Module `mcuuid.tools`
|
||||||
|
#### Function `is_valid_minecraft_username(username)`
|
||||||
|
##### Parameters
|
||||||
|
- `username`: string - a Minecraft username
|
||||||
|
|
||||||
|
##### Returns
|
||||||
|
`True` or `False`
|
||||||
|
|
||||||
|
#### Function `is_valid_mojang_uuid(uuid)`
|
||||||
|
##### Parameters
|
||||||
|
- `uuid`: string - a Mojang UUID
|
||||||
|
|
||||||
|
##### Returns
|
||||||
|
`True` or `False`
|
||||||
|
|
||||||
|
#### Function `cleanup_uuid(uuid)`
|
||||||
|
##### Parameters
|
||||||
|
- `uuid`: string - a Mojang UUID
|
||||||
|
|
||||||
|
##### Returns
|
||||||
|
`uuid` as string, lowered. Without dashes
|
||||||
|
|
||||||
## Test file
|
## Test file
|
||||||
Usage
|
Usage
|
||||||
```
|
```
|
||||||
|
@ -7,8 +7,8 @@ Uses the official Mojang API to fetch player data.
|
|||||||
### Import necessary modules
|
### Import necessary modules
|
||||||
import http.client
|
import http.client
|
||||||
import json
|
import json
|
||||||
from tools import is_valid_minecraft_username
|
from mcuuid.tools import is_valid_minecraft_username
|
||||||
from tools import is_valid_mojang_uuid
|
from mcuuid.tools import is_valid_mojang_uuid
|
||||||
|
|
||||||
### Main class
|
### Main class
|
||||||
class GetPlayerData:
|
class GetPlayerData:
|
||||||
|
@ -29,3 +29,8 @@ def is_valid_mojang_uuid(uuid):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
def cleanup_uuid(uuid):
|
||||||
|
uuid = uuid.lower()
|
||||||
|
uuid = uuid.replace('-', '')
|
||||||
|
return uuid
|
||||||
|
3
setup.py
3
setup.py
@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
|
|||||||
|
|
||||||
setuptools.setup(
|
setuptools.setup(
|
||||||
name="mcuuid",
|
name="mcuuid",
|
||||||
version="0.2",
|
version="0.3",
|
||||||
author="Clemens Riese",
|
author="Clemens Riese",
|
||||||
author_email="hallo@clerie.de",
|
author_email="hallo@clerie.de",
|
||||||
description="Getting Minecraft Player Information from Mojang API.",
|
description="Getting Minecraft Player Information from Mojang API.",
|
||||||
@ -15,7 +15,6 @@ setuptools.setup(
|
|||||||
packages=setuptools.find_packages(),
|
packages=setuptools.find_packages(),
|
||||||
classifiers=[
|
classifiers=[
|
||||||
"Programming Language :: Python :: 3",
|
"Programming Language :: Python :: 3",
|
||||||
"Programming Language :: Python :: 2",
|
|
||||||
"License :: OSI Approved :: MIT License",
|
"License :: OSI Approved :: MIT License",
|
||||||
"Operating System :: OS Independent",
|
"Operating System :: OS Independent",
|
||||||
],
|
],
|
||||||
|
2
test.py
2
test.py
@ -20,7 +20,7 @@ if len(sys.argv) > 1:
|
|||||||
# Else, ask for a identifier by userinput
|
# Else, ask for a identifier by userinput
|
||||||
else:
|
else:
|
||||||
print("Please enter a username or UUID: ")
|
print("Please enter a username or UUID: ")
|
||||||
identifier = raw_input()
|
identifier = input()
|
||||||
|
|
||||||
### Is the identifier a valid value?
|
### Is the identifier a valid value?
|
||||||
if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(identifier):
|
if is_valid_minecraft_username(identifier) or is_valid_mojang_uuid(identifier):
|
||||||
|
Loading…
Reference in New Issue
Block a user