Skip to content

Commit

Permalink
first commit
Browse files Browse the repository at this point in the history
  • Loading branch information
EllieJaybee committed Nov 16, 2022
0 parents commit 875bc68
Show file tree
Hide file tree
Showing 4 changed files with 238 additions and 0 deletions.
130 changes: 130 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class

# C extensions
*.so

# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST

# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec

# Installer logs
pip-log.txt
pip-delete-this-directory.txt

# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
*test*

# Translations
*.mo
*.pot

# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal

# Flask stuff:
instance/
.webassets-cache

# Scrapy stuff:
.scrapy

# Sphinx documentation
docs/_build/

# PyBuilder
target/

# Jupyter Notebook
.ipynb_checkpoints

# IPython
profile_default/
ipython_config.py

# pyenv
.python-version

# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock

# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/

# Celery stuff
celerybeat-schedule
celerybeat.pid

# SageMath parsed files
*.sage.py

# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/

# Spyder project settings
.spyderproject
.spyproject

# Rope project settings
.ropeproject

# mkdocs documentation
/site

# mypy
.mypy_cache/
.dmypy.json
dmypy.json

# Pyre type checker
.pyre/
76 changes: 76 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
======================
YGOPRODECK API Wrapper
======================

------------
Installation
------------

You can install it with pip3:

.. code-block:: bash
pip3 install --upgrade git+https://github.com/EllieJaybee/yugioh.git
-----
Usage
-----

.. code-block:: python
import yugioh
card = yugioh.get_card(card_name = "The Wicked Dreadroot") #Accepts both name and ID
print(card.name) #Returns "The Wicked Dreadroot"
print(card.archetype) #Returns "Wicked God"
print(card.attack) #Returns "4000"
------------------
Monster Attributes
------------------

+--------------------+---------------------------------+
| Attribute | Description |
+--------------------+---------------------------------+
| name | The card's name |
+--------------------+---------------------------------+
| archetype | The card's archetype |
+--------------------+---------------------------------+
| atk | The card's attack points |
+--------------------+---------------------------------+
| attribute | The card's attribute |
+--------------------+---------------------------------+
| def | The card's defense points |
+--------------------+---------------------------------+
| desc | The card's description |
+--------------------+---------------------------------+
| id | The card's ID |
+--------------------+---------------------------------+
| level | The card's level |
+--------------------+---------------------------------+
| race | The card's "race" (type) |
+--------------------+---------------------------------+
| type | Monster/Normal card |
+--------------------+---------------------------------+

---------------------------
Spell/Trap/Skill Attributes
---------------------------

+--------------------+---------------------------------+
| Attribute | Description |
+--------------------+---------------------------------+
| desc | The card's description |
+--------------------+---------------------------------+
| id | The card's ID |
+--------------------+---------------------------------+
| name | The card's name |
+--------------------+---------------------------------+
| type | The card's type |
+--------------------+---------------------------------+
| race | The card's "race" |
+--------------------+---------------------------------+

You can get further documentation from `here <https://ygoprodeck.com/api-guide/>`_.

Please report all issues `here <https://github.com/EllieJaybee/yugioh/issues>`_.
12 changes: 12 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from setuptools import setup

setup(name='ygo',
version='1.0.0',
description='Very Thin Yu-Gi-Oh API Wrapper',
long_description=open('README.rst').read(),
url='https://github.com/EllieJaybee/yugioh',
author='elliejaybee',
author_email='[email protected]',
install_requires=['requests'],
packages=['ygo'],
keywords='Yu-Gi-Oh API')
20 changes: 20 additions & 0 deletions yugioh/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import requests

class Card:
def __init__(self, q):
for key, value in q.items():
if key not in ("card_sets", "card_images", "card_prices"):
setattr(self, key, value)

def __get(parameters):
return requests.get('https://db.ygoprodeck.com/api/v7/cardinfo.php',
params=parameters).json()['data'][0]

def get_card(query):
if not query:
raise ValueError
try:
card = __get({"id": query})
except KeyError:
card = __get({"fname": query})
return Card(card)

0 comments on commit 875bc68

Please sign in to comment.