trakt-to-letterboxd

Extract trakt movie history and export to csv for uploading to letterboxd

Usage no npm install needed!

<script type="module">
  import traktToLetterboxd from 'https://cdn.skypack.dev/trakt-to-letterboxd';
</script>

README

trakt-to-letterboxd

CircleCI codecov Commitizen friendly

Description

A package to migrate your trakt movie history and ratings to letterboxd. Optionally the trakt Watchlist can also be exported. Currently letterboxd only supports importing from a csv, so thats all this package does at the moment. When a proper API is added, I'll update this to push the data right into your letterboxd history.

Usage

The easiest way to use this currently is with npx. You can install that globally with yarn global add npx or npm i -g npx. Once you have that, just run:

npx trakt-to-letterboxd -u username -f filename

where username is the user whose data you want to export, and filename is the name of the csv file you want to output to.

To export your watchlist use

npx trakt-to-letterboxy -u username -w watchListFilename

Both options can also be used together:

npx trakt-to-letterboxd -u username -f filename -w watchListFilename

If only a username is given it will correspond to the following command:

npx trakt-to-letterboxd -u username -f history.csv -w watchlist.csv

API

Table of Contents

traktHistoryToCsv

src/main/index.js:21-54

Export a trakt user's history to csv to be uploaded to letterboxd

Parameters

  • props Object Properties passed from argv
    • props.userName string The user whose data you want to export
    • props.fileName string The name of the file to output the watchlist to
    • props.watchListFileName

Returns Promise<void> We dont return anything

headers

src/main/fetcher.js:15-19

HTTP headers to send with our request to trakt's api

options

src/main/fetcher.js:24-26

The fetch options object (only really needs headers)

mergeWatchedWithRatings

src/main/fetcher.js:35-52

Fetch the ratings of a user and merge them with the movie history based on the movie's Trakt ID

Parameters

  • user string The username we're getting data for
  • watched TraktMovieHistoryType A list of movies that have been watched

Returns Promise<TraktRatingMergedHistoryType> Promise that resolves to Trakt movie data with merged rating

fetchMovies

src/main/fetcher.js:60-81

Fetches the user's history data from the trakt api

Parameters

  • user string The username we're getting data for
  • isWatchlist boolean Whether to fetch the history or the watchlist, defaults to the history (optional, default false)

Returns Promise<Array<LetterboxdHistoryEntityType>> Promise that resolves to mapped Letterboxd data

defaults

src/main/mapper.js:12-24

Default values for letterboxd object shape

mapTraktToLetterboxd

src/main/mapper.js:32-45

Maps a trakt history entry to a letterboxd history entry

Parameters

  • movie TraktRatingMergedHistoryEntityType A trackt movie history entity
  • isWatchlist boolean Whether to map the history or the watchlist, defaults to the history

Returns LetterboxdHistoryEntityType A letterboxd movie history entity

mapper

src/main/mapper.js:53-56

Maps an array of trakt history entries to an array of letterboxd history entities

Parameters

  • movieList Array<TraktRatingMergedHistoryEntityType> Trakt History
  • isWatchlist boolean Whether to map the history or the watchlist, defaults to the history (optional, default false)

Returns Array<LetterboxdHistoryEntityType> letterboxd history

schema

src/main/exporter.js:8-22

Schema for the output csv. Based on https://letterboxd.com/about/importing-data/

builder

src/main/exporter.js:29-29

The instance of CsvBuilder we'll use to export the data. We need to remap the format of the last watched date to YYYY-MM-DD to comply with letterboxd's formatting