GithubHelp home page GithubHelp logo

staraway225 / ichigo Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 10 KB

Simple and lightweight SauceNao API wrapper written in Crystal

License: ISC License

Crystal 100.00%
crystal crystal-lang crystal-language saucenao saucenao-api api-wrapper

ichigo's Introduction

Ichigo

Simple and lightweight SauceNAO API wrapper written in Crystal.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      ichigo:
        github: Staraway225/ichigo
        version: 0.1.1
  2. Run shards install

Usage

require "ichigo"

Examples

  1. Search by an image url:

    client = Ichigo::Client.new "your_saucenao_api_key_here"
    response = client.search "https://example.com/image.png"
    
    pp response
  2. Search by a local image:

    • by an image path as String:

      image = "/path/to/image.png"
      
      client = Ichigo::Client.new "your_saucenao_api_key_here"
      response = client.search(file: image)
      
      pp response
    • by an image path as Path object:

      image = Path["/path/to/image.png"]
      
      client = Ichigo::Client.new "your_saucenao_api_key_here"
      response = client.search(file: image)
      
      pp response
    • by an image as File object:

      image = File.new("/path/to/image.png")
      
      client = Ichigo::Client.new "your_saucenao_api_key_here"
      response = client.search(file: image)
      
      pp response
    • by an image as IO object:

      image = IO::Memory.new File.read("/path/to/image.png")
      
      client = Ichigo::Client.new "your_saucenao_api_key_here"
      response = client.search(file: image)
      
      pp response

You can also use Ichigo::RawClient to perform a request with raw values:

raw_client = Ichigo::RawClient.new "your_saucenao_api_key_here"
response = raw_client.search(
  url: "https://example.com/image.png",
  mask: 8191_i64,
  site: 5,
  result_count: 8
)

pp response

Contributing

  1. Make your changes.
  2. Add additional specs if you introduced new logic, make sure they pass (crystal spec).
  3. Run the code formatter (crystal tool format).
  4. Check for code issues by using linter (bin/ameba).
  5. Create a new pull request.

ichigo's People

Contributors

staraway225 avatar

Watchers

 avatar

ichigo's Issues

Tests are not reflecting on actual site behavior

Current tests aren't actually testing if site accepts files with different types and different types of masks. There are currently webmock stubs that are returning basic successful output. One approach is to use vcr to replicate real responses and exclude possibility of rate limiting.

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.