I just updated to PMS beta 1.26.1.5762 to address the recent issue of manually set Originally Available dates not saving. The dates now save properly on the Edit screen, but display as year “1900” in my Library. Anyone else seeing this?
I’m not suggesting anybody should do this, because I haven’t really tested the edges very well.
UPDATE metadata_items SET year =
STRFTIME('%Y',originally_available_at,'unixepoch') WHERE year <>
STRFTIME('%Y',originally_available_at,'unixepoch') AND metadata_type IN (1);
Yeah, uh, cosmetic … but also, used for Smart Playlists.
It’s the same issue, and the same thing works for Albums/Tracks, but again I haven’t tested it much.
UPDATE metadata_items SET year =
STRFTIME('%Y',originally_available_at,'unixepoch') WHERE year <>
STRFTIME('%Y',originally_available_at,'unixepoch') AND metadata_type IN (9,10);
I notice that this update didn’t fixup all pre-existing mismatches between year and originally_available_at. I was surprised by weird year values for a large number of TV episodes - things I haven’t updated recently.
It appears that Refresh Metadata doesn’t forcibly update all mismatches either. (It does when Originally Available At is modified.)
So I’m considering running this:
UPDATE metadata_items
SET year = STRFTIME('%Y',originally_available_at,'unixepoch')
WHERE
(
originally_available_at IS NOT NULL
AND
(
year IS NULL
OR year <> STRFTIME('%Y',originally_available_at,'unixepoch')
)
);
Edit: I made a backup and did it. I’ll let you know if anything explodes.
Edit a month later: Nothing explodes. I’ve used it again to fix more bad dates from the agents.
@Plan-B I saw your comment in another thread. If you’re comfortable running a SQL update against your database, the above will shotgun-correct the year based on the saved originally_available_at.
@Volts Thanks for this. I’m very tempted to try it. I haven’t touched SQL in over a decade so I’m gonna give it a couple of PMS update cycles to see if they figure out a way to fix broken/mismatched years.
I was surprised this version didn’t update year already. It’s possible a future update will do so, or a future update will do so as part of the normal periodic optimization process.
If not, you don’t need to be an SQL expert. If you can find your Plex SQLite binary and your com.plexapp.plugins.library.db database file, the SQL statement can be copied & pasted.
LMK if you decide to do that and want a walkthrough.
@Volts I realized I had more media stuck at 1900 than I realized when I viewed all titles and sorted by year. So I tried the SQL update and couldn’t figure out how to get it to work.
I started by running: .open "/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/com.plexapp.plugins.library.db"
Then did a simple copy/paste of your update and got: Error: no such table: metadata_items
I had to find a time when I was pretty sure no one was going to try and watch anything. So I might try again later and see if I can figure out what went wrong (probably didn’t open the DB file correctly).