Code Monkey home page Code Monkey logo

fanarttvkit's Introduction

FanartTVKit

License Mit Xcode 9.0 iOS 11 macOS 10.13 Swift 4.0

Fanart.TV API written in Swift. This new version has been fully rewritten in Swift 4.0 and redesigned to acomplish the new API design guideline conventions also.

The Fanart.TV is the best place to find images related to movies, shows or music. First of all you have to obtain an API Key. Read API documentation it's a really good idea.

Usage

The API's entry is the FanartClientclass that contains methods to ask for Movies, TV Shows and Music related images. FanartTVKit provides covers the whole Fanart.TV operations

  • Movies
    • Movie
    • Latests Movies
  • TV
    • Show
    • Latests Shows
  • Music
    • Artist
    • Album
    • Label
    • Latests

Movies changes

FanartClient has two new methods to request movies' art, depending on movie identifier source, TMDB or IMDB

FanartClient.shared.movie(tmdb: Int, completionHandler: @escaping FanartCompletionHandler<FanartResult<MovieArt>>) -> Void

or

FanartClient.shared.movie(imdb: String, completionHandler: @escaping FanartCompletionHandler<FanartResult<MovieArt>>) -> Void 

Code Examples

Inside Test folder you will find a XCTest file which contains examples for all API methods.

TV Shows

In lines below you will see an example of a request for the Suits TV Show

// Manhattan Love Story
let showID: Int = 281624

FanartClient.shared.show(identifier: showID) { (result: FanartResult<ShowArt>) -> (Void) in
    switch result
    {
        case let .error(reason):
            print("err @ \(#function) -> \(reason)")
        
        case let .success(show):
            print("# \(show.showName)")
    }
}

Movies

Now we are going to request fanart for one of my favorites movies... The Goonies

FanartClient.shared.movie(imdb: "tt0089218") { (result: FanartResult<MovieArt>) -> (Void) in
    switch result
    {
        case let .error(reason):
            print("err @ \(#function) -> \(reason)")
            
        case let .success(movie):
            print("\(movie.name!) # Art available")
            
            if let posters = movie.posters, !posters.isEmpty
            {
                print("> \(posters.count) posters")
            }
            
            if let clearart = movie.clearartsHD, !clearart.isEmpty
            {
                print("> \(clearart.count) HD Clearart")
            }
            
            if let banners = movie.banners, !banners.isEmpty
            {
                print("> \(banners.count) banners")
            }
    }
}

Music

And finally an example requesting images related to Depeche Mode

// Depeche Mode
let artistID: String = "8538e728-ca0b-4321-b7e5-cff6565dd4c0"
        
FanartClient.shared.musicArtist(identifier: artistID) { (result: FanartResult<MusicArtistArt>) -> (Void) in
    switch result
    {
        case let .error(reason):
            print("err @ \(#function) -> \(reason)")
        
        case let .success(artist):
            print("#\(artist.name!)")
            
            if let albums = artist.albums
            {
                albums.forEach({ print("\($0.albumID)") })
            }
    }
}

Contact

If you have any question or suggestion feel free to contact me at @fitomad on Twitter.

About

This framework has been written with Swift 4 in mind using Xcode 9. Postman has been a very best friend during FanartTVKit development process

fanarttvkit's People

Contributors

fitomad avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

matteobruni

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.