imdblit

package module
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2023 License: MIT Imports: 9 Imported by: 0

README

IMDB literature.list wrapper

A small library for processing an exported IMDB literature.list database file.

This library was created for my own ebook toolchain, so it contains features only for that purpose; fetching movies that are adaptations of novels.

Usage

A basic example might be:

package main

import (
	"fmt"
	"os"

	"github.com/mrcook/imdblit"
)

func main() {
	imdbFile, err := os.Open("./literature.list")
	if err != nil {
		panic(err)
	}
	db := imdblit.NewIMDB(imdbFile)

	movies, err := db.FindMovieAdaptations("A Christmas Carol", "Charles Dickens")
	if err != nil {
		panic(err)
	}
	for _, movie := range movies {
		fmt.Printf("%d: %s\n", movie.Year, movie.Title)
	}
}

LICENSE

Copyright (c) 2018-2023 Michael R. Cook. All rights reserved.

This work is licensed under the terms of the MIT license. For a copy, see https://opensource.org/licenses/MIT.

Documentation

Overview

Package imdblit provides the ability to search an IMDB literature.list database file, decoding each record to a set of Go structs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IMDB

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

An IMDB reads and processes movie records values from an input stream.

func NewIMDB

func NewIMDB(r io.Reader) *IMDB

NewIMDB returns a new IMDB that reads from r.

func (*IMDB) DatabaseCreatedOn

func (db *IMDB) DatabaseCreatedOn() time.Time

DatabaseCreatedOn will contain the datetime that the DB file was generated, once the .list has been parsed.

func (*IMDB) ExtractAll added in v0.9.0

func (db *IMDB) ExtractAll() ([]movie.Movie, error)

ExtractAll processes the DB and returns all movies and associated data.

func (*IMDB) FindMovieAdaptations

func (db *IMDB) FindMovieAdaptations(title, author string) ([]movie.Movie, error)

FindMovieAdaptations processes the DB and returns movies that are adaptations of the given book title/author.

The search will only parse the book types: ADPT, BOOK, and NOVL, which will speed up the processing considerably.

func (*IMDB) TotalRecordCount

func (db *IMDB) TotalRecordCount() int

TotalRecordCount will contain the total number of records found in the file, once the .list has been parsed.

Directories

Path Synopsis
Package movie is a set of Go types on to which the IMDB movie record is unmarshalled.
Package movie is a set of Go types on to which the IMDB movie record is unmarshalled.

Jump to

Keyboard shortcuts

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