Change the addedAt date?

I have a bunch of movies in my collection that I ripped from DVD but I’ve started to replace some with higher quality BluRay Disc rips.
The problem is that Plex shows these new BD rips as unwatched and recently added. I can manually set them to “watched” status but is there any way to change the date it was added to the library? I would like to set it to be the same date as the original DVD rip file.

If I get info on the movie then view the XML, I see there is an “addedAt” value which is the Unix time of the date it was added. How can I set/change that value?

Thanks

Typically when I ‘upgrade’ an item I just name the new item the same as the old item and overwrite the old one with the new one then Analyze the new entry.

My file names are always perfect to begin with so that WILL make a big difference.

The previous version than this current version screwed up TV Shows (maybe movies too, but I can’t confirm that right now) wherein it was necessary to bump the sort order to something else, then back to Name (where it had been for years) at the library level. You could have an issue in that area, but it’s hard to tell with the information you’ve given.

Thanks for the help but that won’t help me here. Sometimes the names do match up enough so that Plex will see the new file as the same movie and will put them together. I can then remove the old file and empty the trash in Plex.
However, that isn’t always an option or Plex doesn’t match them up.
So my question remains, how can I manually change/set the date a movie was added?

I use this method when a better version isn’t matched with the pre-existing version. I think it works for me because I know I have changed the default agent that Plex uses to match movies over time, so some movies have been matched with one agent, and others with a different agent.
Using Plex Web…

  1. Select the version added as a new movie to get to the pre-play screen
  2. Select “Fix Incorrect Match” from the the three dots (elipsis)
  3. Wait patiently… Plex will find a list of possible matches
  4. IMPORTANT. DO NOT SELECT ONE OF THESE MATCHES
  5. Click “Search Options” (found above the list of matches.)
  6. Enter the correct Title of the Movie, and optionally, the year
  7. Select a different agent to use for the match. DO NOT USE AUTO-MATCH
  8. Click Search
  9. Select the correct match, and save.

In my case, the current default agent is “Plex Movie” so I select:“The Movie Database” which is the agent I previously used. In most cases, the title and year are exactly the same as the auto-match. Plex remembers which agent was used in matching as well as the title and year. That causes a new addition when they are not matched with the same agent. This trick should force Plex into using the same agent, so they become one entry with duplicate versions.

Plex might get a little glitchy for a minute or two while it sorts out the new match. The movie may even show as unavailable,. Just ignore that. Head back to the library, and your new version should now show up as a duplicate version with your original, and those temporary glitches and the New Addition will have disappeared.

alternatively, you could use the “Join” movies option. I have mixed results using that, because some times it joins the old with the new match, and sometimes it joins the new with the old match. They always become one movie, but not necessarily removing the new addition.

Thanks for those suggestions. I’ve tried them before and as you mentioned, the results are not always correct.
However, I still am looking for a way to manually set the addedAt value.

Instead of trying to figure out a way to update an existing movie, let’s go with the idea that I want to add a new movie to the library but don’t want it listed under “Recently Added”. I would need to add it then adjust the addedAt value to an older date (for example the release date).

The first method I suggested always works for me. I upgraded the versions of 3 movies yesterday, each came in as a new addition, but reverted to the original addedAt value after I manually rematched. But I do know that is because of how the original movies were matched and which agent was originally used. Upgraded versions that have originally used the same agent I currently use always match and never a new addition. If you have always used the same agent, my best guess would be your naming is not quite up to the Plex standard.

Give us an example of an actual movie name and your naming structure, and maybe someone will identify the problem.

@leelynds Thanks for staying on this thread. I appreciate your efforts.

I ended up fixing this by directly setting the date in the database. For anyone that wishes to do the same, here is how I did it.

First I made a backup of the database file just in case this goes horribly wrong. To be completely safe, you could shutdown your Plex Media Server application first but it should be just fine to make these changes with it running. SQLite’s locking system is designed to handle concurrent processes accessing the database file, and we are making very small changes to a single table. But perhaps don’t do this during the Plex maintenance window. :wink:

# cd "/volume1/Plex/Library/Application Support/Plex Media Server/Plug-in Support/Databases/"
# cp com.plexapp.plugins.library.db{,.bak}

Next was to run an SQL query to make sure it will be adjusting only the movies I want to change. In this case, I want to set the dates for the Star Wars movies in my library.

# sqlite3 com.plexapp.plugins.library.db "SELECT title,originally_available_at,added_at FROM metadata_items WHERE title LIKE 'star wars%';"
Star Wars IV: A New Hope|1977-05-25 00:00:00|2016-12-15 11:08:59
Star Wars V: The Empire Strikes Back|1980-06-20 00:00:00|2016-12-15 11:09:33
Star Wars VI: Return of the Jedi|1983-05-25 00:00:00|2016-12-15 11:10:02
Star Wars VII: The Force Awakens|2015-12-14 00:00:00|2016-12-15 11:11:14

The query is properly returning the 4 Star Wars movies. The originally_available_at field is the “Release Date” and added_at field is the “Date Added”. As you can see, the Date Added for these are a couple of weeks ago.

Now to run the SQL command to set the Date Added to be the same as the Release Date.

# sqlite3 com.plexapp.plugins.library.db "SELECT 'UPDATE metadata_items SET added_at=''' || originally_available_at || ''' WHERE id=''' || id || ''';' FROM metadata_items WHERE title LIKE 'star wars%';" | sqlite3 com.plexapp.plugins.library.db

Run the SQL query again and now the Date Added is set properly.

# sqlite3 com.plexapp.plugins.library.db "SELECT title,originally_available_at,added_at FROM metadata_items WHERE title LIKE 'star wars%';"
Star Wars IV: A New Hope|1977-05-25 00:00:00|1977-05-25 00:00:00
Star Wars V: The Empire Strikes Back|1980-06-20 00:00:00|1980-06-20 00:00:00
Star Wars VI: Return of the Jedi|1983-05-25 00:00:00|1983-05-25 00:00:00
Star Wars VII: The Force Awakens|2015-12-14 00:00:00|2015-12-14 00:00:00

Perfect! Here is how it appears in Plex

Kinda awesome to see movies added into Plex “40 years ago”

Now, if you want to change a single entry instead of using a wildcard query, you can use the id field in the commands like so.

Query to get the ID for all Star Wars entries.

# sqlite3 com.plexapp.plugins.library.db "SELECT id,title,originally_available_at,added_at FROM metadata_items WHERE title LIKE 'star wars%';"
58372|Star Wars IV: A New Hope|1977-05-25 00:00:00|2016-12-15 11:08:59
58373|Star Wars V: The Empire Strikes Back|1980-06-20 00:00:00|2016-12-15 11:09:33
58374|Star Wars VI: Return of the Jedi|1983-05-25 00:00:00|2016-12-15 11:10:02
58375|Star Wars VII: The Force Awakens|2015-12-14 00:00:00|2016-12-15 11:11:14

Change the 2nd WHERE clause in the command (WHERE title LIKE 'star wars%';)
to use the ID of 58373 (WHERE id='58373';) so that it only changes “Empire”

# sqlite3 com.plexapp.plugins.library.db "SELECT 'UPDATE metadata_items SET added_at=''' || originally_available_at || ''' WHERE id=''' || id || ''';' FROM metadata_items WHERE id='58373';" | sqlite3 com.plexapp.plugins.library.db

For those confused by the SQL command, it is building the UPDATE command inside of a SELECT query, injecting the SELECT return values in the proper locations. The output is then redirected back to sqlite to be executed. If you were to run the command above but without the | sqlite3 com.plexapp.plugins.library.db part, it would simply output the UPDATE command to the console instead. You could use this method to verify the changes before actually doing it.

UPDATE metadata_items SET added_at='1980-06-20 00:00:00' WHERE id='58373';

This kind of SELECT/UPDATE combo works great for multiple entries to dynamically build UPDATE commands. Here is the output of the first command for all of the Star Wars entries.

UPDATE metadata_items SET added_at='1977-05-25 00:00:00' WHERE id='58372';
UPDATE metadata_items SET added_at='1980-06-20 00:00:00' WHERE id='58373';
UPDATE metadata_items SET added_at='1983-05-25 00:00:00' WHERE id='58374';
UPDATE metadata_items SET added_at='2015-12-14 00:00:00' WHERE id='58375';

I am in no way an SQL guru and there is probably a better method to do this but this way has worked well for me. YMMV.

Hope this helps.

@Smudge
Great! You got it fixed, one way or the other! Back in the day, I probably would have tried something similar if nothing else for the challenge. Now that I’m old and retired, I tend to choose the easiest method. In my case, maybe because of the different agents over time, my method has always worked.

But, I may try your method to correct this problem I had, almost same, but not quite…

If my database gets wrecked, I’m gonna be lookin’ for you … :smiley:

@leelynds Using the ID value to set the date will totally work in that situation.

# sqlite3 com.plexapp.plugins.library.db "SELECT id,title,originally_available_at,added_at FROM metadata_items WHERE title LIKE 'Donald duck%';"
12345|Donald Duck's Christmas Favourites|2008-01-01 00:00:00|2015-11-09 15:02:00

If you don’t want the Date Added to be Jan 1 2008 (Release Date), skip the dynamic generation command shown above and just manually create an UPDATE command with the date you want. Here is an example command that will set the Date Added to this last Christmas. (Be sure to use the proper ID number for the video and not my 12345 example)

# sqlite3 com.plexapp.plugins.library.db "UPDATE metadata_items SET added_at='2016-12-25 00:00:00' WHERE id='12345';"

Thanks!. I’ll probably try later, when my annoyance level and OCD at the bug gets the better of me and I decide " I just gotta have this right." Heh, heh … for now I’m trying to ignore it.