Skip to content

Latest commit

 

History

History
163 lines (100 loc) · 7.57 KB

README.md

File metadata and controls

163 lines (100 loc) · 7.57 KB

trakt-to-letterboxd

Build, Test & Publish Main 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

schema

src/main/exporter.ts:7-21

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

defaults

src/main/mapper.ts:11-23

Default values for letterboxd object shape

headers

src/main/fetcher.ts:14-18

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

traktHistoryToCsv

src/main/index.ts:20-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

options

src/main/fetcher.ts:23-25

The fetch options object (only really needs headers)

builder

src/main/exporter.ts:28-28

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

mapTraktToLetterboxd

src/main/mapper.ts:31-44

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

mergeWatchedWithRatings

src/main/fetcher.ts:34-55

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

mapper

src/main/mapper.ts:52-58

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

fetchMovies

src/main/fetcher.ts:63-88

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