Coder Social home page Coder Social logo

zjbennett / trakt-to-letterboxd Goto Github PK

View Code? Open in Web Editor NEW

This project forked from bbeesley/trakt-to-letterboxd

0.0 0.0 0.0 2.76 MB

CLI tool for publishing your trakt watched history to your letterboxd account

JavaScript 48.36% TypeScript 51.64%

trakt-to-letterboxd's Introduction

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-letterboxd -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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.