Hack to get proper "By Date Added" in TV Shows (Gotham-SQL)
#1
I'm not sure how many other people are desperate for the new TV Shows sorting option added to Helix and therefore how useful this is but I found a dirty way to achieve this so thought I'd share. It can no doubt be improved upon.

If you've not tried Helix out yet and seen the new date sorting I'm referring to it basically makes "By date added" work the same in TV Shows as it does in Movies. So whenever you add a new episode of a show, that show gets bumped to the top of the list. This is how pretty much every home sat/cable PVR box I've ever seen does it and the logic for doing it any differently alludes me, but that's another discussion. You may wonder why I don't just switch to Helix and while I've tried and would love to stay on it, exactly zero skins have been updated to work with Helix's new PVR skinning requirements and as I use PVR a lot, Helix is a no-go.

So, I tried and failed to update my favourite skins myself but the PVR migration guide is useless to all but skilled skinners, I asked around and while a few of the skinners are saying Helix changes will get made, none seem like they're coming any time soon. Someone got me excited about patching Helix sorting into Gotham but that also turned into nothing so the only other way I could think of, which turns out to work, is making some changes in the SQL database.

Warning: This will change the lastPlayed timestamp of all files in your database to match the dateAdded attribute (which is actually the file modified date). If you care at all about the lastPlayed (as in date last played) attribute or use it in any way, don't do this.

Install a copy of HeidiSQL and open up the XBMC database. In the [Query] tab enter the following:

Code:
UPDATE files
SET lastPlayed = dateAdded

Press F9 or press the little blue Play icon in the toolbar to execute the query. Open XBMC and in the TV Shows section, set sorting to "Last Played".

I know this targets all files, including movies however my SQL skills weren't quite enough to apply this change only to TV. I got as far as this in order to filter only TV:

Quote:Select files.idFile, files.idPath, files.strFilename from files, episode
WHERE (files.strFilename LIKE '%S__E__%' OR files.strFilename LIKE '%S____E__%') AND files.idFile = episode.idFile

which brings back only TV episodes but then I couldn't work out how to apply the copying of the dateAdded attribute into the lastPlayed column just for these results, maybe someone can offer the correct query for achieving that. For me though, as I don't give a rat's about the lastPlayed stat on movies or TV, it was of no consequence for me to copy it across for all files and it works great. I guess it will need to be run on a regular basis to make the changes on new shows but I can live with that until either skins mature or (please, please, please!) Helix TV sorting makes it's way into Gotham!
Reply
#2
I had another look at this and worked out the MySQL command line to achieve the same thing:

Code:
mysql --host=127.0.0.1 --user=xbmc --password=xbmc --execute "UPDATE files SET lastPlayed = dateAdded" --database=myvideos78
Reply

Logout Mark Read Team Forum Stats Members Help
Hack to get proper "By Date Added" in TV Shows (Gotham-SQL)0