Giter Site home page Giter Site logo

cecobask / imdb-trakt-sync Goto Github PK

View Code? Open in Web Editor NEW
76.0 7.0 184.0 600 KB

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

License: MIT License

Go 99.82% Makefile 0.18%
imdb trakt github-actions golang

imdb-trakt-sync's Introduction

sync quality codecov

imdb-trakt-sync

Command line application that can sync IMDb and Trakt user data - watchlist, lists, ratings and optionally 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.

Usage

The application can be setup to run automatically, based on a custom schedule (default: once every 3 hours) using GitHub Actions or locally on your machine.
Workflow schedules can be tweaked by editing the .github/workflows/sync.yaml file and committing the changes.
There are 3 possible modes to run this application and more details can be found in the config.yaml file.
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 parameter: Settings > Secrets and variables > Actions > New repository secret
    • The secret names should match the configuration parameter paths (delimited by underscore). For example, to configure your Trakt email, the secret name should be TRAKT_EMAIL
  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

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

imdb-trakt-sync's People

Contributors

cecobask avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

imdb-trakt-sync's Issues

Sync two trakt lists

Just an ideia.
Is it possible to implement sync between two trakt lists? The idea is to sync lists between two accounts so we could use it kinda like colab lists.

Sync Failure

I've updated to the latest and my secrets are correct, but I'm getting this error. I do have tv shows in my watchlist list but that was said to be fixed in a previous version.

Run go run cmd/syncer/main.go
{"level":"fatal","ts":"2023-01-[14](https://github.com/kunall-ll/imdb-trakt-sync/actions/runs/3917021448/jobs/6696551623#step:4:15)T05:09:09Z","caller":"syncer/syncer.go:62","msg":"failure initialising imdb client","error":"failure hydrating imdb client: 
failure scraping imdb user id: imdb user id not found: failure scraping imdb response for selector .user-profile.userId and attribute data-
userid","stacktrace":"github.com/cecobask/imdb-trakt-sync/pkg/syncer.NewSyncer\n\t/home/runner/work/imdb-trakt-sync/imdb-trakt-sync/pkg/syncer/syncer.go:62\nmain.main\n\t/home/runner/work/imdb-trakt-sync/imdb-trakt-sync/cmd/syncer/main.go:8\nruntime.main\n\t/opt/hostedtoolcache/go/1.18.9/x64/src/runtime/proc.go:250"}
exit status 1
Error: Process completed with exit code 1.

Sync is failing

go build -o build/its main.go
./build/its sync
Error: error creating syncer: failure hydrating trakt client: failure generating auth codes: http request POST https://api.trakt.tv/oauth/device/code returned status code 401: unexpected status code 401
make: *** [Makefile:7: sync] Error 1
Error: Process completed with exit code 2.

I see it in your actions log too

Sync failing

Hello,
The repository and many other forks are getting this error while syncing.

imagem

This problem is due to the Trakt website being down.
Anyone with this problem can track the Trakt status on https://status.trakt.tv

Additional run modes: dry-run & add-only

I just used this tool to sync imdb ratings to trakt, very useful!
Since I already added something to trakt manually, in the logs it showed some deletions: 1 show from watchlist, and 1 movie and 2 shows from history+ratings.
So I'm thinking two additional run modes would be useful:

  • dry-run: to see what would be applied, and prevent unwillingly erasing data (I have yet to find which movie and 1 of the show it deleted from history)
  • add-only: to permit syncing only additions

Also, a log file with all stuff that was executed would be perfect in case some huge erasing happens, in order to be able to revert them (even manually). In the github action you could just cat it after run to have it logged.

From my side I plan to only use trakt from now on, so these would be useful additions for others in the future, rather than for me specifically.
Thanks for the effort!

Error in retrieving IMDB watchlist.

For the last ~15 hours I've noticed most of my sync jobs failing with the following error, during the Sync step:

./build/its sync
Error: error creating syncer: failure hydrating imdb client: failure scraping imdb watchlist id: http request GET https://www.imdb.com/watchlist returned status code 403: unexpected status code 403
make: *** [Makefile:10: sync] Error 1
Error: Process completed with exit code 2.

After updating my environment variables, the jobs continued to fail until around ~6 hours ago when one of them succeeded. The subsequent jobs have both failed with the 403 error.

I'm assuming IMDB may have changed something on their end, possibly in an attempt to rate-limit or prevent scraping, and that may be causing a 403 Forbidden error when the script attempts to run.

My only idea for resolving this would be to reduce the interval between runs to every 12-24 hours.

Cant get your imdb-trakt sync repo to run

I created the Trakt Api-App with the recommended "urn:ietf:wg:oauth:2.0:oob" url and get a Code like one if i'm about to add a new device. I added this code to the reqbin.com/veotsc62 Snippet and got an access token which I added in the template of the branch secret action (also I added all other Values from IBMD and Trakt).
I'm totally new to github and only got here, because I wanted to sync my imdb records with the one of trakt. :-)

Im always getting an sync error:
Process completed with exit code 1.

Currently I'm out of options and would kindly ask for some help.

I'm not sure this is the right way, or place to do so, but i didn't find a "contact" form of any kind.

Thanks in advance Sky

TRAKT_ACCESS_TOKEN retrieval

Could you verify the steps provided in the README?

I was unable to locate the correct value to use as the TRAKT_ACCESS_TOKEN environment variable through their site. I had to resort to this random website to pull the token for me.

failure unmarshalling trakt response

I get the following error when trying to sync my imdb lists (just for this one list, 3 others sync fine).

{"level":"fatal","time":"2023-04-12T13:25:30Z","caller":"syncer/syncer.go:96","message":"failure syncing lists","error":"failure adding items to trakt list films-to-watch: failure unmarshalling trakt response: EOF","stacktrace":"github.com/cecobask/imdb-trakt-sync/pkg/syncer.(*Syncer).Run\n\t/home/runner/work/imdb-trakt-sync/imdb-trakt-sync/pkg/syncer/syncer.go:96\nmain.main\n\t/home/runner/work/imdb-trakt-sync/imdb-trakt-sync/cmd/syncer/main.go:8\nruntime.main\n\t/opt/hostedtoolcache/go/1.18.10/x64/src/runtime/proc.go:250"}
This happens whether I define the lists by their ID, or choose "all". Running with dry-run works fine, it lists all the titles that it would have added, but running it in "full" mode returns the above message. The list is large - 1029 items, though I have trakt vip to support that list size. I tried it with reducing the number of items and it still didn't work. Running it with just the other 3 lists works fine (largest one of those is 702 items).

Please let me know if you have any suggestions or if you need any other information.

Failure hydrating imdb client

{
  "level": "fatal",
  "ts": "2023-01-06T12:08:13Z",
  "caller": "syncer/syncer.go:92",
  "msg": "failure hydrating imdb client",
  "error": "failure fetching trakt item id: unknown trakt item type season",
  "stacktrace": "github.com/cecobask/imdb-trakt-sync/pkg/syncer.(*Syncer).Run\n\t/home/runner/work/imdb-trakt-sync/imdb-trakt-sync/pkg/syncer/syncer.go:92\nmain.main\n\t/home/runner/work/imdb-trakt-sync/imdb-trakt-sync/cmd/syncer/main.go:8\nruntime.main\n\t/opt/hostedtoolcache/go/1.18.9/x64/src/runtime/proc.go:250"
}

Any idea what might be wrong? I tried refreshing all secrets but with no avail

Sync movie ratings and add to watched history

Hey, I just stumbled across your project and it works amazing. I only got one little feature request:

Would it be possible to mark a movie as watched on Trakt when the rating from IMDb is synced? I now only got the rating synced but it's not in the history.

Best Regards

Nico

Error running sync action: "error scraping trakt pin code: pin code not found"

I followed the instructions in the README about setting up the environment variables for GitHub Actions in a forked repository. When manually running the "sync" action in GitHub on my forked repository, I get the following output:

Run go run cmd/imdb-trakt-sync/main.go
go: downloading github.com/joho/godotenv v1.4.0
go: downloading github.com/PuerkitoBio/goquery v1.8.0
go: downloading github.com/andybalholm/cascadia v1.3.1
go: downloading golang.org/x/net v0.0.0-20210916014120-12bc252f5db8
2022/11/08 19:30:56 error scraping trakt pin code: pin code not found
exit status 1
Error: Process completed with exit code 1.

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.