baconator

package module
v0.0.0-...-d6e2918 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2020 License: MIT Imports: 11 Imported by: 0

README

baconator

godoc ci

Baconator is a json api to find links between movie actors. It's inspired by The Oracle Of Bacon and is a learning exercise for me.

Installation

go get github.com/willabides/baconator/cmd/baconator

Usage

baconator -l <tcp address> -data <path to data.tar.bz2>

If the data file doesn't already exist at the given path, baconator will download it for you.

API

Baconator currently requires that actor names be spelled exactly like their wiki page.

There are two endpoints:

This returns the link between two actors.

$ curl -s "http://localhost:8239/link?a=James+Dean&b=Kevin+Bacon" | jq .
[
  {
    "name": "James Dean",
    "type": "cast"
  },
  {
    "name": "East of Eden (film)",
    "type": "movie"
  },
  {
    "name": "Julie Harris",
    "type": "cast"
  },
  {
    "name": "The Split (film)",
    "type": "movie"
  },
  {
    "name": "Donald Sutherland",
    "type": "cast"
  },
  {
    "name": "Animal House",
    "type": "movie"
  },
  {
    "name": "Kevin Bacon",
    "type": "cast"
  }
]
/center?p=:actor

This returns information that would be found on Oracle of Bacon's onecenter page

$ curl -s "http://localhost:8239/center?p=Kevin+Bacon" | jq .
{
  "count_by_distance": {
    "0": 1,
    "1": 857,
    "10": 3,
    "2": 61663,
    "3": 224174,
    "4": 96516,
    "5": 6495,
    "6": 496,
    "7": 50,
    "8": 12,
    "9": 15
  },
  "total_linkable": 405043,
  "average_distance": 3.009139770345371
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Baconator

type Baconator struct {
	CastNodes  map[string]graph.Node
	MovieNodes map[string]graph.Node
	NodeInfo   []nodeInfo
	Graph      *graph.Graph
	Movies     map[string]*movie
}

Baconator is kind of a big deal around here

func (*Baconator) LoadFromDatafile

func (b *Baconator) LoadFromDatafile(filename string) error

LoadFromDatafile loads b with data in filename

type Server

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

Server is an http server for baconator

func NewServer

func NewServer(baconator *Baconator) *Server

NewServer returns a new Server

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, req *http.Request)

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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