Media not showing as played despite value of view_count in metadata_item_settings

Server Version#:
Player Version#:

I’m trying to migrate my libraries from kodi to plex and want to migrate the watched status, resume point and hopefully the last viewed_at date. The reason I care about viewed_at is I expect the resume watching playlist is sorted using that date.

I know that a commonly suggested approach is to use trakt. However, I have a lot of older anime and other media that doesn’t translate to trakt well. So I’m trying to write a script to read the kodi database and insert entries into the plex db.

From many previous threads I’ve gleaned that I can insert entries into metadata_item_settings. I tried inserting a row for a movie and I find that it does respect the value of the view_offset, but does not mark a show as watched despite my setting the view_,count to 1.

Does anyone know why this might be? Is there an additional table I should be inserting data into?

Are you only inserting the view_count or also values in the other columns?
AFAIK, you need at least to also specifiy the user account_id of the admin (always 1) and maybe also a date-timestamp in last_viewed_at

Here is a real-world view at this table

Thanks for responding so quickly!
Yes I am inserting values into those columns and a few others.

I used values from other rows to fill in last_viewed_at and a few other fields such as changed_at. (I would like to grab last_viewed_at from kodi, but I’m worried that plex might be confused that the value of the field is older than the rest of the db. )

That should be no problem.
You might also want to set the added_at date to the file’s timestamp.

Are you sure that the files are matched to the guid? Because this is the primary identification key for each file. You certainly don’t want to make this ID up willy-nilly.
And if you create a new library with the primary metadata agent set to ‘Plex Movie’ instead of ‘Plex Movie (Legacy)’, a value of e.g. com.plexapp.agents.imdb://tt7146812?lang=en won’t be of use.
Your newly created movie library must use ‘Plex Movie (Legacy)’ as its default agent if you provide the IMDb ID in the above form.
If you use the TheMovieDB instead, your default agent must be set to ‘The Movie Database’ and you must provide the TMDB ID in this form: com.plexapp.agents.themoviedb://508439?lang=en

If you have a mix of the different ID’s, this method will only work for one of the data sources (the one you have selected as your library’s default agent).

Thanks, those are good callouts. I’m testing it manually right now. Once I decide to write a script, my plan was to use media_parts to match the filename and find the corresponding media_item_id and look up the media_items table to find the metadata_item_id and then to look up metadata_items to find the guid that was used.

However, right now when I’m manually testing it, I still dont understand why this movie does not show up as “played”. I know I’m modifying the correct guid because plex clearly reflects the value of view_offset and resumes at the correct mark. Is there anyway to check what plex thinks the played status is?

Responding to this thread. I’ve discovered that plex does correctly read and respond to my setting the view_offset and last_viewed_at and view_count fields correctly. My added_at dates have already been set correctly because plex imported it from the filesystem.

The field I discovered that I have to be careful with is “changed_at”. When I had duplicates, plex was unhappy and there were errors in the log. I cant quite figure out the logic with which changed_at is populated.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.