Giter Club home page Giter Club logo

hoyo-codes's Introduction

hoyo-codes

API to get gift codes from Hoyoverse games, made for auto code redemption feature in hoyo buddy.

Endpoints

How it Works

  • The run.py file is responsible for running the API
  • The update.py file is used to fetch codes from the sources listed in /api/codes/sources.py
  • The check.py file is used to check the status of old codes to see if they have expired

update.py

  1. We first use aiohttp to get the website's HTML. For pockettactics you would need a user agent, else the website blocks you, this is why the fake-useragent package is used
  2. Then we parse the HTML using beautifulsoup + lxml (for faster parsing), then extract the codes from the website by inspecting the HTML elements
  3. Next we verify the status of the each code with genshin.py, we would request to HoYoLAB to redeem a specific code, and save the code with different CodeStatus (OK or NOT_OK) based on the redemption result. If the code already exists in the database, we would skip the verification process

check.py

  1. We get all the codes in the database with CodeStatus.OK and verify their status with the same technique used in update.py
  2. Update the code with the new status

API

The API grabs the codes from the database with CodeStatus.OK and game with the game requested

Scheduled Task

The API runs on my machine, and I schedule 2 tasks:

  • update.py to run once every 2 hours
  • check.py to run once everyday

Notes

Unfortunately, I don't play Honkai Impact 3rd, so I can't verify the status of HI3 codes.

hoyo-codes's People

Contributors

renovate[bot] avatar seriaati avatar

Stargazers

 avatar  avatar  avatar

Watchers

 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.