gomdb

package module
v0.0.0-...-8a1e0ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2017 License: Apache-2.0 Imports: 5 Imported by: 14

README

The Golang Omdb API

Build Status GoDoc

Author: Christopher T. Herrera (eefretsoul AT gmail DOT com)

This API uses the omdbapi.com API by Brian Fritz


OMDBAPI.com

This is an excellent open database for movie and film content.

I strongly encourage you to check it out and contribute to keep it growing.

http://www.omdbapi.com

Project Usage

The API usage is very simple.

package main

import (
	"fmt"
	"github.com/eefret/gomdb"
)

func main() {
        api := gomdb.Init(YOUR_API_KEY)
	query := &gomdb.QueryData{Title: "Macbeth", SearchType: gomdb.MovieSearch}
	res, err := api.Search(query)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(res.Search)

	query = &gomdb.QueryData{Title: "Macbeth", Year: "2015"}
	res2, err := api.MovieByTitle(query)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(res2)

	res3, err := api.MovieByImdbID("tt2884018")
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(res3)
}

See the project documentation to see the Response Objects and stuff

Documentation

Overview

Package gomdb is a golang implementation of the OMDB API.

Index

Constants

View Source
const (
	MovieSearch   = "movie"
	SeriesSearch  = "series"
	EpisodeSearch = "episode"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type MovieResult

type MovieResult struct {
	Title             string
	Year              string
	Rated             string
	Released          string
	Runtime           string
	Genre             string
	Director          string
	Writer            string
	Actors            string
	Plot              string
	Language          string
	Country           string
	Awards            string
	Poster            string
	Metascore         string
	ImdbRating        string
	ImdbVotes         string
	ImdbID            string
	Type              string
	TomatoMeter       string
	TomatoImage       string
	TomatoRating      string
	TomatoReviews     string
	TomatoFresh       string
	TomatoRotten      string
	TomatoConsensus   string
	TomatoUserMeter   string
	TomatoUserRating  string
	TomatoUserReviews string
	TomatoURL         string
	DVD               string
	BoxOffice         string
	Production        string
	Website           string
	Response          string
	Error             string
}

MovieResult is the result struct of an specific movie search

func (MovieResult) String

func (mr MovieResult) String() string

Stringer Interface for MovieResult

type OmdbApi

type OmdbApi struct {
	// contains filtered or unexported fields
}

func Init

func Init(apiKey string) *OmdbApi

func (*OmdbApi) MovieByImdbID

func (api *OmdbApi) MovieByImdbID(id string) (*MovieResult, error)

MovieByImdbID returns a MovieResult given a ImdbID ex:"tt2015381"

func (*OmdbApi) MovieByTitle

func (api *OmdbApi) MovieByTitle(query *QueryData) (*MovieResult, error)

MovieByTitle returns a MovieResult given Title

func (*OmdbApi) Search

func (api *OmdbApi) Search(query *QueryData) (*SearchResponse, error)

Search for movies given a Title and year, Year is optional you can pass nil

type QueryData

type QueryData struct {
	Title      string
	Year       string
	ImdbId     string
	SearchType string
}

QueryData is the type to create the search query

type SearchResponse

type SearchResponse struct {
	Search   []SearchResult
	Response string
	Error    string
	// contains filtered or unexported fields
}

SearchResponse is the struct of the response in a search

type SearchResult

type SearchResult struct {
	Title  string
	Year   string
	ImdbID string
	Type   string
}

SearchResult is the type for the search results

func (SearchResult) String

func (sr SearchResult) String() string

Stringer Interface for SearchResult

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL