Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import From Plex's database to Trakt. #16

Open
ghost opened this issue Mar 10, 2019 · 7 comments
Open

Import From Plex's database to Trakt. #16

ghost opened this issue Mar 10, 2019 · 7 comments

Comments

@ghost
Copy link

ghost commented Mar 10, 2019

Is there a simple way to sync historical data from Plex's database to Trakt? Plex has all watched data stored in metadata_item_views table. I am not sure how to extract from that table to format which your script would expect. Seems like something that might have been done before so figured I might ask. Thanks.

@xbgmsharp
Copy link
Owner

I don't use Plex, so it has not been done before at least per me. If Plex use sqlite db the script should be similar to the Kodi export. Ideally you export in a file the IMDB ID. https://github.com/xbgmsharp/trakt/blob/master/KODI.md

@SturmB
Copy link

SturmB commented Mar 30, 2022

Sorry to resurrect this; I am running into this situation now.

Is there a chance you could please post the schema(s) of the .csv file that the import script expects? Then it shouldn't be a problem for me to work out the proper query that will output the necessary data from Plex's SQLite DB to the .csv file correctly.

@xbgmsharp
Copy link
Owner

xbgmsharp commented Mar 31, 2022

The import csv file should at least include a least an id, you can also have a rated_at and watched_at column.
https://github.com/xbgmsharp/trakt/blob/master/import.md

@SturmB
Copy link

SturmB commented Apr 1, 2022

The import csv file should at least include a list a id, you can also have a rated_at and watched_at column. https://github.com/xbgmsharp/trakt/blob/master/import.md

I assume you meant "at least an id". And I guess the id would be either imdb, tvdb, etc.? That's fine, I am able to find that info in Plex. Same with watched_at.

However, I'm curious about adding to Trakt's 'collection' list. There is definitely an added_at column in one of Plex's db tables, which would be perfect for importing the date/time when a movie or tv show was added to Trakt's 'collection'. How would this be done? I'm guessing that I just need to add the flag -l collection to the cli command, but should the column name stay added_at in the csv file?

@xbgmsharp
Copy link
Owner

That is correct the id can be either 'imdb', 'tmdb', 'tvdb', 'tvrage', 'trakt'.
watched_at and rated_at are the only additional column supported at the moment.
Feel free to contribute, anyhow I don't see an added_at in the doc, https://trakt.docs.apiary.io/#reference/sync
But there is an collected_at when importing collection .

Example integration rated_at for https://github.com/xbgmsharp/trakt/pull/45/files
Import cvs loop, https://github.com/xbgmsharp/trakt/blob/master/import_trakt.py#L450

@SturmB
Copy link

SturmB commented Apr 1, 2022

Okay, those links help, thank you. I am still missing something, though, as I got the following error message:

Invalid file format, id (row) must exists and is not blank (has a format).

From the following simple csv:

id,collected_at
tt0111282,2020-02-16T17:40:42Z

@SturmB
Copy link

SturmB commented Apr 3, 2022

After exploring the repo more and discovering the proper format at https://github.com/xbgmsharp/trakt/blob/master/import.md, I was finally able to get it to work. And I see that collected_at isn't, as you said, supported at the moment.

I just might fork the repo and take a stab at it, myself. If it works, I might even see if I can include the other metadata as well, such as resolution, audio, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants