Let me explain.
I dropped my TV library as I wanted to totally start again using TVDB agent (was using something else). Anyway all was good, if a little slow, until I noticed that 4 or 5 old shows were showing in the recently added section before brand new episodes that had just aired. I investigated in the database and found that these 4 or 5 shows had been added with and updated_at or added_at date of 2038-01-01 for some odd reason.
So I ran some SQL to update the three affected tables
update media_items set updated_at = created_at where updated_at > date('2016-10-01'); update media_parts set updated_at = created_at where updated_at > date('2016-10-01'); update metadata_items set added_at = created_at where added_at > date('2016-10-01');
My actual questions though are
- Why would this happen in the first place
- Will my updates have affected anything else in the system adversely??
Thanks!
Mark
If you add files ‘in the course of creating a library’, Plex uses the file date of your videos as the ‘Added at’ date.
The idea behind this is that it is of limited value to set a whole library worth of media to the same ‘Added at’ date.
Some of your files on disk have a faulty ‘created at’ time stamp.
Well bugger me how’d that happen then!
Guess it’s time to try and reset those date modified values somehow. Thanks!
Just in case it helps anyone else I knocked up a real simple C# function to fix up my file issues, it’s recursive so just call it with the root directory of your TV shows or movies and Bobs yer uncle.
private static void ProcessFiles(string directory)
{
foreach (string file in Directory.GetFiles(directory))
{
var lastWriteTime = File.GetLastWriteTime(file);
if (lastWriteTime.Year > DateTime.Now.Year)
{
File.SetLastWriteTime(file, File.GetCreationTime(file));
Console.WriteLine("{0}", file);
}
}
foreach (string dir in Directory.GetDirectories(directory))
{
ProcessFiles(dir);
}
}
@poweredbyporkers said:
Well bugger me how’d that happen then!
I blame NAS devices without a battery-buffered real-time-clock.
If you bott up such a device without a working internet connection available, the call to the ntp
server fails and the device runs with a fantasy datetime
until the next ntp
retry (if there ever is a ntp retry during that session…).