Socket
Socket
Sign inDemoInstall

github.com/jozsefsallai/gophersauce

Package Overview
Dependencies
1
Alerts
File Explorer

Install Socket

Detect and block malicious and high-risk dependencies

Install

    github.com/jozsefsallai/gophersauce

Package gophersauce is an API wrapper for the SauceNAO.com reverse image search engine. Initializing a client (without additional options): Initializing a client with options: Any of the options can be omitted. By default, MaxResults will be 6 and APIKey will be an empty string. You can also change these properties after instantiating the client: There are three ways in which you can consume the SauceNAO API: URL, file, and reader. Reverse searching an image using a URL: Reverse searching an image using a file path: Reverse searching an image using a reader: API responses have helpful methods, such as First() which will return the first result (which is likely the one that is the most similar to your image), if any: Some of the response fields are, by default, declared as interfaces because of the way the SauceNAO API works. You will have to either check for the type of the field yourself and parse it that way, or use a helper function, such as GetUserID(), GetAccountType() (on type SaucenaoResponse) or GetCreatorString() (on type SearchResult). Example: This will not work: This will work:


Version published

Readme

Source

gophersauce

gophersauce is an API wrapper for SauceNAO written in Go.

go get github.com/jozsefsallai/gophersauce

Basic Example

package main

import (
  "fmt"
  "log"
  "os"

  "github.com/jozsefsallai/gophersauce"
)

func main() {
  client, err := gophersauce.NewClient(nil)
  if err != nil {
    log.Fatal(err)
  }

  response, err := client.FromURL("https://i.imgur.com/v6EiHyj.png")
  if err != nil {
    log.Fatal(err)
  }

  if response.Count() == 0 {
    fmt.Println("There are no results :(")
    os.Exit(0)
  }

  first := response.First()
  if first.IsPixiv() {
    fmt.Println("This result is from Pixiv!")
    fmt.Println("Here's the ID of the image on Pixiv:", first.Data.PixivID)
  } else {
    fmt.Println("Probably not from Pixiv!")
    fmt.Println("Here are the external URLs:", first.Data.ExternalURLs)
  }
}

Currently Supported Providers:

  • Pixiv
  • IMDb
  • Bcy
  • AniDB
  • Pawoo
  • Seiga
  • Sankaku
  • Danbooru

Documentation and Reference

https://pkg.go.dev/github.com/jozsefsallai/gophersauce

Todo

  • Add more providers
  • Unit tests

License

MIT.

FAQs

Last updated on 22 Mar 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc