xbmc/xbmc — pull request #1418 by Montellese (2012-09-13 12:15:57+00:00)
Title: grouping by movie set and movie outside of the database

This is more of an RFC than an actual PR as I'd like to get some opinions on the general idea and the implementation.

A while ago I had a discussion with @jmarshallnz about doing the grouping of movies into movie sets outside of the videodatabase. The advantage would be that the code GetMoviesByWhere would become a lot easier and GetMoviesNav/GetMoviesByWhere will return a list of movies and not a mixed list of movies and movie sets. The grouping into movie sets would then happen before the movies are displayed in the GUI. I had this idea when I was working on the advanced filtering. When applying a filter it can happen that a filter only matches one of the movies in a movie set so XBMC should only show that single movie and not the whole movie set. While that's not a problem to achieve the problem arises when it comes to loading the artwork for items etc which is done in the background and on the initial list. So the "new" item which was previously part of a movie set does not have any artwork and other details assigned yet.

So I have written a utility class called GroupUtils which is called from CGUIWindowVideoBase after a list of movies has been retrieved from the database and filtered. It currently supports grouping by movie sets (based on CVideoInfoTag::m_setId) and grouping by movie (based on movie title and year).

While grouping by movie set is not a new feature per se (just implemented in another way) I have also added grouping by movie which has been requested a few times in the forum. The idea is to group same movie entries (e.g. differing in resolution, audio language ...) together to a single entry to clean up the list of movies a bit. When a user then clicks a movie he gets to choose which version of the movie he wants to watch.
To be able to do that we need to be able to access the original movie items from the grouped item. I can think of two ways to do that: Either add the possiblity to store "sub-items" in a CFileItem or two extend CFileItem to support multiple paths and multipe CVideoInfoTags/CMusicInfoTags/CPictureInfoTags. I've decided to implement the latter approach but the other approach would probably be less intrusive.
I have integrated this grouping by movie into the GUI and added support for asking the user which version of the file to play. There's no implementation/support yet for marking such a movie as watched/unwatched or to change artwork for it (the video info dialog is opened with the details of the first sub-item so the user can only change the artwork of that item).

So what are your opinions? Does the grouping outside of the database make sense at all? Does the grouping by same movie make sense and how should it be implemented?