Copy a Managed User's Watch History

From thread: https://forums.plex.tv/topic/149557-copy-a-managed-users-watch-history/

 

Hi everyone,

 

I run Plex Media Server on a Debian server at home and I'm looking for a way to copy a managed users watch history. Right now I have my main user and a 'kids' user. I want to copy my main users watch history over to a new 'family' user in order to stop using my main user. I've looked in the /var/lib/plexmediaserver/ path and /usr/lib/plexmediaserver/ path for anything that looks like it might be a specific users history, but no luck.

 

Is there a way to copy a managed users watch history over to another user?

Yes, but only by manually editing the Plex database.  This is a totally unsupported feature but it does work.  Make a backup of your file first.  I do not use Debian or any form of linux so I cannot provide the specifics, but you need to get [sqlite](http://www.sqlite.org/download.html) running.

Then follow the commands I mention in this thread.

Ah, that is definitely in the right direction. Thanks. Unfortunately the accounts table in the com.plexapp.plugins.library.db database do not seem to match up with my managed user list.
 
![post-122924-0-02596100-1425927874.png|343x155](upload://lRBjwBfvvCGLpb7Wk8VkcbB78Ag.png)
![post-122924-0-26502600-1425927874.png|690x214](upload://77LB3eRWlNFhDQiM4uFw4Ch17kX.png)

Those 2 accounts (coldhertige and gtenney) are buddies and are actual users. So those are fine. The user I want to copy to is 'Family', so your method should work just fine... but the fact that they don't match concerns me.

The list in the database is a copy from the master list which is kept on plex.tv.  If you just created these users it is possible your database just has not been updated.  Exit PMS and restart and see if the list updates.  You can also try switching to one of these users and mark 1 item as watched which will force the database to update using that user's ID which should force the account list to update.

Thanks. Doing that updated the database. I now see the 'Mom & Dad' account, the kids account I'm guessing is the account with no name, and the Living Room account was one deleted long ago. It's still showing in the database but thats not an issue.

The solution from MovieFan worked just fine. Here were my steps:

Debian# cd /var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases/
Debian# sqlite3 com.plexapp.plugins.library.db

sqlite> .mode column
sqlite> .header on
sqlite> select id, name from accounts;
id name


1 Administrator
3567592
4494128 Family
4494289 Mom & Dad

sqlite> create table “temp” (“id” INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, “account_id” integer, “guid” varchar(255), “rating” float, “view_offset” integer, “view_count” integer, “last_viewed_at” datetime, “created_at” datetime, “updated_at” datetime, ‘skip_count’ integer DEFAULT 0, ‘last_skipped_at’ datetime DEFAULT NULL, ‘changed_at’ integer(8) default ‘0’);

sqlite> insert into temp select * from metadata_item_settings where account_id = 1;

sqlite> update temp set account_id = 4494128;

sqlite> insert into metadata_item_settings (account_id, guid, rating, view_offset, view_count, last_viewed_at, created_at, updated_at, skip_count, last_skipped_at, changed_at) SELECT account_id, guid, rating, view_offset, view_count, last_viewed_at, created_at, updated_at, skip_count, last_skipped_at, changed_at from temp;

sqlite> drop table temp;

Thanks for the help.

Awesome.   :D

I ran into a similar situation - new managed user that I’d like to copy my watched history to. This solution mostly worked - the watch status for individual files was indeed copied, but the summary numbers came out completely off. For instance, a show that was partially watched to different spots on each user ended up with “-2” remaining episodes according to the badge on the show. Opening it showed the proper status for each item, but I can’t say I feel especially safe with this method.

I should have qualified the hack above. The above steps were for copying watched status to a user with 0 watched status. If they have certain items already watched, it could result in duplicate entries which is probably why you are getting the “-2”, although I have not tried to reproduce it. You can replace the last “insert” with “replace” which will then overwrite any existing watched status to prevent duplicates. To not replace existing watched status would need an additional command to remove existing entries from the temp table before inserting them back into the original.

@“MovieFan.Plex” In your accepted answer post above, the link to the page for the sqlite commands is no longer valid. Could you please update the link and/or repost the necessary commands here?

Thanks

Link is updated. Also, here.

https://forums.plex.tv/discussion/comment/777840/#Comment_777840

1 Like

Attempted this several times, and a few notes:

  1. If you create a new managed user and immediately exit PMS, they aren’t listed in the accounts table. Switch to them once and switch back for the necessary id to be created.
  2. Deleting managed users doesn’t delete the id’s from that accounts table. So if you create/delete the same user name while attempting this, you may end up with several id’s for the user in question.
  3. Admin user isn’t always ‘1’. Mine was a still-low number, but ‘1’ was simply ‘plex’.

Sadly, at the end of the day this simply didn’t work for me - nothing was transferred over that I could see, and I’m concerned with how much I’m smashing the database. Restoring the database from an earlier version also doesn’t seem to work - deleted users don’t come back! - so there are either other databases in play or interaction with MyPlex that’s not being considered. As much as I really want this to work, I’d be very wary.

1 Like

@Negative9 said:
Thanks. Doing that updated the database. I now see the ‘Mom & Dad’ account, the kids account I’m guessing is the account with no name, and the Living Room account was one deleted long ago. It’s still showing in the database but thats not an issue.

The solution from MovieFan worked just fine. Here were my steps:

Thanks for the help.

Extra awesome! Worked verbatim (other then ID) on unRaid docker install. One extra step I took as to shut off Plex while I ran sqlite against the db.