A Python API for How Long to Beat
Project description
HowLongToBeat Python API
A simple Python API to read data from howlongtobeat.com.
It is inspired by ckatzorke - howlongtobeat JS API.
Usage
Installation
Installing the package downloading the last release
pip install howlongtobeatpy
Installing the package from the source code
Download the repo, enter the folder with 'setup.py' and run the command
pip install .
Usage in code
Start including it in your file
from howlongtobeatpy import HowLongToBeat
Now call search()
The API main functions are:
results = HowLongToBeat().search("Awesome Game")
or, if you prefer using async:
results = await HowLongToBeat().async_search("Awesome Game")
The return of that function is a list of possible games, or None in case you passed an invalid "game name" as parameter or if there was an error in the request.
If the list is not None you should choose the best entry checking the Similarity value with the original name, example:
results_list = await HowLongToBeat().async_search("Awesome Game")
if results_list is not None and len(results_list) > 0:
max_sim = -1
best_element = None
for element in results_list:
if element.similarity > max_sim:
max_sim = element.similarity
best_element = element
At the end of the for cycle "best_element" will contain the best game found in the research.
Reading an entry
An entry is made of few values, you can check them in the Entry class file
Found a bug?
Please report it as soon as you can creating an issue, the code may not be perfect.
Authors
- ScrappyCocco
License
This project is licensed under the MIT License - see the LICENSE.md file for details
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.