Skip to content

Automatic sync from IMDb to Trakt (watchlist, lists, ratings and history) using GitHub actions.

License

Notifications You must be signed in to change notification settings

cecobask/imdb-trakt-sync

Repository files navigation

sync quality

imdb-trakt-sync

logo

Command line application that can sync IMDb and Trakt user data - watchlist, lists, ratings and history.
To achieve its goals the application is using the Trakt API and web scraping.
Keep in mind that this application is performing one-way sync from IMDb to Trakt. This means that any changes made on IMDb will be reflected on Trakt, but not the other way around.

Configuration

FIELD NAME DEFAULT VALUE ALLOWED VALUES DESCRIPTION
IMDB_AUTH cookies credentials
cookies
none
Authentication method to be used for IMDb:
credentials => IMDB_EMAIL + IMDB_PASSWORD field required
cookies => IMDB_COOKIEATMAIN + IMDB_COOKIEUBIDMAIN fields required
none => IMDB_LISTS field required
IMDB_EMAIL - - IMDb account email address. Only required when IMDB_AUTH => credentials
IMDB_PASSWORD - - IMDb account password. Only required when IMDB_AUTH => credentials
IMDB_COOKIEATMAIN - - Cookie value only required when IMDB_AUTH => cookies. Get the following cookie information from your browser:
name: at-main | domain: .imdb.com
IMDB_COOKIEUBIDMAIN - - Cookie value required when IMDB_AUTH => cookies. Get the following cookie information from your browser:
name: ubid-main | domain: .imdb.com
IMDB_LISTS - - Array of IMDb list IDs that you would like synced to Trakt. If this array is not specified or empty, all IMDb lists on your account will be synced to Trakt. In order to get the ID of an IMDb list, open it from a browser - the ID is in the URL with format ls#########. If provided as GitHub secret or environment variable, define its values as comma-separated list. Keep in mind the Trakt list limits!
IMDB_TRACE false true
false
Print tracing logs related to browser activities. Can be useful for debugging purposes
IMDB_HEADLESS true true
false
Whether to run the browser in headless mode or not. Only set this to false when running the syncer locally
IMDB_BROWSERPATH - - The location of your preferred web browser. If you leave this value empty, the syncer will attempt to lookup common browser locations. You can optionally override its value to use a specific browser
SYNC_MODE dry-run full
add-only
dry-run
Sync mode to be used when running the application:
full => add Trakt items that don't exist, delete Trakt items that don't exist on IMDb, update
Trakt items by treating IMDb as the source of truth
add-only => add Trakt items that do not exist, but do not delete anything
dry-run => identify what Trakt items would be added / deleted / updated
SYNC_HISTORY false true
false
Whether to sync history or not. When IMDB_AUTH => none, history sync will be skipped
SYNC_RATINGS true true
false
Whether to sync ratings or not. When IMDB_AUTH => none, ratings sync will be skipped
SYNC_WATCHLIST true true
false
Whether to sync watchlist or not. When IMDB_AUTH => none, watchlist sync will be skipped
SYNC_LISTS true true
false
Whether to sync lists or not. This provides the option to disable syncing of lists
SYNC_TIMEOUT 15m - Maximum duration to run the syncer. Users with large libraries might have to increase the timeout value accordingly. Valid time units are: ns, us (or µs), ms, s, m, h
TRAKT_CLIENTID - - Trakt app client ID
TRAKT_CLIENTSECRET - - Trakt app client secret
TRAKT_EMAIL - - Trakt account email address (do NOT confuse with username)
TRAKT_PASSWORD - - Trakt account password

Usage

The application can be setup to run automatically, based on a custom schedule (default: once every 12 hours) using GitHub Actions, in a container, or locally on your machine.
Workflow schedules can be tweaked by editing the .github/workflows/sync.yaml file and committing the changes.
Please configure the application to suits your needs, by referring to the Configuration section, before running it.
Follow the relevant section below, based on how you want to use the application.

Run the application using GitHub Actions

  1. Fork the repository to your account
  2. Create a Trakt App. Use urn:ietf:wg:oauth:2.0:oob as redirect uri
  3. Configure the application:
    • Open your fork repository on GitHub
    • Create an individual repository secret for each Configuration field you need: Settings > Secrets and variables > Actions > New repository secret
  4. Allow GitHub Actions on your fork repository: Settings > Actions > General > Allow all actions and reusable workflows
  5. Enable the sync workflow: Actions > Workflows > sync > Enable workflow
  6. Run the sync workflow manually: Actions > Workflows > sync > Run workflow
  7. From now on, GitHub Actions will automatically trigger the sync workflow based on your schedule

Run the application in a Docker container

  1. Install Docker
  2. Clone the repository: git clone [email protected]:cecobask/imdb-trakt-sync.git
  3. Create a Trakt App. Use urn:ietf:wg:oauth:2.0:oob as redirect uri
  4. Configure the application:
    • Create .env file with the same contents as .env.example
    • Populate the .env file with your own secret values
    • All secret keys should have ITS_ prefix
  5. Open a terminal window in the repository folder and then:
    • Build a Docker image: make package
    • Run the sync workflow in a Docker container: make sync-container

Run the application locally

  1. Install Git and Go
  2. Clone the repository: git clone [email protected]:cecobask/imdb-trakt-sync.git
  3. Create a Trakt App. Use urn:ietf:wg:oauth:2.0:oob as redirect uri
  4. Open a terminal window in the repository folder and then:
    • Build the syncer: make build
    • Configure the syncer: make configure
    • Run the syncer: make sync

About

Automatic sync from IMDb to Trakt (watchlist, lists, ratings and history) using GitHub actions.

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors 3

  •  
  •  
  •  

Languages