Jump to content

Help retrieving Watched status from Library.db


Recommended Posts

Posted

I'm constantly running out of space on my harddisk, so I'm trying to make a script that each night searches through the Emby library for watched Series episodes and then deletes the watched episodes that are over for instance 1 week old.

 

I'm using Kodi with Emby library and only the default profile, so no different users or anything like that.

 

I've been looking in the Library.db with DB Browser for SQLite and have found by using this select statement I get the individual episodes:

 

select * from typedbaseitems where unratedtype = 'Series' and mediatype = 'Video'

 

I just can't seem to figure out how to retrieve the Watched information for the episodes. I can see DateLastSaved but that doesn't really tell me if and when the episode was watched through the end. 

 

Can someone point me in the right direction?

mastrmind11
Posted

I'm fairly certain Emby can be set to update the show's watched state in its corresponding .nfo file, in which case you can just parse the .nfo files and remove the corresponding shows.

Posted

Hi @@djon, if you're running the stable release, user data is in a separate database, userdata_v2.db. If you're on beta or dev it's been merged into library,db and we haven't yet documented a process on how to extract it.

 

I would suggest using our backup and restore plugin which you can find in the plugin catalog.

Posted

I am on version Version 3.0.5911.0

 

Looking in the Userdata_v2.db I can see the playCount and a key. What does the key field correspond to in library.db, so I can join them and find the filepath?

Posted

Sorry, in your old version the key will not be in library db. Newer versions of emby server have a UserDataKey column that you could join them with.

Posted

Okay I upgraded to the latest Emby now.

 

Now I can't open Library.db as it requires a Password as it's apparently SQL Cipher encrypted. What's the password?

Happy2Play
Posted

Okay I upgraded to the latest Emby now.

 

Now I can't open Library.db as it requires a Password as it's apparently SQL Cipher encrypted. What's the password?

Had no problem opening it with SQLite Database Browser Portable.

Posted (edited)

Ok, I can only read the db when Emby is shut down. When it's running it apparently locks the db in the new version of Emby. Any way around this?

Edited by djon
Posted

3.0.8500 opens the database in exclusive mode which is what is causing that error. The beta is not doing that although it possible to be added back again. Did you go through the forced upgrade that 3.0.8500 presented you with? You should get that done, because the beta has enough changes that we're no longer going to do the upgrade and instead we're just going to rescan the library entirely (if you're coming from a really old version like you are).

 

you should backup library.db and userdata_v2.db throughout this process in case you need to retry. on the other hand with the beta you could consider deleting library.db and letting it rescan your library. again if you make backups you can try and see what produces the best result.

 

please note, i'm only presenting you with information, not trying to encourage you to install pre-release as it is a work in progress so your transition might not be perfectly seamless. but since you're running sql queries i assume you know what you're doing, so if you make backups of all the databases it shouldn't be hard to experiment.

Posted

I don't remember 3.0.8500 presenting me with anything. I just chose Upgrade and it did everything by itself, including upgrading the databases. Is that what you mean?

 

I think I'll stall my plans and see if the next stable version locks the DB or not. Not much point in making my solution if it won't work in the near future anyway.

Posted

You could try the PORTABLE version of Emby Server.

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...