gomdb

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

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)

	query = &gomdb.QueryData{Title: "Rick and Morty", Season: "1", Episode: "8", SearchType: gomdb.EpisodeSearch}
	res3, err := api.MovieByTitle(query)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(res3)
}

	query = &gomdb.QueryData{ImdbId: "tt2884018"}
	res4, err := api.MovieByImdbID(query)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(res4)

	query = &gomdb.QueryData{ImdbId: "tt0944947", Season: "1", Episode: "1", SearchType: gomdb.EpisodeSearch}
	res5, err := api.MovieByImdbID(query)
	if err != nil {
		fmt.Println(err)
		return
	}
	fmt.Println(res5)

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    `json:"Title"`
	Year       string    `json:"Year"`
	Rated      string    `json:"Rated"`
	Released   string    `json:"Released"`
	Runtime    string    `json:"Runtime"`
	Genre      string    `json:"Genre"`
	Director   string    `json:"Director"`
	Writer     string    `json:"Writer"`
	Actors     string    `json:"Actors"`
	Plot       string    `json:"Plot"`
	Language   string    `json:"Language"`
	Country    string    `json:"Country"`
	Awards     string    `json:"Awards"`
	Poster     string    `json:"Poster"`
	Ratings    []Ratings `json:"Ratings"`
	Metascore  string    `json:"Metascore"`
	ImdbRating string    `json:"imdbRating"`
	ImdbVotes  string    `json:"imdbVotes"`
	ImdbID     string    `json:"imdbID"`
	Type       string    `json:"Type"`
	DVD        string    `json:"DVD"`
	BoxOffice  string    `json:"BoxOffice"`
	Production string    `json:"Production"`
	Website    string    `json:"Website"`
	Response   string    `json:"Response"`
	Error      string    `json:"Error"`
}

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(query *QueryData) (*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
	Season     string
	Episode    string
}

QueryData is the type to create the search query

type Ratings added in v0.2.0

type Ratings struct {
	Source string
	Value  string
}

Ratings is a combination of all ratings

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