imdbs

package module
v0.0.0-...-3dc03f9 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2024 License: GPL-3.0 Imports: 10 Imported by: 0

README

IMDB-Scraper

An IMDb scraper in GO.

Usage

import (
	"git.0x0001f346.de/andreas/imdbs"
)

id, err := imdbs.GetIMDbIDFromQuery("https://www.imdb.com/title/tt3230854/?ref_=nv_sr_srsg_0_tt_8_nm_0_q_expanse") // ("tt3230854", nil)
id, err = imdbs.GetIMDbIDFromQuery("https://www.imdb.com/title/tt0133093") // ("tt0133093", nil)
id, err = imdbs.GetIMDbIDFromQuery("tt2911666") // ("tt2911666", nil)

isValidIMDbID := imdbs.IsValidIMDbID(id) // true
isValidIMDbID = imdbs.IsValidIMDbID("https://www.imdb.com/title/tt0133093") // false

entry, err := imdbs.Scrap(id) // (IMDbEntry{AlternateName: "", IMDbID: "tt2911666", Rating: 7.4, RuntimeInMins: 101, Title: "John Wick", Type: "Movie", Year: 2014}, nil)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetIMDbIDFromQuery

func GetIMDbIDFromQuery(query string) (string, error)

GetIMDbIDFromQuery tries to extract an IMDb ID from query

func IsValidIMDbID

func IsValidIMDbID(s string) bool

IsValidIMDbID returns true, if s is a valid IMDb id

Types

type IMDbEntry

type IMDbEntry struct {
	AlternateName string  `json:",omitempty"`
	IMDbID        string  `json:",omitempty"`
	Rating        float64 `json:",omitempty"`
	RuntimeInMins int64   `json:",omitempty"`
	Title         string  `json:",omitempty"`
	Type          string  `json:",omitempty"`
	Year          int64   `json:",omitempty"`
}

IMDbEntry is a struct that represents an IMDb entry (movie or series)

func Scrap

func Scrap(id string) (IMDbEntry, error)

Scrap tries to scrap an entry from the IMDb

type IMDbJSON

type IMDbJSON struct {
	Context       string `json:"@context"`
	Type          string `json:"@type"`
	URL           string `json:"url"`
	Name          string `json:"name"`
	AlternateName string `json:"alternateName"`
	Image         string `json:"image"`
	Description   string `json:"description"`
	Review        struct {
		Type         string `json:"@type"`
		ItemReviewed struct {
			Type string `json:"@type"`
			URL  string `json:"url"`
		} `json:"itemReviewed"`
		Author struct {
			Type string `json:"@type"`
			Name string `json:"name"`
		} `json:"author"`
		DateCreated  string `json:"dateCreated"`
		InLanguage   string `json:"inLanguage"`
		Name         string `json:"name"`
		ReviewBody   string `json:"reviewBody"`
		ReviewRating struct {
			Type        string `json:"@type"`
			WorstRating int    `json:"worstRating"`
			BestRating  int    `json:"bestRating"`
			RatingValue int    `json:"ratingValue"`
		} `json:"reviewRating"`
	} `json:"review"`
	AggregateRating struct {
		Type        string  `json:"@type"`
		RatingCount int     `json:"ratingCount"`
		BestRating  int     `json:"bestRating"`
		WorstRating int     `json:"worstRating"`
		RatingValue float64 `json:"ratingValue"`
	} `json:"aggregateRating"`
	ContentRating string   `json:"contentRating"`
	Genre         []string `json:"genre"`
	DatePublished string   `json:"datePublished"`
	Keywords      string   `json:"keywords"`
	Trailer       struct {
		Type      string `json:"@type"`
		Name      string `json:"name"`
		EmbedURL  string `json:"embedUrl"`
		Thumbnail struct {
			Type       string `json:"@type"`
			ContentURL string `json:"contentUrl"`
		} `json:"thumbnail"`
		ThumbnailURL string    `json:"thumbnailUrl"`
		URL          string    `json:"url"`
		Description  string    `json:"description"`
		Duration     string    `json:"duration"`
		UploadDate   time.Time `json:"uploadDate"`
	} `json:"trailer"`
	Actor []struct {
		Type string `json:"@type"`
		URL  string `json:"url"`
		Name string `json:"name"`
	} `json:"actor"`
	Director []struct {
		Type string `json:"@type"`
		URL  string `json:"url"`
		Name string `json:"name"`
	} `json:"director"`
	Creator []struct {
		Type string `json:"@type"`
		URL  string `json:"url"`
		Name string `json:"name,omitempty"`
	} `json:"creator"`
	Duration string `json:"duration"`
}

IMDbJSON is a struct that represents the json encoded data of an IMDb entry

func (IMDbJSON) TransformIntoIMDbEntry

func (s IMDbJSON) TransformIntoIMDbEntry(id string, year int64) IMDbEntry

Jump to

Keyboard shortcuts

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