Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!




Jellyfin - How to m...
 
Share:
Notifications
Clear all

Jellyfin - How to make "Latest Movies" and "Latest TV Shows" show latest released, instead of latest added

11 Posts
2 Users
0 Likes
2,017 Views
 Hans
(@hans)
Famed Member Admin
Joined: 9 years ago
Posts: 2275
Topic starter  

I have seen that I'm not the only one running into this with JellyFin - "Latest Movies" and "Latest TV Shows" actually show "Latest ADDED files" and not the most recent releases.
So when you add a movie from 1954 today, it will show first in line with "Latest Movies" - cool if that would have been called "Latest added movies", not so cool if you'd rather see the most recent released movies ...

I did see that this has been a question for several years already, and all requests seem to have been closed and/or ignored. (no hard feelings, I'm sure the JellyFin team has their hands full)

Since I didn't find a "clean" and proper way to do this (I think this should be done in the UI, instead of in the database): I would like to caution everybody when using this trick.
The idea I had was to set the Date (DateCreated) that is being used for "Latest ..." to match the actual Release/Aired date (PremiereDate).
This can be done with a simple SQL query (I didn't dare to add this as a trigger on the database):

UPDATE TypedBaseItems SET DateCreated=PremiereDate;

 

So when doing this, the date when a file has been added to the database, will now be set to the actual release date or aired date of a movie or TV episode (or collection or person etc).

Since JellyFin uses an awesome single user database engine (SQLite), you would first need to "disconnect" JellyFin from its database (by stopping the JellyFin server).
Next you will have to execute the SQL query, and after that start the JellyFin server again.

Warning: before running this, probably a good idea to make a backup of "library.db" after (!) stopping JellyFin.

So in short: stop JellyFin, update database, start JellyFin.

JellyFin on my QNAP is stored in "/share/CACHEDEV1_DATA/.qpkg/Jellyfin", and the database files are stored in the DB directory (/share/CACHEDEV1_DATA/.qpkg/Jellyfin/DB).
This may be different on your QNAP, Linux machine, Windows machine of Mac ...

So ... it looks like this on my QNAP in the JellyFin qpkg directory

cd /share/CACHEDEV1_DATA/.qpkg/Jellyfin
./Jellyfin.sh stop
./sqlite3 DB/data/library.db 'UPDATE TypedBaseItems SET DateCreated=PremiereDate;' 
./Jellyfin.sh start &

 

I managed to shove that in a little script so I can occasionally call it. Maybe a cron task for the future, just don't forget to make the script executable with "chmod +x myupdatescript.sh".

Also note that your QNAP comes with several "local" copies of sqlite3, but is nowhere to be found in the path. See also this post.

Again; this may totally trash you database ... so use at your own risk.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 9 years ago
Posts: 2275
Topic starter  

On my QNAP I've added this as a cron job (daily 6 AM - details here).
For this I created a script (fix_dates.sh located in the JellyFin QPKG directory).

echo "0 6 * * * /share/CACHEDEV1_DATA/.qpkg/Jellyfin/fix_dates.sh" >> /etc/config/crontab
crontab /etc/config/crontab && /etc/init.d/crond.sh restart

 


   
ReplyQuote
 Anonymous
Joined: 53 years ago
Posts: 0
 

@hans Hi, where is the db to change this:

UPDATE TypedBaseItems SET DateCreated=PremiereDate;

   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 9 years ago
Posts: 2275
Topic starter  

Depends on your JellyFin setup ... mine (QNAP) was located in the "DB/data/" directory found the install directory of JellyFin.
The database file is called library.db.

Note that SQLite is a single user database engine, so you'll need to stop JellyFin first, before you can access the data.
After that you can run a SQLite query through the command line or use a tool like Valentina (I do usually use this one - they have a free version) or DBBrowser for SQlite (also free) - all available for Windows, Linux and MacOS.


   
ReplyQuote
 Anonymous
Joined: 53 years ago
Posts: 0
 

@hans Bro im here but i dont know whats the next step, could you please help me 


   
ReplyQuote


 Hans
(@hans)
Famed Member Admin
Joined: 9 years ago
Posts: 2275
Topic starter  

No problem:

Click the tab "Execute SQL", paste the SQL statement, and "Execute" (play) button.

 

SQL: 

UPDATE TypedBaseItems SET DateCreated=PremiereDate;

 

p.s. do not forget to close JellyFin!! SQLite only allows one user at a time 😊 

 

Hope this helps.

 


   
ReplyQuote
 Anonymous
Joined: 53 years ago
Posts: 0
 

im sorry bro ill try but when i run the code says that change some rows but when i go to jellyfin always shows latest added now the release date

could you please check or edit the db please 😉 

(link to file removed)


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 9 years ago
Posts: 2275
Topic starter  

Just checked your DB file, but there is no media content in it. Like totally nothing.
I assume you picked the wrong library.db file or your version of JellyFin isn't storing its data there. 😳 

Are you sure you don't have a library.db stored elsewhere?
What OS are you running JellyFin on? What version of JellyFin are you running?


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 9 years ago
Posts: 2275
Topic starter  

p.s. you can find this OS and JellyFin version in JellyFin's Dashboard.

Should show something like this (name and version different of course on your system, shown on the leftside)

Server: MyQNAP
Version: 10.7.7
Operating System: Linux
Architecture: X64

Here you will find some directory info as well, where you "may" find the correct library.db (on the far right)

 
Cache:
/share/CACHEDEV1_DATA/.qpkg/Jellyfin/CACHE
Logs:
/share/CACHEDEV1_DATA/.qpkg/Jellyfin/LOG
Metadata:
/share/CACHEDEV1_DATA/.qpkg/Jellyfin/DB/metadata
Transcodes:
/share/CACHEDEV1_DATA/.qpkg/Jellyfin/DB/transcodes
Web:
/share/CACHEDEV1_DATA/.qpkg/Jellyfin/jellyfin/bin/jellyfin-web
 
In my case, the library.db file is stored in "/share/CACHEDEV1_DATA/.qpkg/Jellyfin/DB/data", so like the "metadata" line, just with "data" instead of "metadata" (6th line).

   
ReplyQuote
 Anonymous
Joined: 53 years ago
Posts: 0
 

Sorry for the delay, but yes my db its empty because im testing on a new installation.

Perhaps I did not understand very well how to do it and that it was necessary to have a library and  So this means that my current library is the one that is going to be changed.

That means that every time I add a new title I have to run this Script?


   
ReplyQuote


 Hans
(@hans)
Famed Member Admin
Joined: 9 years ago
Posts: 2275
Topic starter  

No worries 😉 

Maybe this explains it better ..

The "Latest Movies" or "Latest TV Show Episodes" are listed by the date they were added, which is understandable - this way we'd see the most recent additions (Netflix for example does this as well).
However when setting up your initial library, you may be adding a very old movie, which then would appear in the beginning of the "latest" list as well.
This is something I would rather not see.

Instead I would have preferred to see a "most recent released" category to movies and TV shows.
Bets would be to have this additionally ... so we can see both "latested added to the library" and "most recent released".

So what the query does: it updates the "date added" field to the "release date" value.
This temporary work around would now make it that the list shows most recent release videos and not most recent added videos.

In the long run, this may not be needed anymore - depending on your preferences and the future development of JellyFin.

For now, I run this every night, until I have my library the way I want it 😉 
Hope that makes sense ...


   
ReplyQuote

Like what you see and you'd like to help out? 

The best way to help is of course by assisting others with their questions here in the forum, but you can also help us out in other ways:

- Do your shopping at Amazon, it will not cost you anything extra but may generate a small commission for us,
- send a cup of coffee through PayPal ($5, $10, $20, or custom amount),
- become a Patreon,
- donate BitCoin (BTC), or BitCoinCash (BCH).

Share: