lbstats

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

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

Go to latest
Published: Feb 3, 2023 License: MIT Imports: 12 Imported by: 0

README

letterboxd_stats

Package to load films, user information and create stats based on Letterboxd .csv exportable files.

Stats

When calling LoadFilmsFromCSVfile() a list of films is returned, using it anything can be done with the film info privided by TMDB. So, if you wish to create your own stats or just display the list of films there is no need to get the buil-in stats. This package can be used just for loading data from the .csv files and obtain the information about each film.

Basic Stats
  • Number of films - NFilms int
  • Number of rewatched films - NRewatched int
  • Most seen years - MostSeenYears map[int]int
  • Total of minutes - NMinutes int
  • Number of films watched per week - NWeek [52]int
  • Number of films watched per fay of week (0 for sunday, ...) - NDayOfWeek [7]int
  • Number of films watched per month - NMonth [12]int
  • Number of films per genre - Genres map[string]int
  • Number of films per languages - Languages map[string]int
  • Number of films per country - Countries map[string]int
  • Average rating - AvgRating float32
Cast Stats
  • Number of films per cast member - Acting map[string]int
  • Number of films per director - Directors map[string]int
  • Number of films per writer - Writers map[string]int
  • Number of films per cinematographer - Cinematographers map[string]int
  • Number of films per editor - Editors map[string]int
  • Number of films per producer - Producers map[string]int
  • Number of films per music crew member - Music map[string]int

Example

import "github.com/diogoftm/letterboxd_stats"
// get user info
var user lbstats.User
user = lbstats.LoadUser("xpto/profile.csv") // get user info

// load films
var filmList lbstats.FilmList
filmList = lbstats.LoadFilmsFromCSVfile("xpto/diary.csv")

// get basic and credits stats
var bs lbstats.BasicStats
var cs lbstats.CreditsStats
var err error
bs, err = lbstats.GetBasicStats(filmList, 0)
cs, err = lbstats.GetCreditsStats(filmList, 0)

TMDB

The Movie Database (TMDB) is a community built movie and TV database. Every piece of data has been added by our amazing community dating back to 2008. TMDB's strong international focus and breadth of data is largely unmatched and something we're incredibly proud of. Put simply, we live and breathe community and that's precisely what makes us different.

All film information is obtained from TMDB's API. Letterboxd uses TMDB too, but on the .csv files they do not include the TMDB id of films. So, a search is always made using the title and the year of release of each film and the best match is picked. Because of that, in some cases, a Letterboxd URI might be mismatched to it's respective TMDB id.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Check

func Check(e error)

func ParseToDate

func ParseToDate(str string) time.Time

func SingleAtoi

func SingleAtoi(str string) int

func SingleParseFloat

func SingleParseFloat(str string) float32

Types

type Basic

type Basic struct {
	Adult                bool      `json:"adult"`
	Backdrop_path        string    `json:"backdrop_path"`
	Budget               int       `json:"budget"`
	Genres               []Gender  `json:"genres"`
	Homepage             string    `json:"homepage"`
	Id                   int       `json:"id"`
	Imdb_id              string    `json:"imdb_id"`
	Original_language    string    `json:"original_language"`
	Original_title       string    `json:"original_title"`
	Overview             string    `json:"overview"`
	Popularity           float32   `json:"popularity"`
	Poster_path          string    `json:"poster_path"`
	Production_companies []Company `json:"production_companies"`
	Production_countries []Country `json:"production_countries"`
	Release_date         string    `json:"release_date"`
	Revenue              int       `json:"revenue"`
	Runtime              int       `json:"runtime"`
	Spoken_languages     []Country `json:"spoken_languages"`
	Status               string    `json:"status"`
	Tagline              string    `json:"tagline"`
	Title                string    `json:"title"`
	Video                bool      `json:"video"`
	Vote_average         float32   `json:"vote_average"`
	Vote_count           int       `json:"vote_count"`
	Year                 int
}

type BasicStats

type BasicStats struct {
	NFilms        int //number of films (does not include rewatches)
	NRewatched    int
	MostSeenYears map[int]int
	NMinutes      int
	NWeek         [52]int
	NDayOfWeek    [7]int //0 for sunday, ...
	NMonth        [12]int
	Genres        map[string]int
	Languages     map[string]int
	Countries     map[string]int
	AvgRating     float32
}

func GetBasicStats

func GetBasicStats(list FilmList, year int) (BasicStats, error)

General stats based on a list of films for a given year (year=0 for no year restriction)

type Cast

type Cast struct {
	Adult                bool    `json:"adult"`
	Gender               int     `json:"gender"`
	Id                   int     `json:"id"`
	Known_for_department string  `json:"known_for_department"`
	Name                 string  `json:"name"`
	Original_name        string  `json:"original_name"`
	Popularity           float32 `json:"popularity"`
	Profile_path         string  `json:"profile_path"`
	Cast_id              int     `json:"cast_id"`
	Character            string  `json:"character"`
	Credit_id            string  `json:"credict_id"`
	Order                int     `json:"order"`
}

type Company

type Company struct {
	Name           string `json:"name"`
	Id             int    `json:"id"`
	Logo_path      string `json:"logo_path"`
	Origin_country string `json:"origin_country"`
}

type Country

type Country struct {
	Iso_3166_1 string `json:"iso_3166_1"`
	Name       string `json:"name"`
}

type Credits

type Credits struct {
	Id   int    `json:"id"`
	Cast []Cast `json:"cast"`
	Crew []Crew `json:"crew"`
}

func (Credits) Jobs

func (credits Credits) Jobs() map[string][]string

Returns a map with jobs as keys and a list of names as value

type CreditsStats

type CreditsStats struct {
	Acting           map[string]int
	Directors        map[string]int
	Writers          map[string]int
	Cinematographers map[string]int
	Editors          map[string]int
	Producers        map[string]int
	Music            map[string]int
}

func GetCreditsStats

func GetCreditsStats(list FilmList, year int) (CreditsStats, error)

Cast and crew stats based on a list of films for a given year (year=0 for no year restriction)

type Crew

type Crew struct {
	Adult                bool    `json:"adult"`
	Gender               int     `json:"gender"`
	Id                   int     `json:"id"`
	Known_for_department string  `json:"known_for_department"`
	Name                 string  `json:"name"`
	Original_name        string  `json:"original_name"`
	Popularity           float32 `json:"popularity"`
	Profile_path         string  `json:"profile_path"`
	Credit_id            string  `json:"credict_id"`
	Department           string  `json:"department"`
	Job                  string  `json:"job"`
}

type Film

type Film struct {
	Basic   Basic
	Credits Credits

	Date    string
	Rating  float32
	Rewatch []Rewatch
	// contains filtered or unexported fields
}

func Duplicates

func Duplicates(films []*Film) []*Film

func GetFilm

func GetFilm(title string, year string) *Film

TMDB API requests for film info

type FilmList

type FilmList struct {
	AllFilms        map[int]*Film    //keys are TMDB id's
	AllFilmsByLbURI map[string]*Film //keys are letterboxd URI's
	FilmsByYear     map[int][]*Film  //rewatches are included, use nRewatched() to get the full list taking into account the full depth of the Rewatched list
}

func LoadFilmsFromCSVfile

func LoadFilmsFromCSVfile(diaryPath string) FilmList

Load films from diary.csv like file

func (FilmList) ListFilms

func (lst FilmList) ListFilms() []*Film

List all films on a FilmList

type FindAnswer

type FindAnswer struct {
	Results       []Basic `json:"results"`
	Total_results int     `json:"total_results"`
}

type Gender

type Gender struct {
	Id   int    `json:"id"`
	Name string `json:"name"`
}

type Rewatch

type Rewatch struct {
	Date   string
	Rating float32
}

type User

type User struct {
	DateJoined    string
	Username      string
	GivenName     string
	FamilyName    string
	Email         string
	Location      string
	Website       string
	Bio           string
	Pronoun       string
	FavoriteFilms []string //list of Letterboxd URI's (to get film info access AllFilmsLbURI map)
}

func LoadUser

func LoadUser(profilePath string) User

Load user info from profile.csv like file

Jump to

Keyboard shortcuts

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