Giter VIP home page Giter VIP logo

swift-saucenao's Introduction

Swift-SauceNao

SauceNAO API for Swift

Requirements

  • iOS 9.0+, macOS 10.12+
  • Swift 4.2

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate Swift-SauceNao into your Xcode project using Carthage, specify it in your Cartfile:

github "Vinrobot/Swift-SauceNao"

Run carthage update to build the framework and drag the built Swift_SauceNao.framework into your Xcode project or follow Carthage: Getting started.

How to use

  1. Create an instance of SauceNao
import Swift_SauceNao

let saucenao = SauceNao(apiKey: "API Key from https://saucenao.com/user.php?page=search-api")
or
let saucenao = SauceNao(apiKey: "API Key", skipLimiters: false) // To skip embedded limiters
  1. Use one of the search methods.
  • Search using an URL:
let url = URL(string: "https://saucenao.com/images/static/banner.gif")!
saucenao.search(url: url) { (result, error) in
	guard let result = result else {
		print(error ?? "Unknown error")
		return
	}

	print("Long: \(result.limits.longRemaining) / \(result.limits.longLimit)")
	print("Short: \(result.limits.shortRemaining) / \(result.limits.shortLimit)")

	if let results = result.results {
		for res in results {
			print(res.thumbnail)
		}
	}
}

let urlAsString = "https://saucenao.com/images/static/banner.gif"
saucenao.search(url: urlAsString) { (result, error) in
	...
}
  • Search using File URL:
let file = URL(fileURLWithPath: "/Users/Vinrobot/Downloads/banner.gif")
saucenao.search(file: file) { (result, error) in
	...
}
  • Search using Data:
let file = URL(fileURLWithPath: "/Users/Vinrobot/Downloads/banner.jpg")

let imageData = try Data(contentsOf: file) // Example by reading file content
let fileName = "image.jpg"
let mimeType = "image/jpeg"

saucenao.search(data: imageData, fileName: fileName, mimeType: mimeType) { (result, error) in
	...
}
  1. Look at SauceNaoResult.swift to see the content of the result variable.

swift-saucenao's People

Contributors

vinrobot avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

skjiisa

swift-saucenao's Issues

ReadMe

I'm not sure if im just insanely stupid or what. but I can't figure out how to use this in my own project. it would be insanely helpful if the readme told me this

[Enhancement] Updating Alamofire

Is it possible to update Alamofire within the package to the most recent or one of the recent versions so it is compatible with other Alamofire packages such as Alamofire Image?

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.