Jump to content

mirror watched state


mastrmind11

Recommended Posts

mastrmind11

Is there a way to mirror watched state across 2 accounts so that I can keep my admin account for admin-y stuff but have a side account for when I am external so that I can keep it passwordless?  My admin password is not fun on a remote but it also my main account for viewing, and when I'm out of the house it isn't a fun login procedure.  I'm sure I'm not alone, so curious how others are handling this.  Cheers

Edited by mastrmind11
Link to comment
Share on other sites

Happy2Play

You could periodically do it with the Server Configuration Backup plugin as it allows you to map userdata to any user.  On a restore deselect everything and only select the users data you want to map to another user.

 

57 minutes ago, Q-Droid said:

Is that info in the DB? Might need to work up some SQL to copy that activity between the accounts.

 

Yes it is the userdatas table of the library db.  You would need to look in the users.db to know what userid belongs to the users.

Edited by Happy2Play
Link to comment
Share on other sites

mastrmind11

so in short without scripting something up, no dice.  rgr, thought i'd throw it out there.  perhaps throw in a FR.  cheers

Link to comment
Share on other sites

chef

Hey @mastrmind11 😃 so we want to sync watched data across two accounts?

 

We need to do an initial sync, and then updated watched status from one account to the other when it changes?

 

Let's do this! 

  • Like 1
Link to comment
Share on other sites

Gilgamesh_48
On 8/12/2020 at 3:45 PM, mastrmind11 said:

Is there a way to mirror watched state across 2 accounts so that I can keep my admin account for admin-y stuff but have a side account for when I am external so that I can keep it passwordless?  My admin password is not fun on a remote but it also my main account for viewing, and when I'm out of the house it isn't a fun login procedure.  I'm sure I'm not alone, so curious how others are handling this.  Cheers

I use Trakt for that. I have two accounts on my main server and a total of three servers and Trakt keeps them synced up nicely. I have seen others talk about having issues with multiple users but, for me, Trakt just works and keeps all my servers and accounts synced up just fine.

Link to comment
Share on other sites

Q-Droid
2 hours ago, chef said:

Hey @mastrmind11 😃 so we want to sync watched data across two accounts?

 

We need to do an initial sync, and then updated watched status from one account to the other when it changes?

 

Let's do this! 

Hey, while you're at it you could work on role hierarchy and an RBAC model. Imagine being able to use roles for settings, access, ratings and even watch history.  Wouldn't that be cool? 😉

 

Link to comment
Share on other sites

chef
26 minutes ago, Q-Droid said:

Hey, while you're at it you could work on role hierarchy and an RBAC model. Imagine being able to use roles for settings, access, ratings and even watch history.  Wouldn't that be cool? 😉

 

Oh boy. I think that Role Based Access Control is a core thing.  😉

But, that would be cool wouldn't it

Then my wife wouldn't have to ask me to change parental controls for my boys account. She could do it, and I wouldn't worry about her changing item delete settings while she was messing with it.

Link to comment
Share on other sites

chef

I have the layout setup. 

 

I think after the initial sync, we can create a scheduled task which will run and make sure everything is sync'd up properly, but  should we also tie into the playback event Arguments to update the sync'd account lists as well? That would allow for a more real time sync.

Goin' for lunch, see ya back in a bit! 😉

accountSync1.png

Edited by chef
Link to comment
Share on other sites

chef

I've got the accounts watched status syncing. 

 

I'm gonna run it through a couple preliminary tests to make sure it works, then I'll put a copy here.  Then I can add stuff it might be missing :)

 

 

accountSync2.png

Edited by chef
Link to comment
Share on other sites

chef

@mastrmind11 It looks as though now we can log the watched states between two account profiles after running the scheduledTask.

So the only thing now will be to sync the two accounts together, by marking the media item  "IsPlayed"  param to true. Should be interesting.

accountSync3.png

Edited by chef
  • Like 1
Link to comment
Share on other sites

chef

Uh oh, I'm stuck.

 

I've always written code which acted upon the information in Emby, I've never tried to manipulate it before. 😥

I've got to figure out how to target played state of a userItem, change it, and save it to the database.

 

                var user1 = UserManager.GetUserById(syncProfile.UserId1);
                var user2 = UserManager.GetUserById(syncProfile.UserId2);

                //Query Movie and television episodes ID's  only for testing
                var queryResultIds = LibraryManager.GetInternalItemIds(new InternalItemsQuery() {IncludeItemTypes = new [] {"Movie", "Episode"}});
                
                foreach (var id in queryResultIds)
                {
                    //Here is a baseItem
                    var item = LibraryManager.GetItemById(id);

                    //DO these two profile users have a sync'd watch status for the item
                    if (item.IsPlayed(user1) && !item.IsPlayed(user2))
                    {
                        //No! the watched statuses are different
                        Log.Info($"\n{user1.Name}: {item.Name} is Played equals: {item.IsPlayed(user1).ToString()} \n {user2.Name}: {item.Name} is Played equals: {item.IsPlayed(user2).ToString()}");


                        //How to set the IsPlayed(User user) parameter?
                        //Try to set the played ticks to the entire RuntimeTicks??                     
                        item.PlaybackPositionTicks = item.RunTimeTicks.Value;
                        
                        //Also, once we've tried to access an items userData, how do we save it back to the database??
                        //Does LibraryManager do this? or do we have to use UserManager??
                        LibraryManager.UpdateItem(item, item.Parent, ItemUpdateType.None);

                        Log.Info($"\n{user1.Name}: {item.Name} is Played equals: {item.IsPlayed(user1).ToString()} \n {user2.Name}: {item.Name} is Played equals: {item.IsPlayed(user2).ToString()}");
                    }
                }

 

Trial and error time....

  • Like 1
Link to comment
Share on other sites

chef

 

27 minutes ago, ebr said:

Hint: look at the progress/playback reporting API.

Thank you sir. Got it! Moving on :)

accountSync4.png

Link to comment
Share on other sites

chef

@mastrmind11

 I have something working, but I am foreseeing a big issue with putting the plugin out into the wild.

 

If the plugin is synchronizing a new account back to an admin account, then we have to be careful not to overwrite all of the playback progress info in the admin account when a fresh account is sync'd to it.

You know what I mean? The fresh account wouldn't have any playback progress, so syncing nothing back to the admin account would overwrite all the progress... on everything...

 

This is why, I'm going to PM you with the DLL, and not post it public here. If someone misused it they could probably mess up their whole library.

 

To run things properly:

1. First sync the admin play state progress status to the new account

2.Then switch to sync back to the admin account moving forward.

 

Ya know what I mean?

 

 

 

 

 

Link to comment
Share on other sites

mastrmind11
10 hours ago, chef said:

@mastrmind11

 I have something working, but I am foreseeing a big issue with putting the plugin out into the wild.

 

If the plugin is synchronizing a new account back to an admin account, then we have to be careful not to overwrite all of the playback progress info in the admin account when a fresh account is sync'd to it.

You know what I mean? The fresh account wouldn't have any playback progress, so syncing nothing back to the admin account would overwrite all the progress... on everything...

 

This is why, I'm going to PM you with the DLL, and not post it public here. If someone misused it they could probably mess up their whole library.

 

To run things properly:

1. First sync the admin play state progress status to the new account

2.Then switch to sync back to the admin account moving forward.

 

Ya know what I mean?

 

 

 

 

 

I hear you, so maybe only allow sync 1 way... ie, dont allow unmarking something watched (or make it an advanced option to allow for it with a big warning?).

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...